Skip to content

Commit eea069e

Browse files
vsytchtensorflower-gardener
authored andcommitted
Allow single core embeddings
PiperOrigin-RevId: 781291822
1 parent 1773d87 commit eea069e

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

tensorflow/core/tpu/kernels/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ cc_library(
194194
"//tensorflow/core/platform:statusor",
195195
"@com_google_absl//absl/log",
196196
"@com_google_absl//absl/log:check",
197+
"@com_google_absl//absl/numeric:bits",
197198
"@com_google_absl//absl/status",
198199
"@com_google_absl//absl/strings",
199200
"@com_google_absl//absl/types:span",

tensorflow/core/tpu/kernels/sparse_core_xla_ops.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ limitations under the License.
2424

2525
#include "absl/log/check.h"
2626
#include "absl/log/log.h"
27+
#include "absl/numeric/bits.h"
2728
#include "absl/status/status.h"
2829
#include "absl/strings/str_cat.h"
2930
#include "absl/types/span.h"
@@ -108,10 +109,11 @@ void GetAndSetSparseCoresPerLogicalDevice(OpKernelConstruction* ctx,
108109

109110
// Validate the final value.
110111
OP_REQUIRES(
111-
ctx, num_sparsecores_per_device == 2 || num_sparsecores_per_device == 4,
112-
absl::InvalidArgumentError(
113-
absl::StrCat("num_sparsecores_per_device must be 2 or 4, but got: ",
114-
num_sparsecores_per_device)));
112+
ctx,
113+
absl::has_single_bit(static_cast<uint32_t>(num_sparsecores_per_device)),
114+
absl::InvalidArgumentError(absl::StrCat(
115+
"num_sparsecores_per_device must be a power of two, but got: ",
116+
num_sparsecores_per_device)));
115117
}
116118

117119
// Returns the number of ops in the tuple.

0 commit comments

Comments
 (0)