diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h index a732bf169dc7a..1cb4d82835619 100644 --- a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h +++ b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h @@ -2048,6 +2048,9 @@ inline ShapeInferContext::Ints ShapeInferContext::GetAttrInts(const char* attr_n Ort::ThrowOnError(ort_api_->ReadOpAttr(attr, ORT_OP_ATTR_INTS, ints.data(), out, &out)); return ints; } else { + if (out == 0u) { + return {}; + } return {i}; } } @@ -2072,6 +2075,9 @@ inline ShapeInferContext::Floats ShapeInferContext::GetAttrFloats(const char* at Ort::ThrowOnError(ort_api_->ReadOpAttr(attr, ORT_OP_ATTR_FLOATS, floats.data(), out, &out)); return floats; } else { + if (out == 0u) { + return {}; + } return {f}; } } @@ -2112,6 +2118,9 @@ inline ShapeInferContext::Strings ShapeInferContext::GetAttrStrings(const char* } return strings; } else { + if (out == 0u) { + return {}; + } return {std::string{c}}; } }