import { OpCategory } from '@wetron/tokens'; export { OpCategory } from '@wetron/tokens'; import { AttributeValue, GraphNode, GraphValue, ModelGraph, TensorOrder } from '@wetron/common/ir'; export { AttributeValue, GraphNode, GraphValue, ModelGraph, PanelTarget, ParseError, ParseWarning, TensorOrder, WeightSource } from '@wetron/common/ir'; export { loadOnnxExternalWeightsFromUrl, parseOnnx } from '@wetron/onnx'; export { parseTflite } from '@wetron/tflite'; export { KerasModelConfig, buildKerasGraph, parseKeras, parseKerasWithWeights } from '@wetron/keras'; export { parseExecutorch } from '@wetron/executorch'; export { parseTorchscript } from '@wetron/torchscript'; export { parseGguf } from '@wetron/gguf'; export { CheckpointMeta, CheckpointVariableMeta, LoadedCheckpoint, attachCheckpointToGraph, loadSavedModelWeights, loadSavedModelWeightsFromUrls, parseCheckpointIndex, parseSavedModel } from '@wetron/savedmodel'; /** Extracts the base op name from an aten namespace op (e.g. "aten::add.int" -> "add"). * Returns null for non-aten ops. */ declare function opBase(opType: string): string | null; declare function opCategory(opType: string): OpCategory; declare function opInputLabels(opType: string): readonly string[]; type Format = 'onnx' | 'tflite' | 'keras' | 'executorch' | 'torchscript' | 'savedmodel' | 'gguf' | 'unknown'; declare function detectFormat(bytes: Uint8Array, filename?: string): Format; type NodeData = { opType: string; name: string; inputs: readonly string[]; outputs: readonly string[]; attributes: Readonly>; }; type GraphOperationNodeData = NodeData & { graphNode: GraphNode; weightInputs: readonly { slot: number; label: string; name: string; shape: readonly number[]; dtype: string; }[]; }; type IoNodeData = NodeData & { opType: 'Input' | 'Output'; graphValue: GraphValue; shape: readonly number[] | null; dtype: string | null; }; type GraphNodeData = GraphOperationNodeData | IoNodeData; type FlowNodeBase = { id: string; position: { x: number; y: number; }; initialWidth: number; initialHeight: number; }; type GraphFlowNode = FlowNodeBase & { type: 'graphNode'; data: GraphOperationNodeData; }; type IoFlowNode = FlowNodeBase & { type: 'ioNode'; data: IoNodeData; }; type FlowNode = GraphFlowNode | IoFlowNode; 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; }[]; }; }; type LayoutDirection = 'TB' | 'LR'; declare function filterGraph(graph: ModelGraph, query: string): ReadonlySet; declare function modelGraphToFlow(graph: ModelGraph, options?: { rankdir?: LayoutDirection; }): { nodes: FlowNode[]; edges: FlowEdge[]; }; type DecodedWeight = Float64Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array; type NumericWeight = Float64Array | Int32Array | Uint32Array; /** Return number-valued weights, preserving number arrays by identity. */ declare function numericView(values: DecodedWeight): NumericWeight; /** Bytes per element for a dtype name, accepting native and GGML scalar names. * Returns 0 for unknown dtypes. Q4_0 is block-quantized: 18 bytes per 32 elements, * so its per-element size is fractional. */ declare function elementSize(dtype: string): number; declare function decodeWeight(bytes: Uint8Array, dtype: string, shape: readonly number[]): DecodedWeight | null; declare function decodeFirstN(bytes: Uint8Array, dtype: string, n: number): DecodedWeight | null; interface WeightStats { readonly count: number; readonly min: number; readonly max: number; readonly mean: number; readonly std: number; readonly zeros: number; /** 12 fixed-width bins between min and max. */ readonly histogram: readonly number[]; /** 16 cols x 8 rows of mean-of-chunk values, length 128. */ readonly heatmap: readonly number[]; /** number of consecutive values averaged per heatmap cell. */ readonly chunkSize: number; /** * Number of heatmap cells that contain real data. * Cells beyond this index are zero-padded and should be treated as empty. * Always <= 128. Equal to 128 when the tensor has >= 128 elements. */ readonly filledCells: number; } declare function computeStats(values: NumericWeight): WeightStats; type WeightInspectionStatus = 'deferred' | 'external' | 'unavailable' | 'ready' | 'unsupported'; interface WeightInspectionBase { readonly tensor: { readonly name: string; readonly shape: readonly number[] | null; readonly dtype: string | null; /** Memory order of the payload. Absent means row-major. */ readonly order?: TensorOrder; }; } type WeightInspectionData = WeightInspectionBase & ({ readonly status: 'deferred' | 'external' | 'unavailable'; readonly bytes: null; readonly values: null; readonly stats: null; } | { readonly status: 'unsupported'; readonly bytes: Uint8Array; readonly values: null; readonly stats: null; } | { readonly status: 'ready'; readonly bytes: Uint8Array; readonly values: DecodedWeight; readonly numeric: NumericWeight; readonly stats: WeightStats; }); interface TensorSliceSelection { readonly rowAxis: number; readonly colAxis: number; readonly fixed: Readonly>; } interface TensorSliceDescriptor { readonly rows: number; readonly cols: number; readonly selection: TensorSliceSelection; } interface TensorLayout { readonly shape: readonly number[]; readonly strides: readonly number[]; readonly count: number; readonly order: TensorOrder; } declare function tensorElementCount(shape: readonly number[]): number; declare function tensorStrides(shape: readonly number[], order?: TensorOrder): readonly number[]; declare function tensorLayout(shape: readonly number[], order?: TensorOrder): TensorLayout; declare function coordinateToOffsetInLayout(coordinate: readonly number[], layout: TensorLayout): number; declare function coordinateToOffset(coordinate: readonly number[], shape: readonly number[]): number; declare function offsetToCoordinateInLayout(offset: number, layout: TensorLayout): readonly number[]; declare function offsetToCoordinate(offset: number, shape: readonly number[]): readonly number[]; declare function describeTensorSlice(shape: readonly number[], selection: TensorSliceSelection): TensorSliceDescriptor; interface TensorSliceCell { readonly row: readonly [number, number]; readonly col: readonly [number, number]; readonly coordinateStart: readonly number[]; readonly coordinateEnd: readonly number[]; readonly mean: number; readonly min: number; readonly max: number; } interface TensorSliceSample { readonly rows: number; readonly cols: number; readonly sourceRows: number; readonly sourceCols: number; readonly cells: readonly TensorSliceCell[]; readonly min: number; readonly max: number; } declare function sampleTensorSlice(values: DecodedWeight, shape: readonly number[], selection: TensorSliceSelection, maxRows: number, maxCols: number, order?: TensorOrder): TensorSliceSample; interface WeightDistribution { readonly finiteCount: number; readonly nanCount: number; readonly positiveInfinityCount: number; readonly negativeInfinityCount: number; readonly min: number; readonly max: number; readonly percentiles: Readonly>; readonly approximate: boolean; readonly fullRange: { readonly edges: readonly number[]; readonly counts: readonly number[]; }; readonly percentileRange: { readonly edges: readonly number[]; readonly counts: readonly number[]; } | null; } declare function computeWeightDistribution(values: DecodedWeight, bins?: number): WeightDistribution; type AxisMetric = 'mean' | 'std' | 'l1' | 'l2' | 'max-abs' | 'zero-ratio'; interface AxisStats { readonly axis: number; readonly metrics: Readonly>; readonly excluded: readonly number[]; readonly min: number; readonly max: number; } declare function computeAxisStats(values: DecodedWeight, shape: readonly number[], axis: number, order?: TensorOrder): AxisStats; interface SparsitySummary { readonly count: number; readonly zeroCount: number; readonly zeroRatio: number; readonly zeroRatioByAxis: readonly number[]; readonly deadSlices: number; } interface SparsityBlock { readonly row: readonly [number, number]; readonly col: readonly [number, number]; readonly coordinateStart: readonly number[]; readonly coordinateEnd: readonly number[]; readonly occupied: number; readonly empty: number; } declare function computeWeightSparsity(values: DecodedWeight, shape: readonly number[], axis: number, threshold?: number, order?: TensorOrder): SparsitySummary; declare function computeSparsityBlocks(values: DecodedWeight, shape: readonly number[], selection: TensorSliceSelection, blockRows: number, blockCols: number, threshold?: number, order?: TensorOrder): readonly SparsityBlock[]; interface KernelAxisMapping { readonly output: number; readonly input: number; readonly height: number; readonly width: number; readonly group?: number; } type KernelLayoutPreset = 'OIHW' | 'OHWI' | 'HWIO' | 'IHWO'; declare const KERNEL_LAYOUTS: Readonly>; declare function validateKernelAxisMapping(shape: readonly number[], mapping: KernelAxisMapping): void; interface KernelSlice { readonly output: number; readonly input: number; readonly selection: TensorSliceSelection; } declare function kernelSlicePage(shape: readonly number[], mapping: KernelAxisMapping, outputStart: number, pageSize: number, input: number, group?: number): readonly KernelSlice[]; declare function computeKernelL2(values: DecodedWeight, shape: readonly number[], selection: TensorSliceSelection, order?: TensorOrder): number; interface Q4_0BlockInspection { readonly index: number; readonly scale: number; readonly frequencies: readonly number[]; readonly saturation: number; readonly zeroCodeFrequency: number; } interface Q4_0QuantizationInspection { readonly dtype: 'Q4_0'; readonly blockBytes: 18; readonly valuesPerBlock: 32; readonly blockCount: number; /** Inspect one block on demand. Returns null when index is out of range. * Lazy because a large tensor has hundreds of thousands of blocks and the * UI only ever displays one at a time. */ readonly blockAt: (index: number) => Q4_0BlockInspection | null; readonly frequencies: readonly number[]; readonly trailingBytes: number; } type QuantizationInspection = Q4_0QuantizationInspection; declare function inspectWeightQuantization(bytes: Uint8Array, dtype: string): QuantizationInspection | null; type DiagnosticSeverity = 'error' | 'warning' | 'info'; /** The median-absolute-deviation test that produced a `norm-outlier` finding. */ interface NormOutlierTest { readonly median: number; readonly deviation: number; readonly multiple: number; readonly threshold: number; } interface WeightDiagnosticFinding { readonly code: 'nan' | 'positive-infinity' | 'negative-infinity' | 'constant-slice' | 'norm-outlier'; readonly severity: DiagnosticSeverity; readonly count: number; readonly coordinates: readonly (readonly number[])[]; readonly position?: number; readonly value?: number; readonly outlier?: NormOutlierTest; } declare function inspectWeightDiagnostics(values: DecodedWeight, shape: readonly number[], axis: number, tolerance?: number, outlierMultiple?: number, order?: TensorOrder): readonly WeightDiagnosticFinding[]; type InspectorName = 'matrix' | 'distribution' | 'axis' | 'sparsity' | 'kernel' | 'quantization' | 'diagnostics' | 'values'; /** Inspectors offered for a tensor, in picker order. */ declare function availableInspectors(inspection: Pick): readonly InspectorName[]; /** Inspector to open a tensor with. */ declare function defaultInspector(shape: readonly number[] | null): InspectorName; /** Display text for the inspector picker. */ declare function inspectorLabel(name: InspectorName): string; /** Explains the summary block above the inspectors, which never changes with the view. */ declare function weightStatsHint(stats: WeightStats): string; /** One line describing what an inspector is for, shown beside the view picker. */ declare function inspectorViewHint(name: InspectorName): string; /** Option text pairing an axis with its extent, e.g. "axis 0 ยท 288". */ declare function axisOptionLabel(axis: number, shape: readonly number[]): string; declare function matrixAxisHint(kind: 'row' | 'col'): string; declare function matrixSampleHint(sample: TensorSliceSample): string; declare function matrixScaleHint(sample: TensorSliceSample): string; declare function distributionScaleHint(bins: number): string; declare function distributionDomainHint(): string; declare function distributionApproximateHint(distribution: WeightDistribution): string; declare function axisProfileAxisHint(): string; declare function axisMetricHint(metric: AxisMetric): string; declare function axisExcludedHint(excluded: number, sliceLength: number): string; declare function sparsityModeHint(): string; declare function sparsityZeroHint(summary: SparsitySummary, dtype: string | null): string; declare function sparsityDeadHint(summary: SparsitySummary, axis: number): string; declare function sparsityBlockHint(blockRows: number, blockCols: number): string; declare function kernelLayoutHint(shape: readonly number[]): string; declare function kernelInputHint(shape: readonly number[], mapping: KernelAxisMapping): string; declare function kernelL2Hint(shape: readonly number[], mapping: KernelAxisMapping, input: number): string; declare function kernelPageLabel(start: number, pageSize: number, total: number): string; type QuantizationField = 'block' | 'format' | 'levels' | 'blockSize' | 'trailingBytes' | 'scale' | 'saturation' | 'zeroCode' | 'histogram'; declare function quantizationHint(field: QuantizationField, result: QuantizationInspection, block: Q4_0BlockInspection | null): string; declare function diagnosticCodeHint(finding: WeightDiagnosticFinding, axis: number): string; declare function parseModel(bytes: Uint8Array, filename?: string): Promise; /** Fetches and parses a model from a URL. The server must allow CORS (`Access-Control-Allow-Origin`). */ declare function parseModelFromUrl(url: string): Promise; export { type AxisMetric, type AxisStats, type DecodedWeight, type DiagnosticSeverity, type FlowEdge, type FlowNode, type Format, type GraphFlowNode, type GraphNodeData, type GraphOperationNodeData, type InspectorName, type IoFlowNode, type IoNodeData, KERNEL_LAYOUTS, type KernelAxisMapping, type KernelLayoutPreset, type KernelSlice, type LayoutDirection, type NormOutlierTest, type NumericWeight, type Q4_0BlockInspection, type Q4_0QuantizationInspection, type QuantizationField, type QuantizationInspection, type SparsityBlock, type SparsitySummary, type TensorLayout, type TensorSliceCell, type TensorSliceDescriptor, type TensorSliceSample, type TensorSliceSelection, type WeightDiagnosticFinding, type WeightDistribution, type WeightInspectionData, type WeightInspectionStatus, type WeightStats, availableInspectors, axisExcludedHint, axisMetricHint, axisOptionLabel, axisProfileAxisHint, computeAxisStats, computeKernelL2, computeSparsityBlocks, computeStats, computeWeightDistribution, computeWeightSparsity, coordinateToOffset, coordinateToOffsetInLayout, decodeFirstN, decodeWeight, defaultInspector, describeTensorSlice, detectFormat, diagnosticCodeHint, distributionApproximateHint, distributionDomainHint, distributionScaleHint, elementSize, filterGraph, inspectWeightDiagnostics, inspectWeightQuantization, inspectorLabel, inspectorViewHint, kernelInputHint, kernelL2Hint, kernelLayoutHint, kernelPageLabel, kernelSlicePage, matrixAxisHint, matrixSampleHint, matrixScaleHint, modelGraphToFlow, numericView, offsetToCoordinate, offsetToCoordinateInLayout, opBase, opCategory, opInputLabels, parseModel, parseModelFromUrl, quantizationHint, sampleTensorSlice, sparsityBlockHint, sparsityDeadHint, sparsityModeHint, sparsityZeroHint, tensorElementCount, tensorLayout, tensorStrides, validateKernelAxisMapping, weightStatsHint };