Skip to content

Commit

Permalink
[numpy] Fix build and test failures under NumPy 2.0.
Browse files Browse the repository at this point in the history
NumPy 2.0 makes many breaking changes to its C and Python APIs. This change updates users of NumPy to fix test failures found under NumPy 2.

PiperOrigin-RevId: 657768879
Change-Id: I59178e0b9f448fd7002674b46da1f041e25ba067
  • Loading branch information
hawkinsp authored and copybara-github committed Jul 30, 2024
1 parent ac13ce8 commit 2ceef01
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions saxml/server/tf/np_conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ char const *NumpyTypeName(int numpy_type) {
TYPE_CASE(NPY_DATETIME);
TYPE_CASE(NPY_TIMEDELTA);
TYPE_CASE(NPY_HALF);
TYPE_CASE(NPY_NTYPES);
TYPE_CASE(NPY_NOTYPE);
TYPE_CASE(NPY_USERDEF);

Expand Down Expand Up @@ -132,8 +131,8 @@ tensorflow::Status StringTensorToPyArray(const tensorflow::Tensor &tensor,
" of a TF_STRING tensor to a numpy ndarray");
}

if (PyArray_SETITEM(dst, PyArray_ITER_DATA(iter.get()), py_string.get()) !=
0) {
if (PyArray_SETITEM(dst, static_cast<char *>(PyArray_ITER_DATA(iter.get())),
py_string.get()) != 0) {
return tensorflow::errors::Internal("Error settings element #", i,
" in the numpy ndarray");
}
Expand Down Expand Up @@ -171,8 +170,8 @@ tensorflow::Status GetPyDescrFromDataType(tensorflow::DataType dtype,
#undef TF_DTYPE_TO_PY_ARRAY_TYPE_CASE

default:
return tensorflow::errors::Internal(
"Unsupported tf type: ", tensorflow::DataType_Name(dtype));
return tensorflow::errors::Internal("Unsupported tf type: ",
tensorflow::DataType_Name(dtype));
}

return absl::OkStatus();
Expand Down

0 comments on commit 2ceef01

Please sign in to comment.