Title here
Summary here
import type { ModelGraph, GraphNode, GraphValue, ParseWarning, AttributeValue, WeightSource } from '@wetron/common/ir';
import { ParseError } from '@wetron/common/ir';interface ModelGraph {
readonly name: string;
readonly inputs: readonly GraphValue[];
readonly outputs: readonly GraphValue[];
readonly nodes: readonly GraphNode[];
readonly initializers: ReadonlyMap<string, { shape: readonly number[]; dtype: string }>;
readonly tensorShapes: ReadonlyMap<string, { shape: readonly number[] | null; dtype: string | null }>;
readonly opsets?: ReadonlyMap<string, number>; // ONNX only - domain -> opset version ("" = ai.onnx)
readonly fileSizeBytes: number; // size of the source file - drives the >20MB weight-panel gate
readonly weights?: ModelWeights;
readonly warnings?: readonly ParseWarning[];
}weights is absent when the parser exposes no payloads. It is tagged when bytes are available or live in external files:
type ModelWeights =
| { readonly kind: 'available'; readonly source: WeightSource }
| { readonly kind: 'external'; readonly format: 'savedmodel' | 'onnx' };interface WeightSource {
readonly totalBytes: number;
get(name: string): Uint8Array | undefined;
}get(name) returns raw little-endian bytes for the named initializer, or undefined if the name is unknown. The slice is a view into the parser’s source buffer - no copy is made. Decode it with decodeWeight / decodeFirstN from @wetron/core (see
Weights).
interface GraphNode {
readonly name: string;
readonly opType: string;
readonly domain?: string; // ONNX only - absent means standard ai.onnx domain
readonly inputs: readonly string[]; // tensor names consumed
readonly outputs: readonly string[]; // tensor names produced
readonly attributes: Readonly<Record<string, AttributeValue>>;
}interface GraphValue {
readonly name: string;
readonly shape: readonly number[] | null;
readonly dtype: string | null;
}type AttributeValue = string | number | boolean | readonly number[] | readonly string[];Non-fatal issues attached to a successfully-parsed graph:
interface ParseWarning {
readonly code: string;
readonly context: string;
readonly nodeIndex?: number;
}Thrown by all parsers on unrecoverable failures:
class ParseError extends Error {
readonly format: string; // "onnx" | "tflite" | "keras" | "torchscript" | "executorch" | "savedmodel" | "unknown"
readonly context: string; // human-readable description of the failure
}@wetron/core/transform)Used internally by renderers. Import directly only when building a custom renderer:
import type { FlowNode, FlowEdge, GraphNodeData } from '@wetron/core/transform';type GraphNodeData = {
opType: string;
name: string;
inputs: readonly string[];
outputs: readonly string[];
attributes: Readonly<Record<string, AttributeValue>>;
graphNode?: GraphNode; // set for op nodes
graphValue?: GraphValue; // set for I/O nodes
shape?: readonly number[] | null;
dtype?: string | null;
weightInputs?: readonly {
slot: number;
label: string;
name: string;
shape: readonly number[];
dtype: string;
}[];
};
type FlowNode = {
id: string;
type: 'graphNode' | 'ioNode';
position: { x: number; y: number };
data: GraphNodeData;
initialWidth: number;
initialHeight: number;
};
type FlowEdge = {
id: string;
source: string;
target: string;
type: 'modelEdge';
data: {
readonly tensorName: string;
readonly sourceOpType: string;
readonly sourceNodeName: string;
readonly targetOpType: string;
readonly targetNodeName: string;
readonly points?: readonly { x: number; y: number }[];
};
};