ir

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotYetImplemented ...
	ErrNotYetImplemented = errors.New("Not Yet Implemented")
	// ErrNoDataFound ...
	ErrNoDataFound = errors.New("No data found")
	// ErrCorruptedData ...
	ErrCorruptedData = errors.New("Unable to decode data")
)
View Source
var AttributeProto_AttributeType_name = map[int32]string{
	0:  "UNDEFINED",
	1:  "FLOAT",
	2:  "INT",
	3:  "STRING",
	4:  "TENSOR",
	5:  "GRAPH",
	6:  "FLOATS",
	7:  "INTS",
	8:  "STRINGS",
	9:  "TENSORS",
	10: "GRAPHS",
}
View Source
var AttributeProto_AttributeType_value = map[string]int32{
	"UNDEFINED": 0,
	"FLOAT":     1,
	"INT":       2,
	"STRING":    3,
	"TENSOR":    4,
	"GRAPH":     5,
	"FLOATS":    6,
	"INTS":      7,
	"STRINGS":   8,
	"TENSORS":   9,
	"GRAPHS":    10,
}
View Source
var TensorProto_DataType_name = map[int32]string{
	0:  "UNDEFINED",
	1:  "FLOAT",
	2:  "UINT8",
	3:  "INT8",
	4:  "UINT16",
	5:  "INT16",
	6:  "INT32",
	7:  "INT64",
	8:  "STRING",
	9:  "BOOL",
	10: "FLOAT16",
	11: "DOUBLE",
	12: "UINT32",
	13: "UINT64",
	14: "COMPLEX64",
	15: "COMPLEX128",
	16: "BFLOAT16",
}
View Source
var TensorProto_DataType_value = map[string]int32{
	"UNDEFINED":  0,
	"FLOAT":      1,
	"UINT8":      2,
	"INT8":       3,
	"UINT16":     4,
	"INT16":      5,
	"INT32":      6,
	"INT64":      7,
	"STRING":     8,
	"BOOL":       9,
	"FLOAT16":    10,
	"DOUBLE":     11,
	"UINT32":     12,
	"UINT64":     13,
	"COMPLEX64":  14,
	"COMPLEX128": 15,
	"BFLOAT16":   16,
}
View Source
var Version_name = map[int32]string{
	0: "_START_VERSION",
	1: "IR_VERSION_2017_10_10",
	2: "IR_VERSION_2017_10_30",
	3: "IR_VERSION",
}
View Source
var Version_value = map[string]int32{
	"_START_VERSION":        0,
	"IR_VERSION_2017_10_10": 1,
	"IR_VERSION_2017_10_30": 2,
	"IR_VERSION":            3,
}

Functions

This section is empty.

Types

type AttributeProto

type AttributeProto struct {
	// The name field MUST be present for this version of the IR.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// if ref_attr_name is not empty, ref_attr_name is the attribute name in parent function.
	// In this case, this AttributeProto does not contain data, and it's a reference of attribute
	// in parent scope.
	// NOTE: This should ONLY be used in function (sub-graph). It's invalid to be used in main graph.
	RefAttrName string `protobuf:"bytes,21,opt,name=ref_attr_name,json=refAttrName,proto3" json:"ref_attr_name,omitempty"`
	// A human-readable documentation for this attribute. Markdown is allowed.
	DocString string `protobuf:"bytes,13,opt,name=doc_string,json=docString,proto3" json:"doc_string,omitempty"`
	// The type field MUST be present for this version of the IR.
	// For 0.0.1 versions of the IR, this field was not defined, and
	// implementations needed to use has_field hueristics to determine
	// which value field was in use.  For IR_VERSION 0.0.2 or later, this
	// field MUST be set and match the f|i|s|t|... field in use.  This
	// change was made to accomodate proto3 implementations.
	Type AttributeProto_AttributeType `protobuf:"varint,20,opt,name=type,proto3,enum=onnx.AttributeProto_AttributeType" json:"type,omitempty"`
	// Exactly ONE of the following fields must be present for this version of the IR
	F                    float32        `protobuf:"fixed32,2,opt,name=f,proto3" json:"f,omitempty"`
	I                    int64          `protobuf:"varint,3,opt,name=i,proto3" json:"i,omitempty"`
	S                    []byte         `protobuf:"bytes,4,opt,name=s,proto3" json:"s,omitempty"`
	T                    *TensorProto   `protobuf:"bytes,5,opt,name=t,proto3" json:"t,omitempty"`
	G                    *GraphProto    `protobuf:"bytes,6,opt,name=g,proto3" json:"g,omitempty"`
	Floats               []float32      `protobuf:"fixed32,7,rep,packed,name=floats,proto3" json:"floats,omitempty"`
	Ints                 []int64        `protobuf:"varint,8,rep,packed,name=ints,proto3" json:"ints,omitempty"`
	Strings              [][]byte       `protobuf:"bytes,9,rep,name=strings,proto3" json:"strings,omitempty"`
	Tensors              []*TensorProto `protobuf:"bytes,10,rep,name=tensors,proto3" json:"tensors,omitempty"`
	Graphs               []*GraphProto  `protobuf:"bytes,11,rep,name=graphs,proto3" json:"graphs,omitempty"`
	XXX_NoUnkeyedLiteral struct{}       `json:"-"`
	XXX_unrecognized     []byte         `json:"-"`
	XXX_sizecache        int32          `json:"-"`
}

Attributes

A named attribute containing either singular float, integer, string, graph, and tensor values, or repeated float, integer, string, graph, and tensor values. An AttributeProto MUST contain the name field, and *only one* of the following content fields, effectively enforcing a C/C++ union equivalent.

func (*AttributeProto) Descriptor

func (*AttributeProto) Descriptor() ([]byte, []int)

func (*AttributeProto) GetDocString

func (m *AttributeProto) GetDocString() string

func (*AttributeProto) GetF

func (m *AttributeProto) GetF() float32

func (*AttributeProto) GetFloats

func (m *AttributeProto) GetFloats() []float32

func (*AttributeProto) GetG

func (m *AttributeProto) GetG() *GraphProto

func (*AttributeProto) GetGraphs

func (m *AttributeProto) GetGraphs() []*GraphProto

func (*AttributeProto) GetI

func (m *AttributeProto) GetI() int64

func (*AttributeProto) GetInts

func (m *AttributeProto) GetInts() []int64

func (*AttributeProto) GetName

func (m *AttributeProto) GetName() string

func (*AttributeProto) GetRefAttrName

func (m *AttributeProto) GetRefAttrName() string

func (*AttributeProto) GetS

func (m *AttributeProto) GetS() []byte

func (*AttributeProto) GetStrings

func (m *AttributeProto) GetStrings() [][]byte

func (*AttributeProto) GetT

func (m *AttributeProto) GetT() *TensorProto

func (*AttributeProto) GetTensors

func (m *AttributeProto) GetTensors() []*TensorProto

func (*AttributeProto) GetType

func (*AttributeProto) ProtoMessage

func (*AttributeProto) ProtoMessage()

func (*AttributeProto) Reset

func (m *AttributeProto) Reset()

func (*AttributeProto) String

func (m *AttributeProto) String() string

func (*AttributeProto) XXX_DiscardUnknown

func (m *AttributeProto) XXX_DiscardUnknown()

func (*AttributeProto) XXX_Marshal

func (m *AttributeProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AttributeProto) XXX_Merge

func (m *AttributeProto) XXX_Merge(src proto.Message)

func (*AttributeProto) XXX_Size

func (m *AttributeProto) XXX_Size() int

func (*AttributeProto) XXX_Unmarshal

func (m *AttributeProto) XXX_Unmarshal(b []byte) error

type AttributeProto_AttributeType

type AttributeProto_AttributeType int32

Note: this enum is structurally identical to the OpSchema::AttrType enum defined in schema.h. If you rev one, you likely need to rev the other.

const (
	AttributeProto_UNDEFINED AttributeProto_AttributeType = 0
	AttributeProto_FLOAT     AttributeProto_AttributeType = 1
	AttributeProto_INT       AttributeProto_AttributeType = 2
	AttributeProto_STRING    AttributeProto_AttributeType = 3
	AttributeProto_TENSOR    AttributeProto_AttributeType = 4
	AttributeProto_GRAPH     AttributeProto_AttributeType = 5
	AttributeProto_FLOATS    AttributeProto_AttributeType = 6
	AttributeProto_INTS      AttributeProto_AttributeType = 7
	AttributeProto_STRINGS   AttributeProto_AttributeType = 8
	AttributeProto_TENSORS   AttributeProto_AttributeType = 9
	AttributeProto_GRAPHS    AttributeProto_AttributeType = 10
)

func (AttributeProto_AttributeType) EnumDescriptor

func (AttributeProto_AttributeType) EnumDescriptor() ([]byte, []int)

func (AttributeProto_AttributeType) String

type ErrNotImplemented

type ErrNotImplemented struct {
	Operator       string
	AttributeName  string
	AttributeValue interface{}
	Message        string
}

ErrNotImplemented is returned for any operator or attribute

func (*ErrNotImplemented) Error

func (e *ErrNotImplemented) Error() string

type GraphProto

type GraphProto struct {
	// The nodes in the graph, sorted topologically.
	Node []*NodeProto `protobuf:"bytes,1,rep,name=node,proto3" json:"node,omitempty"`
	// The name of the graph.
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// A list of named tensor values, used to specify constant inputs of the graph.
	// Each TensorProto entry must have a distinct name (within the list) that
	// also appears in the input list.
	Initializer []*TensorProto `protobuf:"bytes,5,rep,name=initializer,proto3" json:"initializer,omitempty"`
	// A human-readable documentation for this graph. Markdown is allowed.
	DocString string `protobuf:"bytes,10,opt,name=doc_string,json=docString,proto3" json:"doc_string,omitempty"`
	// The inputs and outputs of the graph.
	Input  []*ValueInfoProto `protobuf:"bytes,11,rep,name=input,proto3" json:"input,omitempty"`
	Output []*ValueInfoProto `protobuf:"bytes,12,rep,name=output,proto3" json:"output,omitempty"`
	// Information for the values in the graph. The ValueInfoProto.name's
	// must be distinct. It is optional for a value to appear in value_info list.
	ValueInfo            []*ValueInfoProto `protobuf:"bytes,13,rep,name=value_info,json=valueInfo,proto3" json:"value_info,omitempty"`
	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
	XXX_unrecognized     []byte            `json:"-"`
	XXX_sizecache        int32             `json:"-"`
}

Graphs

A graph defines the computational logic of a model and is comprised of a parameterized list of nodes that form a directed acyclic graph based on their inputs and outputs. This is the equivalent of the "network" or "graph" in many deep learning frameworks.

func (*GraphProto) Descriptor

func (*GraphProto) Descriptor() ([]byte, []int)

func (*GraphProto) GetDocString

func (m *GraphProto) GetDocString() string

func (*GraphProto) GetInitializer

func (m *GraphProto) GetInitializer() []*TensorProto

func (*GraphProto) GetInput

func (m *GraphProto) GetInput() []*ValueInfoProto

func (*GraphProto) GetName

func (m *GraphProto) GetName() string

func (*GraphProto) GetNode

func (m *GraphProto) GetNode() []*NodeProto

func (*GraphProto) GetOutput

func (m *GraphProto) GetOutput() []*ValueInfoProto

func (*GraphProto) GetValueInfo

func (m *GraphProto) GetValueInfo() []*ValueInfoProto

func (*GraphProto) ProtoMessage

func (*GraphProto) ProtoMessage()

func (*GraphProto) Reset

func (m *GraphProto) Reset()

func (*GraphProto) String

func (m *GraphProto) String() string

func (*GraphProto) XXX_DiscardUnknown

func (m *GraphProto) XXX_DiscardUnknown()

func (*GraphProto) XXX_Marshal

func (m *GraphProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GraphProto) XXX_Merge

func (m *GraphProto) XXX_Merge(src proto.Message)

func (*GraphProto) XXX_Size

func (m *GraphProto) XXX_Size() int

func (*GraphProto) XXX_Unmarshal

func (m *GraphProto) XXX_Unmarshal(b []byte) error

type ModelProto

type ModelProto struct {
	// The version of the IR this model targets. See Version enum above.
	// This field MUST be present.
	IrVersion int64 `protobuf:"varint,1,opt,name=ir_version,json=irVersion,proto3" json:"ir_version,omitempty"`
	// The OperatorSets this model relies on.
	// All ModelProtos MUST have at least one entry that
	// specifies which version of the ONNX OperatorSet is
	// being imported.
	//
	// All nodes in the ModelProto's graph will bind against the operator
	// with the same-domain/same-op_type operator with the HIGHEST version
	// in the referenced operator sets.
	OpsetImport []*OperatorSetIdProto `protobuf:"bytes,8,rep,name=opset_import,json=opsetImport,proto3" json:"opset_import,omitempty"`
	// The name of the framework or tool used to generate this model.
	// This field SHOULD be present to indicate which implementation/tool/framework
	// emitted the model.
	ProducerName string `protobuf:"bytes,2,opt,name=producer_name,json=producerName,proto3" json:"producer_name,omitempty"`
	// The version of the framework or tool used to generate this model.
	// This field SHOULD be present to indicate which implementation/tool/framework
	// emitted the model.
	ProducerVersion string `protobuf:"bytes,3,opt,name=producer_version,json=producerVersion,proto3" json:"producer_version,omitempty"`
	// Domain name of the model.
	// We use reverse domain names as name space indicators. For example:
	// `com.facebook.fair` or `com.microsoft.cognitiveservices`
	//
	// Together with `model_version` and GraphProto.name, this forms the unique identity of
	// the graph.
	Domain string `protobuf:"bytes,4,opt,name=domain,proto3" json:"domain,omitempty"`
	// The version of the graph encoded. See Version enum below.
	ModelVersion int64 `protobuf:"varint,5,opt,name=model_version,json=modelVersion,proto3" json:"model_version,omitempty"`
	// A human-readable documentation for this model. Markdown is allowed.
	DocString string `protobuf:"bytes,6,opt,name=doc_string,json=docString,proto3" json:"doc_string,omitempty"`
	// The parameterized graph that is evaluated to execute the model.
	Graph *GraphProto `protobuf:"bytes,7,opt,name=graph,proto3" json:"graph,omitempty"`
	// Named metadata values; keys should be distinct.
	MetadataProps        []*StringStringEntryProto `protobuf:"bytes,14,rep,name=metadata_props,json=metadataProps,proto3" json:"metadata_props,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                  `json:"-"`
	XXX_unrecognized     []byte                    `json:"-"`
	XXX_sizecache        int32                     `json:"-"`
}

Models

ModelProto is a top-level file/container format for bundling a ML model and associating its computation graph with metadata.

The semantics of the model are described by the associated GraphProto.

func (*ModelProto) Descriptor

func (*ModelProto) Descriptor() ([]byte, []int)

func (*ModelProto) GetDocString

func (m *ModelProto) GetDocString() string

func (*ModelProto) GetDomain

func (m *ModelProto) GetDomain() string

func (*ModelProto) GetGraph

func (m *ModelProto) GetGraph() *GraphProto

func (*ModelProto) GetIrVersion

func (m *ModelProto) GetIrVersion() int64

func (*ModelProto) GetMetadataProps

func (m *ModelProto) GetMetadataProps() []*StringStringEntryProto

func (*ModelProto) GetModelVersion

func (m *ModelProto) GetModelVersion() int64

func (*ModelProto) GetOpsetImport

func (m *ModelProto) GetOpsetImport() []*OperatorSetIdProto

func (*ModelProto) GetProducerName

func (m *ModelProto) GetProducerName() string

func (*ModelProto) GetProducerVersion

func (m *ModelProto) GetProducerVersion() string

func (*ModelProto) ProtoMessage

func (*ModelProto) ProtoMessage()

func (*ModelProto) Reset

func (m *ModelProto) Reset()

func (*ModelProto) String

func (m *ModelProto) String() string

func (*ModelProto) XXX_DiscardUnknown

func (m *ModelProto) XXX_DiscardUnknown()

func (*ModelProto) XXX_Marshal

func (m *ModelProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ModelProto) XXX_Merge

func (m *ModelProto) XXX_Merge(src proto.Message)

func (*ModelProto) XXX_Size

func (m *ModelProto) XXX_Size() int

func (*ModelProto) XXX_Unmarshal

func (m *ModelProto) XXX_Unmarshal(b []byte) error

type NodeProto

type NodeProto struct {
	Input  []string `protobuf:"bytes,1,rep,name=input,proto3" json:"input,omitempty"`
	Output []string `protobuf:"bytes,2,rep,name=output,proto3" json:"output,omitempty"`
	// An optional identifier for this node in a graph.
	// This field MAY be absent in ths version of the IR.
	Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
	// The symbolic identifier of the Operator to execute.
	OpType string `protobuf:"bytes,4,opt,name=op_type,json=opType,proto3" json:"op_type,omitempty"`
	// The domain of the OperatorSet that specifies the operator named by op_type.
	Domain string `protobuf:"bytes,7,opt,name=domain,proto3" json:"domain,omitempty"`
	// Additional named attributes.
	Attribute []*AttributeProto `protobuf:"bytes,5,rep,name=attribute,proto3" json:"attribute,omitempty"`
	// A human-readable documentation for this node. Markdown is allowed.
	DocString            string   `protobuf:"bytes,6,opt,name=doc_string,json=docString,proto3" json:"doc_string,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Nodes

Computation graphs are made up of a DAG of nodes, which represent what is commonly called a "layer" or "pipeline stage" in machine learning frameworks.

For example, it can be a node of type "Conv" that takes in an image, a filter tensor and a bias tensor, and produces the convolved output.

func (*NodeProto) Descriptor

func (*NodeProto) Descriptor() ([]byte, []int)

func (*NodeProto) GetAttribute

func (m *NodeProto) GetAttribute() []*AttributeProto

func (*NodeProto) GetDocString

func (m *NodeProto) GetDocString() string

func (*NodeProto) GetDomain

func (m *NodeProto) GetDomain() string

func (*NodeProto) GetInput

func (m *NodeProto) GetInput() []string

func (*NodeProto) GetName

func (m *NodeProto) GetName() string

func (*NodeProto) GetOpType

func (m *NodeProto) GetOpType() string

func (*NodeProto) GetOutput

func (m *NodeProto) GetOutput() []string

func (*NodeProto) ProtoMessage

func (*NodeProto) ProtoMessage()

func (*NodeProto) Reset

func (m *NodeProto) Reset()

func (*NodeProto) String

func (m *NodeProto) String() string

func (*NodeProto) XXX_DiscardUnknown

func (m *NodeProto) XXX_DiscardUnknown()

func (*NodeProto) XXX_Marshal

func (m *NodeProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*NodeProto) XXX_Merge

func (m *NodeProto) XXX_Merge(src proto.Message)

func (*NodeProto) XXX_Size

func (m *NodeProto) XXX_Size() int

func (*NodeProto) XXX_Unmarshal

func (m *NodeProto) XXX_Unmarshal(b []byte) error

type OperatorSetIdProto

type OperatorSetIdProto struct {
	// The domain of the operator set being identified.
	// The empty string ("") or absence of this field implies the operator
	// set that is defined as part of the ONNX specification.
	// This field MUST be present in this version of the IR when referring to any other operator set.
	Domain string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"`
	// The version of the operator set being identified.
	// This field MUST be present in this version of the IR.
	Version              int64    `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Operator Sets

OperatorSets are uniquely identified by a (domain, opset_version) pair.

func (*OperatorSetIdProto) Descriptor

func (*OperatorSetIdProto) Descriptor() ([]byte, []int)

func (*OperatorSetIdProto) GetDomain

func (m *OperatorSetIdProto) GetDomain() string

func (*OperatorSetIdProto) GetVersion

func (m *OperatorSetIdProto) GetVersion() int64

func (*OperatorSetIdProto) ProtoMessage

func (*OperatorSetIdProto) ProtoMessage()

func (*OperatorSetIdProto) Reset

func (m *OperatorSetIdProto) Reset()

func (*OperatorSetIdProto) String

func (m *OperatorSetIdProto) String() string

func (*OperatorSetIdProto) XXX_DiscardUnknown

func (m *OperatorSetIdProto) XXX_DiscardUnknown()

func (*OperatorSetIdProto) XXX_Marshal

func (m *OperatorSetIdProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*OperatorSetIdProto) XXX_Merge

func (m *OperatorSetIdProto) XXX_Merge(src proto.Message)

func (*OperatorSetIdProto) XXX_Size

func (m *OperatorSetIdProto) XXX_Size() int

func (*OperatorSetIdProto) XXX_Unmarshal

func (m *OperatorSetIdProto) XXX_Unmarshal(b []byte) error

type StringStringEntryProto

type StringStringEntryProto struct {
	Key                  string   `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Value                string   `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

StringStringEntryProto follows the pattern for cross-proto-version maps. See https://developers.google.com/protocol-buffers/docs/proto3#maps

func (*StringStringEntryProto) Descriptor

func (*StringStringEntryProto) Descriptor() ([]byte, []int)

func (*StringStringEntryProto) GetKey

func (m *StringStringEntryProto) GetKey() string

func (*StringStringEntryProto) GetValue

func (m *StringStringEntryProto) GetValue() string

func (*StringStringEntryProto) ProtoMessage

func (*StringStringEntryProto) ProtoMessage()

func (*StringStringEntryProto) Reset

func (m *StringStringEntryProto) Reset()

func (*StringStringEntryProto) String

func (m *StringStringEntryProto) String() string

func (*StringStringEntryProto) XXX_DiscardUnknown

func (m *StringStringEntryProto) XXX_DiscardUnknown()

func (*StringStringEntryProto) XXX_Marshal

func (m *StringStringEntryProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*StringStringEntryProto) XXX_Merge

func (m *StringStringEntryProto) XXX_Merge(src proto.Message)

func (*StringStringEntryProto) XXX_Size

func (m *StringStringEntryProto) XXX_Size() int

func (*StringStringEntryProto) XXX_Unmarshal

func (m *StringStringEntryProto) XXX_Unmarshal(b []byte) error

type TensorProto

type TensorProto struct {
	// The shape of the tensor.
	Dims []int64 `protobuf:"varint,1,rep,packed,name=dims,proto3" json:"dims,omitempty"`
	// The data type of the tensor.
	// This field MUST have a valid TensorProto.DataType value
	DataType int32                `protobuf:"varint,2,opt,name=data_type,json=dataType,proto3" json:"data_type,omitempty"`
	Segment  *TensorProto_Segment `protobuf:"bytes,3,opt,name=segment,proto3" json:"segment,omitempty"`
	// For float and complex64 values
	// Complex64 tensors are encoded as a single array of floats,
	// with the real components appearing in odd numbered positions,
	// and the corresponding imaginary component apparing in the
	// subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
	// is encoded as [1.0, 2.0 ,3.0 ,4.0]
	// When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
	FloatData []float32 `protobuf:"fixed32,4,rep,packed,name=float_data,json=floatData,proto3" json:"float_data,omitempty"`
	// For int32, uint8, int8, uint16, int16, bool, and float16 values
	// float16 values must be bit-wise converted to an uint16_t prior
	// to writing to the buffer.
	// When this field is present, the data_type field MUST be
	// INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
	Int32Data []int32 `protobuf:"varint,5,rep,packed,name=int32_data,json=int32Data,proto3" json:"int32_data,omitempty"`
	// For strings.
	// Each element of string_data is a UTF-8 encoded Unicode
	// string. No trailing null, no leading BOM. The protobuf "string"
	// scalar type is not used to match ML community conventions.
	// When this field is present, the data_type field MUST be STRING
	StringData [][]byte `protobuf:"bytes,6,rep,name=string_data,json=stringData,proto3" json:"string_data,omitempty"`
	// For int64.
	// When this field is present, the data_type field MUST be INT64
	Int64Data []int64 `protobuf:"varint,7,rep,packed,name=int64_data,json=int64Data,proto3" json:"int64_data,omitempty"`
	// Optionally, a name for the tensor.
	Name string `protobuf:"bytes,8,opt,name=name,proto3" json:"name,omitempty"`
	// A human-readable documentation for this tensor. Markdown is allowed.
	DocString string `protobuf:"bytes,12,opt,name=doc_string,json=docString,proto3" json:"doc_string,omitempty"`
	// Serializations can either use one of the fields above, or use this
	// raw bytes field. The only exception is the string case, where one is
	// required to store the content in the repeated bytes string_data field.
	//
	// When this raw_data field is used to store tensor value, elements MUST
	// be stored in as fixed-width, little-endian order.
	// Floating-point data types MUST be stored in IEEE 754 format.
	// Complex64 elements must be written as two consecutive FLOAT values, real component first.
	// Complex128 elements must be written as two consecutive DOUBLE values, real component first.
	// Boolean type MUST be written one byte per tensor element (00000001 for true, 00000000 for false).
	//
	// Note: the advantage of specific field rather than the raw_data field is
	// that in some cases (e.g. int data), protobuf does a better packing via
	// variable length storage, and may lead to smaller binary footprint.
	// When this field is present, the data_type field MUST NOT be STRING or UNDEFINED
	RawData []byte `protobuf:"bytes,9,opt,name=raw_data,json=rawData,proto3" json:"raw_data,omitempty"`
	// For double
	// Complex128 tensors are encoded as a single array of doubles,
	// with the real components appearing in odd numbered positions,
	// and the corresponding imaginary component apparing in the
	// subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
	// is encoded as [1.0, 2.0 ,3.0 ,4.0]
	// When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
	DoubleData []float64 `protobuf:"fixed64,10,rep,packed,name=double_data,json=doubleData,proto3" json:"double_data,omitempty"`
	// For uint64 and uint32 values
	// When this field is present, the data_type field MUST be
	// UINT32 or UINT64
	Uint64Data           []uint64 `protobuf:"varint,11,rep,packed,name=uint64_data,json=uint64Data,proto3" json:"uint64_data,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Tensors

A serialized tensor value.

func (*TensorProto) Descriptor

func (*TensorProto) Descriptor() ([]byte, []int)

func (*TensorProto) GetDataType

func (m *TensorProto) GetDataType() int32

func (*TensorProto) GetDims

func (m *TensorProto) GetDims() []int64

func (*TensorProto) GetDocString

func (m *TensorProto) GetDocString() string

func (*TensorProto) GetDoubleData

func (m *TensorProto) GetDoubleData() []float64

func (*TensorProto) GetFloatData

func (m *TensorProto) GetFloatData() []float32

func (*TensorProto) GetInt32Data

func (m *TensorProto) GetInt32Data() []int32

func (*TensorProto) GetInt64Data

func (m *TensorProto) GetInt64Data() []int64

func (*TensorProto) GetName

func (m *TensorProto) GetName() string

func (*TensorProto) GetRawData

func (m *TensorProto) GetRawData() []byte

func (*TensorProto) GetSegment

func (m *TensorProto) GetSegment() *TensorProto_Segment

func (*TensorProto) GetStringData

func (m *TensorProto) GetStringData() [][]byte

func (*TensorProto) GetUint64Data

func (m *TensorProto) GetUint64Data() []uint64

func (*TensorProto) ProtoMessage

func (*TensorProto) ProtoMessage()

func (*TensorProto) Reset

func (m *TensorProto) Reset()

func (*TensorProto) String

func (m *TensorProto) String() string

func (*TensorProto) Tensor

func (tx *TensorProto) Tensor() (tensor.Tensor, error)

Tensor returns a Gorgonia compatible tensor

func (*TensorProto) XXX_DiscardUnknown

func (m *TensorProto) XXX_DiscardUnknown()

func (*TensorProto) XXX_Marshal

func (m *TensorProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TensorProto) XXX_Merge

func (m *TensorProto) XXX_Merge(src proto.Message)

func (*TensorProto) XXX_Size

func (m *TensorProto) XXX_Size() int

func (*TensorProto) XXX_Unmarshal

func (m *TensorProto) XXX_Unmarshal(b []byte) error

type TensorProto_DataType

type TensorProto_DataType int32
const (
	TensorProto_UNDEFINED TensorProto_DataType = 0
	// Basic types.
	TensorProto_FLOAT  TensorProto_DataType = 1
	TensorProto_UINT8  TensorProto_DataType = 2
	TensorProto_INT8   TensorProto_DataType = 3
	TensorProto_UINT16 TensorProto_DataType = 4
	TensorProto_INT16  TensorProto_DataType = 5
	TensorProto_INT32  TensorProto_DataType = 6
	TensorProto_INT64  TensorProto_DataType = 7
	TensorProto_STRING TensorProto_DataType = 8
	TensorProto_BOOL   TensorProto_DataType = 9
	// IEEE754 half-precision floating-point format (16 bits wide).
	// This format has 1 sign bit, 5 exponent bits, and 10 mantissa bits.
	TensorProto_FLOAT16    TensorProto_DataType = 10
	TensorProto_DOUBLE     TensorProto_DataType = 11
	TensorProto_UINT32     TensorProto_DataType = 12
	TensorProto_UINT64     TensorProto_DataType = 13
	TensorProto_COMPLEX64  TensorProto_DataType = 14
	TensorProto_COMPLEX128 TensorProto_DataType = 15
	// Non-IEEE floating-point format based on IEEE754 single-precision
	// floating-point number truncated to 16 bits.
	// This format has 1 sign bit, 8 exponent bits, and 7 mantissa bits.
	TensorProto_BFLOAT16 TensorProto_DataType = 16
)

func (TensorProto_DataType) Dtype

func (t TensorProto_DataType) Dtype() (tensor.Dtype, error)

Dtype returns a compatible dtype from the source

func (TensorProto_DataType) EnumDescriptor

func (TensorProto_DataType) EnumDescriptor() ([]byte, []int)

func (TensorProto_DataType) String

func (x TensorProto_DataType) String() string

type TensorProto_Segment

type TensorProto_Segment struct {
	Begin                int64    `protobuf:"varint,1,opt,name=begin,proto3" json:"begin,omitempty"`
	End                  int64    `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

For very large tensors, we may want to store them in chunks, in which case the following fields will specify the segment that is stored in the current TensorProto.

func (*TensorProto_Segment) Descriptor

func (*TensorProto_Segment) Descriptor() ([]byte, []int)

func (*TensorProto_Segment) GetBegin

func (m *TensorProto_Segment) GetBegin() int64

func (*TensorProto_Segment) GetEnd

func (m *TensorProto_Segment) GetEnd() int64

func (*TensorProto_Segment) ProtoMessage

func (*TensorProto_Segment) ProtoMessage()

func (*TensorProto_Segment) Reset

func (m *TensorProto_Segment) Reset()

func (*TensorProto_Segment) String

func (m *TensorProto_Segment) String() string

func (*TensorProto_Segment) XXX_DiscardUnknown

func (m *TensorProto_Segment) XXX_DiscardUnknown()

func (*TensorProto_Segment) XXX_Marshal

func (m *TensorProto_Segment) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TensorProto_Segment) XXX_Merge

func (m *TensorProto_Segment) XXX_Merge(src proto.Message)

func (*TensorProto_Segment) XXX_Size

func (m *TensorProto_Segment) XXX_Size() int

func (*TensorProto_Segment) XXX_Unmarshal

func (m *TensorProto_Segment) XXX_Unmarshal(b []byte) error

type TensorShapeProto

type TensorShapeProto struct {
	Dim                  []*TensorShapeProto_Dimension `protobuf:"bytes,1,rep,name=dim,proto3" json:"dim,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                      `json:"-"`
	XXX_unrecognized     []byte                        `json:"-"`
	XXX_sizecache        int32                         `json:"-"`
}

Defines a tensor shape. A dimension can be either an integer value or a symbolic variable. A symbolic variable represents an unknown dimension.

func (*TensorShapeProto) Descriptor

func (*TensorShapeProto) Descriptor() ([]byte, []int)

func (*TensorShapeProto) GetDim

func (*TensorShapeProto) ProtoMessage

func (*TensorShapeProto) ProtoMessage()

func (*TensorShapeProto) Reset

func (m *TensorShapeProto) Reset()

func (*TensorShapeProto) String

func (m *TensorShapeProto) String() string

func (*TensorShapeProto) XXX_DiscardUnknown

func (m *TensorShapeProto) XXX_DiscardUnknown()

func (*TensorShapeProto) XXX_Marshal

func (m *TensorShapeProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TensorShapeProto) XXX_Merge

func (m *TensorShapeProto) XXX_Merge(src proto.Message)

func (*TensorShapeProto) XXX_Size

func (m *TensorShapeProto) XXX_Size() int

func (*TensorShapeProto) XXX_Unmarshal

func (m *TensorShapeProto) XXX_Unmarshal(b []byte) error

type TensorShapeProto_Dimension

type TensorShapeProto_Dimension struct {
	// Types that are valid to be assigned to Value:
	//	*TensorShapeProto_Dimension_DimValue
	//	*TensorShapeProto_Dimension_DimParam
	Value isTensorShapeProto_Dimension_Value `protobuf_oneof:"value"`
	// Standard denotation can optionally be used to denote tensor
	// dimensions with standard semantic descriptions to ensure
	// that operations are applied to the correct axis of a tensor.
	// Refer to https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
	// for pre-defined dimension denotations.
	Denotation           string   `protobuf:"bytes,3,opt,name=denotation,proto3" json:"denotation,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*TensorShapeProto_Dimension) Descriptor

func (*TensorShapeProto_Dimension) Descriptor() ([]byte, []int)

func (*TensorShapeProto_Dimension) GetDenotation

func (m *TensorShapeProto_Dimension) GetDenotation() string

func (*TensorShapeProto_Dimension) GetDimParam

func (m *TensorShapeProto_Dimension) GetDimParam() string

func (*TensorShapeProto_Dimension) GetDimValue

func (m *TensorShapeProto_Dimension) GetDimValue() int64

func (*TensorShapeProto_Dimension) GetValue

func (m *TensorShapeProto_Dimension) GetValue() isTensorShapeProto_Dimension_Value

func (*TensorShapeProto_Dimension) ProtoMessage

func (*TensorShapeProto_Dimension) ProtoMessage()

func (*TensorShapeProto_Dimension) Reset

func (m *TensorShapeProto_Dimension) Reset()

func (*TensorShapeProto_Dimension) String

func (m *TensorShapeProto_Dimension) String() string

func (*TensorShapeProto_Dimension) XXX_DiscardUnknown

func (m *TensorShapeProto_Dimension) XXX_DiscardUnknown()

func (*TensorShapeProto_Dimension) XXX_Marshal

func (m *TensorShapeProto_Dimension) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TensorShapeProto_Dimension) XXX_Merge

func (m *TensorShapeProto_Dimension) XXX_Merge(src proto.Message)

func (*TensorShapeProto_Dimension) XXX_OneofWrappers

func (*TensorShapeProto_Dimension) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*TensorShapeProto_Dimension) XXX_Size

func (m *TensorShapeProto_Dimension) XXX_Size() int

func (*TensorShapeProto_Dimension) XXX_Unmarshal

func (m *TensorShapeProto_Dimension) XXX_Unmarshal(b []byte) error

type TensorShapeProto_Dimension_DimParam

type TensorShapeProto_Dimension_DimParam struct {
	DimParam string `protobuf:"bytes,2,opt,name=dim_param,json=dimParam,proto3,oneof"`
}

type TensorShapeProto_Dimension_DimValue

type TensorShapeProto_Dimension_DimValue struct {
	DimValue int64 `protobuf:"varint,1,opt,name=dim_value,json=dimValue,proto3,oneof"`
}

type TypeProto

type TypeProto struct {
	// Types that are valid to be assigned to Value:
	//	*TypeProto_TensorType
	Value isTypeProto_Value `protobuf_oneof:"value"`
	// An optional denotation can be used to denote the whole
	// type with a standard semantic description as to what is
	// stored inside. Refer to https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition
	// for pre-defined type denotations.
	Denotation           string   `protobuf:"bytes,6,opt,name=denotation,proto3" json:"denotation,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Types

The standard ONNX data types.

func (*TypeProto) Descriptor

func (*TypeProto) Descriptor() ([]byte, []int)

func (*TypeProto) GetDenotation

func (m *TypeProto) GetDenotation() string

func (*TypeProto) GetTensorType

func (m *TypeProto) GetTensorType() *TypeProto_Tensor

func (*TypeProto) GetValue

func (m *TypeProto) GetValue() isTypeProto_Value

func (*TypeProto) ProtoMessage

func (*TypeProto) ProtoMessage()

func (*TypeProto) Reset

func (m *TypeProto) Reset()

func (*TypeProto) String

func (m *TypeProto) String() string

func (*TypeProto) XXX_DiscardUnknown

func (m *TypeProto) XXX_DiscardUnknown()

func (*TypeProto) XXX_Marshal

func (m *TypeProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TypeProto) XXX_Merge

func (m *TypeProto) XXX_Merge(src proto.Message)

func (*TypeProto) XXX_OneofWrappers

func (*TypeProto) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*TypeProto) XXX_Size

func (m *TypeProto) XXX_Size() int

func (*TypeProto) XXX_Unmarshal

func (m *TypeProto) XXX_Unmarshal(b []byte) error

type TypeProto_Tensor

type TypeProto_Tensor struct {
	// This field MUST NOT have the value of UNDEFINED
	// This field MUST have a valid TensorProto.DataType value
	// This field MUST be present for this version of the IR.
	ElemType             int32             `protobuf:"varint,1,opt,name=elem_type,json=elemType,proto3" json:"elem_type,omitempty"`
	Shape                *TensorShapeProto `protobuf:"bytes,2,opt,name=shape,proto3" json:"shape,omitempty"`
	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
	XXX_unrecognized     []byte            `json:"-"`
	XXX_sizecache        int32             `json:"-"`
}

func (*TypeProto_Tensor) Descriptor

func (*TypeProto_Tensor) Descriptor() ([]byte, []int)

func (*TypeProto_Tensor) GetElemType

func (m *TypeProto_Tensor) GetElemType() int32

func (*TypeProto_Tensor) GetShape

func (m *TypeProto_Tensor) GetShape() *TensorShapeProto

func (*TypeProto_Tensor) ProtoMessage

func (*TypeProto_Tensor) ProtoMessage()

func (*TypeProto_Tensor) Reset

func (m *TypeProto_Tensor) Reset()

func (*TypeProto_Tensor) String

func (m *TypeProto_Tensor) String() string

func (*TypeProto_Tensor) XXX_DiscardUnknown

func (m *TypeProto_Tensor) XXX_DiscardUnknown()

func (*TypeProto_Tensor) XXX_Marshal

func (m *TypeProto_Tensor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TypeProto_Tensor) XXX_Merge

func (m *TypeProto_Tensor) XXX_Merge(src proto.Message)

func (*TypeProto_Tensor) XXX_Size

func (m *TypeProto_Tensor) XXX_Size() int

func (*TypeProto_Tensor) XXX_Unmarshal

func (m *TypeProto_Tensor) XXX_Unmarshal(b []byte) error

type TypeProto_TensorType

type TypeProto_TensorType struct {
	TensorType *TypeProto_Tensor `protobuf:"bytes,1,opt,name=tensor_type,json=tensorType,proto3,oneof"`
}

type ValueInfoProto

type ValueInfoProto struct {
	// This field MUST be present in this version of the IR.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// This field MUST be present in this version of the IR.
	Type *TypeProto `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
	// A human-readable documentation for this value. Markdown is allowed.
	DocString            string   `protobuf:"bytes,3,opt,name=doc_string,json=docString,proto3" json:"doc_string,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Defines information on value, including the name, the type, and the shape of the value.

func (*ValueInfoProto) Descriptor

func (*ValueInfoProto) Descriptor() ([]byte, []int)

func (*ValueInfoProto) GetDocString

func (m *ValueInfoProto) GetDocString() string

func (*ValueInfoProto) GetName

func (m *ValueInfoProto) GetName() string

func (*ValueInfoProto) GetType

func (m *ValueInfoProto) GetType() *TypeProto

func (*ValueInfoProto) ProtoMessage

func (*ValueInfoProto) ProtoMessage()

func (*ValueInfoProto) Reset

func (m *ValueInfoProto) Reset()

func (*ValueInfoProto) String

func (m *ValueInfoProto) String() string

func (*ValueInfoProto) XXX_DiscardUnknown

func (m *ValueInfoProto) XXX_DiscardUnknown()

func (*ValueInfoProto) XXX_Marshal

func (m *ValueInfoProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ValueInfoProto) XXX_Merge

func (m *ValueInfoProto) XXX_Merge(src proto.Message)

func (*ValueInfoProto) XXX_Size

func (m *ValueInfoProto) XXX_Size() int

func (*ValueInfoProto) XXX_Unmarshal

func (m *ValueInfoProto) XXX_Unmarshal(b []byte) error

type Version

type Version int32

Versioning

ONNX versioning is specified in docs/IR.md and elaborated on in docs/Versioning.md

To be compatible with both proto2 and proto3, we will use a version number that is not defined by the default value but an explicit enum number.

const (
	// proto3 requires the first enum value to be zero.
	// We add this just to appease the compiler.
	Version__START_VERSION Version = 0
	// The version field is always serialized and we will use it to store the
	// version that the  graph is generated from. This helps us set up version
	// control.
	// For the IR, we are using simple numbers starting with with 0x00000001,
	// which was the version we published on Oct 10, 2017.
	Version_IR_VERSION_2017_10_10 Version = 1
	// IR_VERSION 2 published on Oct 30, 2017
	// - Added type discriminator to AttributeProto to support proto3 users
	Version_IR_VERSION_2017_10_30 Version = 2
	// IR VERSION 3 published on Nov 3, 2017
	// - For operator versioning:
	//    - Added new message OperatorSetIdProto
	//    - Added opset_import in ModelProto
	// - For vendor extensions, added domain in NodeProto
	Version_IR_VERSION Version = 3
)

func (Version) EnumDescriptor

func (Version) EnumDescriptor() ([]byte, []int)

func (Version) String

func (x Version) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL