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

Throw for scalar input to Shape. #18504

Closed
wants to merge 1 commit into from
Closed
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: 2 additions & 0 deletions onnxruntime/core/providers/cpu/tensor/shape_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Shape final : public OpKernel {
const TensorShape& input_shape = input->Shape();

int64_t rank = gsl::narrow_cast<int64_t>(input_shape.NumDimensions());
// ONNX shape inferencing doesn't work with a scalar. Spec does not say it's unsupported.
ORT_ENFORCE(rank != 0, "Shape of a scalar is not supported");

if (!needs_slicing_) { // vanilla use of Shape (no slicing)
Tensor* output = context->Output(0, {rank});
Expand Down
Loading