@hoff97/tensor-js
Version:
PyTorch like deep learning inferrence library
45 lines • 1.86 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { OnnxNode } from '../../node';
export class ReduceNode extends OnnxNode {
constructor(attributes, inputs, outputs, constants, onnxVersion, name, mode) {
super(attributes, inputs, outputs, constants, onnxVersion, mode);
this.axes = this.getAttributeInts('axes');
const keep = this.getAttributeInt('keepdims');
this.keepDims = keep === 1 || keep === undefined;
this.name = name;
}
getAxes(input) {
if (this.axes !== undefined) {
return this.axes;
}
else {
const rank = input.getShape().length;
const res = new Array(rank);
for (let i = 0; i < rank; i++) {
res[i] = i;
}
return res;
}
}
forward(inputs) {
return __awaiter(this, void 0, void 0, function* () {
if (this.onnxVersion < 13) {
return [this.calc(inputs[0])];
}
throw new Error(`${this.name} is not implemented for onnx version ${this.onnxVersion}`);
});
}
getType() {
return this.name;
}
delete() { }
}
//# sourceMappingURL=reduceNode.js.map