Class ONNXAttribute

java.lang.Object
org.tribuo.util.onnx.ONNXAttribute

public final class ONNXAttribute extends Object
The spec for an attribute, used to produce the attribute proto at construction time.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Value used to denote a varaidic input in an ONNX operator
  • Constructor Summary

    Constructors
    Constructor
    Description
    ONNXAttribute(String name, ai.onnx.proto.OnnxMl.AttributeProto.AttributeType type, boolean mandatory)
    Constructs an attribute placeholder of the appropriate name and type.
  • Method Summary

    Modifier and Type
    Method
    Description
    ai.onnx.proto.OnnxMl.AttributeProto
    build(Object value)
    Builds the attribute proto using the supplied value.
    Gets the attribute's name.
    ai.onnx.proto.OnnxMl.AttributeProto.AttributeType
    Gets the attribute's type.
    boolean
    Is this attribute mandatory?
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • VARIADIC_INPUT

      public static final int VARIADIC_INPUT
      Value used to denote a varaidic input in an ONNX operator
      See Also:
  • Constructor Details

    • ONNXAttribute

      public ONNXAttribute(String name, ai.onnx.proto.OnnxMl.AttributeProto.AttributeType type, boolean mandatory)
      Constructs an attribute placeholder of the appropriate name and type.
      Parameters:
      name - The name of the attribute.
      type - The type of the attribute.
      mandatory - Is this attribute mandatory?
  • Method Details

    • getName

      public String getName()
      Gets the attribute's name.
      Returns:
      The attribute's name.
    • getType

      public ai.onnx.proto.OnnxMl.AttributeProto.AttributeType getType()
      Gets the attribute's type.
      Returns:
      The attribute's type.
    • isMandatory

      public boolean isMandatory()
      Is this attribute mandatory?
      Returns:
      True if the attribute is mandatory for this operation.
    • build

      public ai.onnx.proto.OnnxMl.AttributeProto build(Object value)
      Builds the attribute proto using the supplied value.

      Throws IllegalArgumentException if the value type does not match the expected type, and throws UnsupportedOperationException if the value type is not supported. Currently supported types are primitives, strings and arrays of primitives and strings. ONNX attributes only support float and int as primitives.

      Parameters:
      value - The value
      Returns:
      The AttributeProto.
    • toString

      public String toString()
      Overrides:
      toString in class Object