UNPKG

onnxruntime-web

Version:

A Javascript library for running ONNX models on browsers

271 lines (270 loc) 9.16 kB
'use strict'; // automatically generated by the FlatBuffers compiler, do not modify var __createBinding = (this && this.__createBinding) || (Object.create ? function (o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function () { return m[k]; }, }; } Object.defineProperty(o, k2, desc); } : function (o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; }); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? function (o, v) { Object.defineProperty(o, 'default', { enumerable: true, value: v }); } : function (o, v) { o['default'] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, '__esModule', { value: true }); exports.Graph = void 0; /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ const flatbuffers = __importStar(require('flatbuffers')); const node_js_1 = require('../../onnxruntime/fbs/node.js'); const node_edge_js_1 = require('../../onnxruntime/fbs/node-edge.js'); const runtime_optimizations_js_1 = require('../../onnxruntime/fbs/runtime-optimizations.js'); const sparse_tensor_js_1 = require('../../onnxruntime/fbs/sparse-tensor.js'); const tensor_js_1 = require('../../onnxruntime/fbs/tensor.js'); const value_info_js_1 = require('../../onnxruntime/fbs/value-info.js'); class Graph { constructor() { this.bb = null; this.bb_pos = 0; } __init(i, bb) { this.bb_pos = i; this.bb = bb; return this; } static getRootAsGraph(bb, obj) { return (obj || new Graph()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsGraph(bb, obj) { bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); return (obj || new Graph()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } initializers(index, obj) { const offset = this.bb.__offset(this.bb_pos, 4); return offset ? (obj || new tensor_js_1.Tensor()).__init( this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb, ) : null; } initializersLength() { const offset = this.bb.__offset(this.bb_pos, 4); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } nodeArgs(index, obj) { const offset = this.bb.__offset(this.bb_pos, 6); return offset ? (obj || new value_info_js_1.ValueInfo()).__init( this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb, ) : null; } nodeArgsLength() { const offset = this.bb.__offset(this.bb_pos, 6); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } nodes(index, obj) { const offset = this.bb.__offset(this.bb_pos, 8); return offset ? (obj || new node_js_1.Node()).__init( this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb, ) : null; } nodesLength() { const offset = this.bb.__offset(this.bb_pos, 8); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } maxNodeIndex() { const offset = this.bb.__offset(this.bb_pos, 10); return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; } nodeEdges(index, obj) { const offset = this.bb.__offset(this.bb_pos, 12); return offset ? (obj || new node_edge_js_1.NodeEdge()).__init( this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb, ) : null; } nodeEdgesLength() { const offset = this.bb.__offset(this.bb_pos, 12); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } inputs(index, optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 14); return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; } inputsLength() { const offset = this.bb.__offset(this.bb_pos, 14); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } outputs(index, optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 16); return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; } outputsLength() { const offset = this.bb.__offset(this.bb_pos, 16); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } sparseInitializers(index, obj) { const offset = this.bb.__offset(this.bb_pos, 18); return offset ? (obj || new sparse_tensor_js_1.SparseTensor()).__init( this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb, ) : null; } sparseInitializersLength() { const offset = this.bb.__offset(this.bb_pos, 18); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } runtimeOptimizations(obj) { const offset = this.bb.__offset(this.bb_pos, 20); return offset ? (obj || new runtime_optimizations_js_1.RuntimeOptimizations()).__init( this.bb.__indirect(this.bb_pos + offset), this.bb, ) : null; } static startGraph(builder) { builder.startObject(9); } static addInitializers(builder, initializersOffset) { builder.addFieldOffset(0, initializersOffset, 0); } static createInitializersVector(builder, data) { builder.startVector(4, data.length, 4); for (let i = data.length - 1; i >= 0; i--) { builder.addOffset(data[i]); } return builder.endVector(); } static startInitializersVector(builder, numElems) { builder.startVector(4, numElems, 4); } static addNodeArgs(builder, nodeArgsOffset) { builder.addFieldOffset(1, nodeArgsOffset, 0); } static createNodeArgsVector(builder, data) { builder.startVector(4, data.length, 4); for (let i = data.length - 1; i >= 0; i--) { builder.addOffset(data[i]); } return builder.endVector(); } static startNodeArgsVector(builder, numElems) { builder.startVector(4, numElems, 4); } static addNodes(builder, nodesOffset) { builder.addFieldOffset(2, nodesOffset, 0); } static createNodesVector(builder, data) { builder.startVector(4, data.length, 4); for (let i = data.length - 1; i >= 0; i--) { builder.addOffset(data[i]); } return builder.endVector(); } static startNodesVector(builder, numElems) { builder.startVector(4, numElems, 4); } static addMaxNodeIndex(builder, maxNodeIndex) { builder.addFieldInt32(3, maxNodeIndex, 0); } static addNodeEdges(builder, nodeEdgesOffset) { builder.addFieldOffset(4, nodeEdgesOffset, 0); } static createNodeEdgesVector(builder, data) { builder.startVector(4, data.length, 4); for (let i = data.length - 1; i >= 0; i--) { builder.addOffset(data[i]); } return builder.endVector(); } static startNodeEdgesVector(builder, numElems) { builder.startVector(4, numElems, 4); } static addInputs(builder, inputsOffset) { builder.addFieldOffset(5, inputsOffset, 0); } static createInputsVector(builder, data) { builder.startVector(4, data.length, 4); for (let i = data.length - 1; i >= 0; i--) { builder.addOffset(data[i]); } return builder.endVector(); } static startInputsVector(builder, numElems) { builder.startVector(4, numElems, 4); } static addOutputs(builder, outputsOffset) { builder.addFieldOffset(6, outputsOffset, 0); } static createOutputsVector(builder, data) { builder.startVector(4, data.length, 4); for (let i = data.length - 1; i >= 0; i--) { builder.addOffset(data[i]); } return builder.endVector(); } static startOutputsVector(builder, numElems) { builder.startVector(4, numElems, 4); } static addSparseInitializers(builder, sparseInitializersOffset) { builder.addFieldOffset(7, sparseInitializersOffset, 0); } static createSparseInitializersVector(builder, data) { builder.startVector(4, data.length, 4); for (let i = data.length - 1; i >= 0; i--) { builder.addOffset(data[i]); } return builder.endVector(); } static startSparseInitializersVector(builder, numElems) { builder.startVector(4, numElems, 4); } static addRuntimeOptimizations(builder, runtimeOptimizationsOffset) { builder.addFieldOffset(8, runtimeOptimizationsOffset, 0); } static endGraph(builder) { const offset = builder.endObject(); return offset; } } exports.Graph = Graph; //# sourceMappingURL=graph.js.map