Skip to content

Commit 65cd16b

Browse files
authored
Merge pull request #1404 from shrinath-suresh/ts-kservev2-bytes-fix
Kserve V2 - Fix for Bytes output
2 parents 91a4f51 + d161196 commit 65cd16b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ts/torch_handler/request_envelope/kservev2.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
# NOTE: numpy has more types than v2 protocol
3131
_NumpyToDatatype["object"] = "BYTES"
3232

33+
# Adding support for unicode string
34+
# Ref: https://numpy.org/doc/stable/reference/arrays.dtypes.html
35+
_NumpyToDatatype["U"] = "BYTES"
36+
3337

3438
def _to_dtype(datatype: str) -> "np.dtype":
3539
dtype = _DatatypeToNumpy[datatype]
@@ -38,6 +42,8 @@ def _to_dtype(datatype: str) -> "np.dtype":
3842

3943
def _to_datatype(dtype: np.dtype) -> str:
4044
as_str = str(dtype)
45+
if as_str not in _NumpyToDatatype:
46+
as_str = getattr(dtype, "kind")
4147
datatype = _NumpyToDatatype[as_str]
4248

4349
return datatype

0 commit comments

Comments
 (0)