Skip to content

Commit 75ea0b3

Browse files
chsiggtensorflower-gardener
authored andcommitted
Provide overload to cope with const-ness change of NumPy's PyUFuncGenericFunction.
See #40688, #40654. PiperOrigin-RevId: 318452381 Change-Id: Icc5152f2b020ef19882a49e3c86ac80bbe048d64
1 parent ec14651 commit 75ea0b3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tensorflow/python/lib/core/bfloat16.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ bool RegisterBfloat16Cast(int numpy_type, bool cast_is_safe) {
517517
}
518518

519519
template <typename InType, typename OutType, typename Functor>
520-
void BinaryUFunc(char** args, npy_intp* dimensions, npy_intp* steps,
520+
void BinaryUFunc(char** args, const npy_intp* dimensions, const npy_intp* steps,
521521
void* data) {
522522
const char* i0 = args[0];
523523
const char* i1 = args[1];
@@ -532,11 +532,17 @@ void BinaryUFunc(char** args, npy_intp* dimensions, npy_intp* steps,
532532
}
533533
}
534534

535+
// Numpy changed const-ness of PyUFuncGenericFunction, provide overload.
535536
template <typename Functor>
536537
void CompareUFunc(char** args, npy_intp* dimensions, npy_intp* steps,
537538
void* data) {
538539
BinaryUFunc<bfloat16, npy_bool, Functor>(args, dimensions, steps, data);
539540
}
541+
template <typename Functor>
542+
void CompareUFunc(char** args, const npy_intp* dimensions,
543+
const npy_intp* steps, void* data) {
544+
BinaryUFunc<bfloat16, npy_bool, Functor>(args, dimensions, steps, data);
545+
}
540546

541547
struct Bfloat16EqFunctor {
542548
npy_bool operator()(bfloat16 a, bfloat16 b) { return a == b; }

0 commit comments

Comments
 (0)