GizStack
View .mdOpen in ChatGPTOpen in Claude

gizai:onnx/model

the ONNX graph types and protobuf fields.

gizlang
import * as Model from "gizai:onnx/model";

Types

Attr

gizlang
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: string
  • kind: i64
  • f: f64
  • i: i64
  • s: string
  • floats: Vec<f64>
  • ints: Vec<i64>
  • strings: Vec<string>
  • wide: bool
  • proto: bytes — A tensor attribute's TensorProto, as stored.

Node

gizlang
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: string
  • domain: string
  • inputs: Vec<string>
  • outputs: Vec<string>
  • attrs: Vec<M56.Attr>

Tensor

gizlang
type Tensor = { name: string; dims: Vec<i64>; values: Vec<f64>; }

An initializer: its name, dimensions and values.

  • name: string
  • dims: Vec<i64>
  • values: Vec<f64>

Port

gizlang
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: string
  • elem: i64
  • dims: Vec<i64>

Graph

gizlang
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

gizlang
function attr(name: string, kind: i64): Attr

An empty attribute name of AttributeType kind.

intAttr

gizlang
function intAttr(name: string, v: i64): Attr

The integer attribute name.

textAttr

gizlang
function textAttr(name: string, v: string): Attr

The string attribute name.

floatsAttr

gizlang
function floatsAttr(name: string, v: Vec<f64>): Attr

The float list attribute name.

intsAttr

gizlang
function intsAttr(name: string, v: Vec<i64>): Attr

The integer list attribute name.

textsAttr

gizlang
function textsAttr(name: string, v: Vec<string>): Attr

The string list attribute name.

node

gizlang
function node(op: string, domain: string, inputs: Vec<string>, outputs: Vec<string>, attrs: Vec<Attr>): Node

The node of operator op in domain.

key

gizlang
function key(out: mut bytes, field: i64, wire: i64): void

Writes the protobuf key of field with wire type wire.

Effects: fail.

putInt

gizlang
function putInt(out: mut bytes, field: i64, v: i64): void

Writes v as varint field field.

Effects: fail.

putBytes

gizlang
function putBytes(out: mut bytes, field: i64, b: bytes): void

Writes b as length-delimited field field.

Effects: fail.

putText

gizlang
function putText(out: mut bytes, field: i64, s: string): void

Writes s as a UTF-8 field field.

Effects: fail.

putFloats

gizlang
function putFloats(out: mut bytes, field: i64, v: Vec<f64>): void

Writes v as a packed f32 field field.

Effects: fail.

putInts

gizlang
function putInts(out: mut bytes, field: i64, v: Vec<i64>): void

Writes v as a packed varint field field.

Effects: fail.

textOf

gizlang
function textOf(w: Wire, f: Span): string

The text of the length-delimited field f.

Effects: fail.

readFloats

gizlang
function readFloats(w: Wire, f: Span, out: mut Vec<f64>): void

A repeated float (f32) field, one value or packed.

Effects: fail.

readDoubles

gizlang
function readDoubles(w: Wire, f: Span, out: mut Vec<f64>): void

A repeated double (f64) field, one value or packed.

Effects: fail.

readInts

gizlang
function readInts(w: Wire, f: Span, out: mut Vec<i64>): bool throws string

A repeated int64 field, one value or packed.

Effects: fail.

Methods

Node.find

gizlang
function Node.find(self: Node, name: string): Option<Attr>

The attribute name (or name_as_tensor), if present.

Effects: fail.

Node.floats

gizlang
function Node.floats(self: Node, name: string): Vec<f64>

The floats of attribute name, else none.

Effects: fail.

Node.ints

gizlang
function Node.ints(self: Node, name: string): Vec<i64>

The integers of attribute name, else none.

Effects: fail.

Node.texts

gizlang
function Node.texts(self: Node, name: string): Vec<string>

The strings of attribute name, else none.

Effects: fail.

Node.text

gizlang
function Node.text(self: Node, name: string, otherwise: string): string

The string of attribute name, else otherwise.

Effects: fail.

Node.int

gizlang
function Node.int(self: Node, name: string, otherwise: i64): i64

The integer of attribute name, else otherwise.

Effects: fail.

Node.wide

gizlang
function Node.wide(self: Node, name: string): bool

Whether the floats of attribute name came from an f64 tensor.

Effects: fail.

Constants

IR_VERSION

gizlang
const IR_VERSION = 8

The ONNX version that encode writes (IR version 8: ONNX 1.10 and later).

OPSET

gizlang
const OPSET = 17

The ONNX operator set version that encode writes.

ML_OPSET

gizlang
const ML_OPSET = 3

The ONNX-ML (ai.onnx.ml) operator set version that encode writes.

ML

gizlang
const ML = "ai.onnx.ml"

The ONNX-ML operator domain.

A_FLOAT

gizlang
const A_FLOAT = 1

The AttributeType of a float.

A_INT

gizlang
const A_INT = 2

The AttributeType of an integer.

A_STRING

gizlang
const A_STRING = 3

The AttributeType of a string.

A_FLOATS

gizlang
const A_FLOATS = 6

The AttributeType of a list of floats.

A_INTS

gizlang
const A_INTS = 7

The AttributeType of a list of integers.

A_STRINGS

gizlang
const A_STRINGS = 8

The AttributeType of a list of strings.

T_FLOAT

gizlang
const T_FLOAT = 1

The TensorProto data type of a 32-bit float.

T_INT64

gizlang
const T_INT64 = 7

The TensorProto data type of a 64-bit integer.

T_INT32

gizlang
const T_INT32 = 6

The TensorProto data type of a 32-bit integer.

T_DOUBLE

gizlang
const T_DOUBLE = 11

The TensorProto data type of a 64-bit float.