Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for string data type #2478

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Runtime/OMUnique.inc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ int isLessNum(void *arg1, void *arg2, OM_DATA_TYPE dataType) {
return *((int32_t *)arg1) < *((int32_t *)arg2);
case ONNX_TYPE_INT64:
return *((int64_t *)arg1) < *((int64_t *)arg2);
// case ONNX_TYPE_STRING:
case ONNX_TYPE_STRING:
Copy link
Collaborator Author

@hamptonm1 hamptonm1 Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the missing ONNX_TYPE_STRING case for OMUnique.inc

return *((const char **)arg1) < *((const char **)arg2);
case ONNX_TYPE_BOOL:
return *((bool *)arg1) < *((bool *)arg2);
// case ONNX_TYPE_FLOAT16:
Expand Down
3 changes: 2 additions & 1 deletion src/Runtime/PyExecutionSessionBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ std::vector<py::array> PyExecutionSessionBase::pyRun(
dtype = ONNX_TYPE_INT32;
else if (py::isinstance<py::array_t<std::int64_t>>(inputPyArray))
dtype = ONNX_TYPE_INT64;
// string type missing
// else if (py::isinstance<py::array_t<const char *>>(inputPyArray))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chentong319 Here I added the missing string type which uses const char * pybind11 datatype.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to comment this out for now until we get pybind11 support for it....I get the error runtimeerror: numpy type info missing for pkc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I was doing a bit more research and came across this link: pybind/pybind11#2337. I am pretty sure that it can prove to be helpful in our case with regards to const char * in pybind11

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the first place we got assertion error. The link you provided is really helpful.

// dtype = ONNX_TYPE_STRING;
else if (py::isinstance<py::array_t<bool>>(inputPyArray))
dtype = ONNX_TYPE_BOOL;
else if (py::isinstance<py::array_t<float_16>>(inputPyArray))
Expand Down
Loading
Loading