UNPKG

@ai-on-browser/data-analysis-models

Version:

Data analysis model package without any dependencies

27 lines (24 loc) 865 B
import { onnx } from '../onnx_exporter.js' /** * Handle shape layer */ export default { /** * Export to onnx object. * @param {onnx.ModelProto} model Model object * @param {import("../../graph").LayerObject & {type: 'shape'}} obj Node object * @param {{[key: string]: {type: onnx.TensorProto.DataType; size: number[]}}} info Output informatino of other layers * @returns {{type: onnx.TensorProto.DataType; size: number[]} | undefined} Output information of this layer */ export(model, obj, info) { const input = Array.isArray(obj.input) ? obj.input[0] : obj.input const node = new onnx.NodeProto() node.setOpType('Shape') node.addInput(input) node.addOutput(obj.name) const graph = model.getGraph() graph.addNode(node) const inSize = info[input].size return { type: onnx.TensorProto.DataType.INT64, size: [inSize.length] } }, }