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 tensor element type for register custom op shape infer function #21387

Merged
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
2 changes: 1 addition & 1 deletion include/onnxruntime/core/session/onnxruntime_cxx_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,7 @@

size_t GetInputCount() const { return input_shapes_.size(); }

Status SetOutputShape(size_t indice, const Shape& shape);
Status SetOutputShape(size_t indice, const Shape& shape, ONNXTensorElementDataType type = ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT);

Check warning on line 2219 in include/onnxruntime/core/session/onnxruntime_cxx_api.h

View workflow job for this annotation

GitHub Actions / Lint C++

[cpplint] reported by reviewdog 🐶 Lines should be <= 120 characters long [whitespace/line_length] [2] Raw Output: include/onnxruntime/core/session/onnxruntime_cxx_api.h:2219: Lines should be <= 120 characters long [whitespace/line_length] [2]

int64_t GetAttrInt(const char* attr_name);

Expand Down
3 changes: 2 additions & 1 deletion include/onnxruntime/core/session/onnxruntime_cxx_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -1996,9 +1996,10 @@ inline ShapeInferContext::ShapeInferContext(const OrtApi* ort_api,
}
}

inline Status ShapeInferContext::SetOutputShape(size_t indice, const Shape& shape) {
inline Status ShapeInferContext::SetOutputShape(size_t indice, const Shape& shape, ONNXTensorElementDataType type) {
OrtTensorTypeAndShapeInfo* info = {};
ORT_CXX_RETURN_ON_API_FAIL(ort_api_->CreateTensorTypeAndShapeInfo(&info));
ORT_CXX_RETURN_ON_API_FAIL(ort_api_->SetTensorElementType(info, type));

using InfoPtr = std::unique_ptr<OrtTensorTypeAndShapeInfo, std::function<void(OrtTensorTypeAndShapeInfo*)>>;

Expand Down
1 change: 1 addition & 0 deletions onnxruntime/core/session/custom_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ struct OrtShapeInferContext {
}
}
ONNX_NAMESPACE::updateOutputShape(ctx_, index, shape_proto);
ONNX_NAMESPACE::updateOutputElemType(ctx_, index, info->type);
return onnxruntime::Status::OK();
}

Expand Down
Loading