Title here
Summary here
import type {
ModelGraph,
GraphNode,
GraphValue,
ParseWarning,
AttributeValue,
WeightSource,
} from "@wetron/core/ir";
import { ParseError } from "@wetron/core/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?: WeightSource; // present when the parser surfaces initializer bytes
readonly hasExternalWeights?: boolean; // TF2 SavedModel - true when VarHandleOp variables need a checkpoint
readonly warnings?: readonly ParseWarning[];
}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 }[];
};
};