gizai:onnx/model
the ONNX graph types and protobuf fields.
import * as Model from "gizai:onnx/model";Types
Attr
type Attr = { name: string; kind: i64; f: f64; i: i64; s: string; floats: Vec<f64>; ints: Vec<i64>; strings: Vec<string>; wide: bool; proto: bytes; }wide: the floats came from a tensor of f64.
name:stringkind:i64f:f64i:i64s:stringfloats:Vec<f64>ints:Vec<i64>strings:Vec<string>wide:boolproto:bytes— A tensor attribute's TensorProto, as stored.
Node
type Node = { op: string; domain: string; inputs: Vec<string>; outputs: Vec<string>; attrs: Vec<Attr>; }A graph node: its operator in its domain, its input and output names and its attributes.
op:stringdomain:stringinputs:Vec<string>outputs:Vec<string>attrs:Vec<M56.Attr>
Tensor
type Tensor = { name: string; dims: Vec<i64>; values: Vec<f64>; }An initializer: its name, dimensions and values.
name:stringdims:Vec<i64>values:Vec<f64>
Port
type Port = { name: string; elem: i64; dims: Vec<i64>; }A graph input or output: its element type and dimensions (-1: the row count N).
name:stringelem:i64dims:Vec<i64>
Graph
type Graph = { nodes: Vec<Node>; initializers: Vec<Tensor>; inputs: Vec<Port>; outputs: Vec<Port>; }An ONNX graph: its nodes, initializers, inputs and outputs.
nodes:Vec<M56.Node>initializers:Vec<M56.Tensor>inputs:Vec<M56.Port>outputs:Vec<M56.Port>
Functions
attr
function attr(name: string, kind: i64): AttrAn empty attribute name of AttributeType kind.
intAttr
function intAttr(name: string, v: i64): AttrThe integer attribute name.
textAttr
function textAttr(name: string, v: string): AttrThe string attribute name.
floatsAttr
function floatsAttr(name: string, v: Vec<f64>): AttrThe float list attribute name.
intsAttr
function intsAttr(name: string, v: Vec<i64>): AttrThe integer list attribute name.
textsAttr
function textsAttr(name: string, v: Vec<string>): AttrThe string list attribute name.
node
function node(op: string, domain: string, inputs: Vec<string>, outputs: Vec<string>, attrs: Vec<Attr>): NodeThe node of operator op in domain.
key
function key(out: mut bytes, field: i64, wire: i64): voidWrites the protobuf key of field with wire type wire.
Effects: fail.
putInt
function putInt(out: mut bytes, field: i64, v: i64): voidWrites v as varint field field.
Effects: fail.
putBytes
function putBytes(out: mut bytes, field: i64, b: bytes): voidWrites b as length-delimited field field.
Effects: fail.
putText
function putText(out: mut bytes, field: i64, s: string): voidWrites s as a UTF-8 field field.
Effects: fail.
putFloats
function putFloats(out: mut bytes, field: i64, v: Vec<f64>): voidWrites v as a packed f32 field field.
Effects: fail.
putInts
function putInts(out: mut bytes, field: i64, v: Vec<i64>): voidWrites v as a packed varint field field.
Effects: fail.
textOf
function textOf(w: Wire, f: Span): stringThe text of the length-delimited field f.
Effects: fail.
readFloats
function readFloats(w: Wire, f: Span, out: mut Vec<f64>): voidA repeated float (f32) field, one value or packed.
Effects: fail.
readDoubles
function readDoubles(w: Wire, f: Span, out: mut Vec<f64>): voidA repeated double (f64) field, one value or packed.
Effects: fail.
readInts
function readInts(w: Wire, f: Span, out: mut Vec<i64>): bool throws stringA repeated int64 field, one value or packed.
Effects: fail.
Methods
Node.find
function Node.find(self: Node, name: string): Option<Attr>The attribute name (or name_as_tensor), if present.
Effects: fail.
Node.floats
function Node.floats(self: Node, name: string): Vec<f64>The floats of attribute name, else none.
Effects: fail.
Node.ints
function Node.ints(self: Node, name: string): Vec<i64>The integers of attribute name, else none.
Effects: fail.
Node.texts
function Node.texts(self: Node, name: string): Vec<string>The strings of attribute name, else none.
Effects: fail.
Node.text
function Node.text(self: Node, name: string, otherwise: string): stringThe string of attribute name, else otherwise.
Effects: fail.
Node.int
function Node.int(self: Node, name: string, otherwise: i64): i64The integer of attribute name, else otherwise.
Effects: fail.
Node.wide
function Node.wide(self: Node, name: string): boolWhether the floats of attribute name came from an f64 tensor.
Effects: fail.
Constants
IR_VERSION
const IR_VERSION = 8The ONNX version that encode writes (IR version 8: ONNX 1.10 and later).
OPSET
const OPSET = 17The ONNX operator set version that encode writes.
ML_OPSET
const ML_OPSET = 3The ONNX-ML (ai.onnx.ml) operator set version that encode writes.
ML
const ML = "ai.onnx.ml"The ONNX-ML operator domain.
A_FLOAT
const A_FLOAT = 1The AttributeType of a float.
A_INT
const A_INT = 2The AttributeType of an integer.
A_STRING
const A_STRING = 3The AttributeType of a string.
A_FLOATS
const A_FLOATS = 6The AttributeType of a list of floats.
A_INTS
const A_INTS = 7The AttributeType of a list of integers.
A_STRINGS
const A_STRINGS = 8The AttributeType of a list of strings.
T_FLOAT
const T_FLOAT = 1The TensorProto data type of a 32-bit float.
T_INT64
const T_INT64 = 7The TensorProto data type of a 64-bit integer.
T_INT32
const T_INT32 = 6The TensorProto data type of a 32-bit integer.
T_DOUBLE
const T_DOUBLE = 11The TensorProto data type of a 64-bit float.