6 #ifndef SHARED_PROVIDER
13 #ifdef __has_attribute
14 #define ORT_HAVE_ATTRIBUTE(x) __has_attribute(x)
16 #define ORT_HAVE_ATTRIBUTE(x) 0
19 #if ORT_HAVE_ATTRIBUTE(nodiscard)
20 #define MUST_USE_RESULT [[nodiscard]]
21 #elif defined(__clang__) && ORT_HAVE_ATTRIBUTE(warn_unused_result)
22 #define MUST_USE_RESULT __attribute__((warn_unused_result))
24 #define MUST_USE_RESULT
29 namespace onnxruntime {
36 template <
class Impl_t>
55 return GetAttr<T>(name, &tmp).IsOK() ? tmp : default_value;
64 if (!GetAttr<T>(name, value).IsOK())
65 *value = default_value;
75 return GetAttrs<T>(name, tmp).IsOK() ? tmp : default_value;
96 return GetAttrs(name, tmp).IsOK() ? tmp : default_value;
102 template <
typename T>
105 template <
typename T>
109 std::vector<std::reference_wrapper<const std::string>>& refs)
const;
118 return gsl::narrow_cast<uint32_t>(impl_->getNumInputs());
122 return gsl::narrow_cast<uint32_t>(impl_->getNumOutputs());
126 return impl_->getInputType(index);
131 return const_cast<Impl_t*
>(impl_)->getOutputType(index);
136 return impl_->getAttribute(name);
147 const Impl_t* impl_ =
nullptr;
MUST_USE_RESULT Status GetAttrs(const std::string &name, TensorShapeVector &out) const
void GetAttrOrDefault(const std::string &name, T *value, const T &default_value) const
ProtoHelperNodeContext(const onnxruntime::Node &node)
T GetAttrOrDefault(const std::string &name, const T &default_value) const
ProtoHelperNodeContext()=delete
uint32_t GetPrimitiveAttrElementCount(ONNX_NAMESPACE::AttributeProto_AttributeType type, const std::string &name) const noexcept
GLsizei const GLchar *const * string
const ONNX_NAMESPACE::AttributeProto * TryGetAttribute(const std::string &name) const
#define ORT_ENFORCE(condition,...)
bool HasPrimitiveAttribute(ONNX_NAMESPACE::AttributeProto_AttributeType type, const std::string &name) const noexcept
MUST_USE_RESULT TensorShapeVector GetAttrsOrDefault(const std::string &name, const TensorShapeVector &default_value=TensorShapeVector{}) const
uint32_t GetInputCount() const
OpNodeProtoHelper(const Impl_t *impl)
uint32_t GetOutputCount() const
MUST_USE_RESULT Status GetAttrsStringRefs(const std::string &name, std::vector< std::reference_wrapper< const std::string >> &refs) const
const ONNX_NAMESPACE::TypeProto * getInputType(size_t index) const
MUST_USE_RESULT Status GetAttr(const std::string &name, T *value) const
absl::InlinedVector< int64_t, kTensorShapeSmallBufferElementsSize > TensorShapeVector
size_t getNumOutputs() const
const ONNX_NAMESPACE::TypeProto * GetInputType(size_t index) const
GLuint const GLchar * name
MUST_USE_RESULT Status GetAttrsAsSpan(const std::string &name, gsl::span< const T > &values) const
Return a gsl::span that points to an array of primitive types held by AttributeProto This function al...
MUST_USE_RESULT std::vector< T > GetAttrsOrDefault(const std::string &name, const std::vector< T > &default_value=std::vector< T >{}) const
const ONNX_NAMESPACE::AttributeProto * GetAttribute(const std::string &name) const
GLenum GLsizei GLsizei GLint * values
const ONNX_NAMESPACE::TypeProto * GetOutputType(size_t index) const
const ONNX_NAMESPACE::TypeProto * getOutputType(size_t index) const
const ONNX_NAMESPACE::AttributeProto * getAttribute(const std::string &name) const
size_t getNumInputs() const