diff --git a/onnxruntime/core/providers/cpu/generator/constant_of_shape_base.h b/onnxruntime/core/providers/cpu/generator/constant_of_shape_base.h index ffd954f13e568..f08f134d0c080 100644 --- a/onnxruntime/core/providers/cpu/generator/constant_of_shape_base.h +++ b/onnxruntime/core/providers/cpu/generator/constant_of_shape_base.h @@ -78,8 +78,9 @@ class ConstantOfShapeBase { auto* t_proto_p = t_proto.get(); #endif if (info.GetAttr("value", t_proto_p).IsOK()) { - ORT_ENFORCE(t_proto_p->dims_size() == 1, "Must have a single dimension"); - ORT_ENFORCE(t_proto_p->dims()[0] == 1, "Must have a single dimension of 1"); + for (auto dim : t_proto_p->dims()) { + ORT_ENFORCE(dim == 1, "The value attribute of ConstantOfShape must be a single-element tensor"); + } SetValueFromTensorProto(*t_proto_p); } else { float f_value = 0.f; diff --git a/onnxruntime/core/providers/shared_library/provider_wrappedtypes.h b/onnxruntime/core/providers/shared_library/provider_wrappedtypes.h index 1ab32e649ed40..cdbd0c074f443 100644 --- a/onnxruntime/core/providers/shared_library/provider_wrappedtypes.h +++ b/onnxruntime/core/providers/shared_library/provider_wrappedtypes.h @@ -78,6 +78,8 @@ struct int64s final { const int64_t* data() const { return g_host->int64s__data(this); } const int64_t& operator[](int index) const { return Get(index); } void Reserve(int size) { g_host->int64s__Reserve(this, size); } + const int64_t* begin() const { return data(); } + const int64_t* end() const { return data() + size(); } PROVIDER_DISALLOW_ALL(int64s) };