@tensorflow/tfjs-node
Advanced tools
Comparing version 0.1.9 to 0.1.10
import { BackendTimingInfo, DataType, KernelBackend, Rank, ShapeMap, Tensor, Tensor1D, Tensor2D, Tensor3D, Tensor4D } from '@tensorflow/tfjs-core'; | ||
import { Conv2DInfo } from '@tensorflow/tfjs-core/dist/ops/conv_util'; | ||
import { TFJSBinding } from './tfjs_binding'; | ||
import { TFEOpAttr, TFJSBinding } from './tfjs_binding'; | ||
export declare class NodeJSKernelBackend implements KernelBackend { | ||
private binding; | ||
binding: TFJSBinding; | ||
private tensorMap; | ||
constructor(binding: TFJSBinding); | ||
private getTFDType(dataType); | ||
private createOutputTensor(metadata); | ||
private getInputTensorIds(tensors); | ||
private createReductionOpAttrs(tensor); | ||
private createTypeOpAttr(attrName, dtype); | ||
private executeSingleInput(name, input); | ||
private executeSingleOutput(name, opAttrs, inputs); | ||
private executeMultipleOutputs(name, opAttrs, inputs, numOutputs); | ||
executeSingleOutput(name: string, opAttrs: TFEOpAttr[], inputs: Tensor[]): Tensor; | ||
executeMultipleOutputs(name: string, opAttrs: TFEOpAttr[], inputs: Tensor[], numOutputs: number): Tensor[]; | ||
dispose(): void; | ||
@@ -29,2 +27,4 @@ read(dataId: object): Promise<Float32Array | Int32Array | Uint8Array>; | ||
add(a: Tensor, b: Tensor): Tensor; | ||
select(condition: Tensor, a: Tensor, b: Tensor): Tensor; | ||
addN<T extends Tensor>(tensors: T[]): T; | ||
subtract(a: Tensor, b: Tensor): Tensor; | ||
@@ -48,5 +48,6 @@ multiply(a: Tensor, b: Tensor): Tensor; | ||
logicalOr(a: Tensor, b: Tensor): Tensor; | ||
where(condition: Tensor, a: Tensor, b: Tensor, dtype: DataType): Tensor; | ||
where(condition: Tensor): Tensor2D; | ||
topKValues<T extends Tensor>(x: T, k: number): Tensor1D; | ||
topKIndices(x: Tensor, k: number): Tensor1D; | ||
topk<T extends Tensor>(x: T, k?: number, sorted?: boolean): [T, T]; | ||
min(x: Tensor, axes: number[]): Tensor; | ||
@@ -113,2 +114,4 @@ minimum(a: Tensor, b: Tensor): Tensor; | ||
gather<T extends Tensor>(x: T, indices: Tensor1D, axis: number): T; | ||
batchToSpaceND<T extends Tensor>(x: T, blockShape: number[], crops: number[][]): T; | ||
spaceToBatchND<T extends Tensor>(x: T, blockShape: number[], paddings: number[][]): T; | ||
resizeBilinear(x: Tensor4D, newHeight: number, newWidth: number, alignCorners: boolean): Tensor4D; | ||
@@ -120,5 +123,7 @@ resizeBilinearBackprop(dy: Tensor4D, x: Tensor4D, alignCorners: boolean): Tensor4D; | ||
localResponseNormalization4D(x: Tensor4D, radius: number, bias: number, alpha: number, beta: number): Tensor4D; | ||
LRNGrad(dy: Tensor4D, inputImage: Tensor4D, outputImage: Tensor4D, radius: number, bias: number, alpha: number, beta: number): Tensor4D; | ||
multinomial(logits: Tensor2D, normalized: boolean, numSamples: number, seed: number): Tensor2D; | ||
oneHot(indices: Tensor1D, depth: number, onValue: number, offValue: number): Tensor2D; | ||
cumsum(x: Tensor, axis: number, exclusive: boolean, reverse: boolean): Tensor; | ||
nonMaxSuppression(boxes: Tensor2D, scores: Tensor1D, maxOutputSize: number, iouThreshold?: number, scoreThreshold?: number): Tensor1D; | ||
fromPixels(pixels: ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, numChannels: number): Tensor3D; | ||
@@ -125,0 +130,0 @@ memory(): { |
@@ -40,2 +40,4 @@ "use strict"; | ||
var types_1 = require("@tensorflow/tfjs-core/dist/types"); | ||
var util_1 = require("util"); | ||
var op_utils_1 = require("./ops/op_utils"); | ||
var NodeJSKernelBackend = (function () { | ||
@@ -46,14 +48,2 @@ function NodeJSKernelBackend(binding) { | ||
} | ||
NodeJSKernelBackend.prototype.getTFDType = function (dataType) { | ||
switch (dataType) { | ||
case 'float32': | ||
return this.binding.TF_FLOAT; | ||
case 'int32': | ||
return this.binding.TF_INT32; | ||
case 'bool': | ||
return this.binding.TF_BOOL; | ||
default: | ||
throw new Error('Unknown dtype `${dtype}`'); | ||
} | ||
}; | ||
NodeJSKernelBackend.prototype.createOutputTensor = function (metadata) { | ||
@@ -100,15 +90,7 @@ var newId = {}; | ||
{ name: 'keep_dims', type: this.binding.TF_ATTR_BOOL, value: false }, | ||
this.createTypeOpAttr('T', tensor.dtype), | ||
this.createTypeOpAttr('Tidx', 'int32') | ||
op_utils_1.createTypeOpAttr('T', tensor.dtype), op_utils_1.createTypeOpAttr('Tidx', 'int32') | ||
]; | ||
}; | ||
NodeJSKernelBackend.prototype.createTypeOpAttr = function (attrName, dtype) { | ||
return { | ||
name: attrName, | ||
type: this.binding.TF_ATTR_TYPE, | ||
value: this.getTFDType(dtype) | ||
}; | ||
}; | ||
NodeJSKernelBackend.prototype.executeSingleInput = function (name, input) { | ||
var opAttrs = [this.createTypeOpAttr('T', input.dtype)]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', input.dtype)]; | ||
return this.executeSingleOutput(name, opAttrs, [input]); | ||
@@ -162,3 +144,3 @@ }; | ||
if (!this.tensorMap.has(dataId)) { | ||
this.tensorMap.set(dataId, { shape: shape, dtype: this.getTFDType(dtype), values: null, id: -1 }); | ||
this.tensorMap.set(dataId, { shape: shape, dtype: op_utils_1.getTFDType(dtype), values: null, id: -1 }); | ||
} | ||
@@ -170,3 +152,3 @@ }; | ||
{ name: 'transpose_b', type: this.binding.TF_ATTR_BOOL, value: transposeB }, | ||
this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype)) | ||
op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype)) | ||
]; | ||
@@ -180,4 +162,3 @@ return this.executeSingleOutput('MatMul', opAttrs, [a, b]); | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
this.createTypeOpAttr('Index', 'int32'), | ||
op_utils_1.createTypeOpAttr('T', x.dtype), op_utils_1.createTypeOpAttr('Index', 'int32'), | ||
{ name: 'begin_mask', type: this.binding.TF_ATTR_INT, value: beginMask }, | ||
@@ -192,6 +173,3 @@ { name: 'end_mask', type: this.binding.TF_ATTR_INT, value: endMask }, | ||
NodeJSKernelBackend.prototype.slice = function (x, begin, size) { | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
this.createTypeOpAttr('Index', 'int32') | ||
]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', x.dtype), op_utils_1.createTypeOpAttr('Index', 'int32')]; | ||
var beginTensor = tfjs_core_1.tensor1d(begin, 'int32'); | ||
@@ -202,6 +180,3 @@ var sizeTensor = tfjs_core_1.tensor1d(size, 'int32'); | ||
NodeJSKernelBackend.prototype.reverse = function (a, axis) { | ||
var opAttrs = [ | ||
this.createTypeOpAttr('Tidx', 'int32'), | ||
this.createTypeOpAttr('T', a.dtype) | ||
]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('Tidx', 'int32'), op_utils_1.createTypeOpAttr('T', a.dtype)]; | ||
var axisTensor = tfjs_core_1.tensor1d(axis, 'int32'); | ||
@@ -213,4 +188,3 @@ return this.executeSingleOutput('ReverseV2', opAttrs, [a, axisTensor]); | ||
{ name: 'N', type: this.binding.TF_ATTR_INT, value: 2 }, | ||
this.createTypeOpAttr('Tidx', 'int32'), | ||
this.createTypeOpAttr('T', a.dtype) | ||
op_utils_1.createTypeOpAttr('Tidx', 'int32'), op_utils_1.createTypeOpAttr('T', a.dtype) | ||
]; | ||
@@ -224,23 +198,34 @@ var axisTensor = tfjs_core_1.scalar(1, 'int32'); | ||
NodeJSKernelBackend.prototype.add = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('Add', opAttrs, [a, b]); | ||
}; | ||
NodeJSKernelBackend.prototype.select = function (condition, a, b) { | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('Select', opAttrs, [condition, a, b]); | ||
}; | ||
NodeJSKernelBackend.prototype.addN = function (tensors) { | ||
var opAttrs = [ | ||
op_utils_1.createTypeOpAttr('T', tensors[0].dtype), | ||
{ name: 'N', type: this.binding.TF_ATTR_INT, value: tensors.length } | ||
]; | ||
return this.executeSingleOutput('AddN', opAttrs, tensors); | ||
}; | ||
NodeJSKernelBackend.prototype.subtract = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('Sub', opAttrs, [a, b]); | ||
}; | ||
NodeJSKernelBackend.prototype.multiply = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('Mul', opAttrs, [a, b]); | ||
}; | ||
NodeJSKernelBackend.prototype.realDivide = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('RealDiv', opAttrs, [a, b]); | ||
}; | ||
NodeJSKernelBackend.prototype.floorDiv = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('FloorDiv', opAttrs, [a, b]); | ||
}; | ||
NodeJSKernelBackend.prototype.divide = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('Div', opAttrs, [a, b]); | ||
@@ -250,5 +235,4 @@ }; | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
this.createTypeOpAttr('Tindices', 'int32'), | ||
this.createTypeOpAttr('Tnumsegments', 'int32') | ||
op_utils_1.createTypeOpAttr('T', x.dtype), op_utils_1.createTypeOpAttr('Tindices', 'int32'), | ||
op_utils_1.createTypeOpAttr('Tnumsegments', 'int32') | ||
]; | ||
@@ -264,5 +248,4 @@ return this.executeSingleOutput('UnsortedSegmentSum', opAttrs, [x, segmentIds, tfjs_core_1.scalar(numSegments, 'int32')]); | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
this.createTypeOpAttr('Tidx', 'int32'), | ||
this.createTypeOpAttr('output_type', 'int32') | ||
op_utils_1.createTypeOpAttr('T', x.dtype), op_utils_1.createTypeOpAttr('Tidx', 'int32'), | ||
op_utils_1.createTypeOpAttr('output_type', 'int32') | ||
]; | ||
@@ -274,5 +257,4 @@ return this.executeSingleOutput('ArgMin', opAttrs, [x, axisScalar]); | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
this.createTypeOpAttr('Tidx', 'int32'), | ||
this.createTypeOpAttr('output_type', 'int32') | ||
op_utils_1.createTypeOpAttr('T', x.dtype), op_utils_1.createTypeOpAttr('Tidx', 'int32'), | ||
op_utils_1.createTypeOpAttr('output_type', 'int32') | ||
]; | ||
@@ -282,23 +264,23 @@ return this.executeSingleOutput('ArgMax', opAttrs, [x, axisScalar]); | ||
NodeJSKernelBackend.prototype.equal = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('Equal', opAttrs, [a, b]); | ||
}; | ||
NodeJSKernelBackend.prototype.notEqual = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('NotEqual', opAttrs, [a, b]); | ||
}; | ||
NodeJSKernelBackend.prototype.less = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('Less', opAttrs, [a, b]); | ||
}; | ||
NodeJSKernelBackend.prototype.lessEqual = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('LessEqual', opAttrs, [a, b]); | ||
}; | ||
NodeJSKernelBackend.prototype.greater = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('Greater', opAttrs, [a, b]); | ||
}; | ||
NodeJSKernelBackend.prototype.greaterEqual = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('GreaterEqual', opAttrs, [a, b]); | ||
@@ -315,5 +297,4 @@ }; | ||
}; | ||
NodeJSKernelBackend.prototype.where = function (condition, a, b, dtype) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('Select', opAttrs, [condition, a, b]); | ||
NodeJSKernelBackend.prototype.where = function (condition) { | ||
return this.executeSingleOutput('Where', [], [condition]); | ||
}; | ||
@@ -326,2 +307,12 @@ NodeJSKernelBackend.prototype.topKValues = function (x, k) { | ||
}; | ||
NodeJSKernelBackend.prototype.topk = function (x, k, sorted) { | ||
var kCount = util_1.isNullOrUndefined(k) ? 1 : k; | ||
var isSorted = util_1.isNullOrUndefined(sorted) ? true : sorted; | ||
var opAttrs = [ | ||
{ name: 'sorted', type: this.binding.TF_ATTR_BOOL, value: isSorted }, | ||
op_utils_1.createTypeOpAttr('T', x.dtype), | ||
]; | ||
var kTensor = tfjs_core_1.scalar(kCount, 'int32'); | ||
return this.executeMultipleOutputs('TopKV2', opAttrs, [x, kTensor], 2); | ||
}; | ||
NodeJSKernelBackend.prototype.min = function (x, axes) { | ||
@@ -332,3 +323,3 @@ var axesTensor = tfjs_core_1.tensor1d(axes, 'int32'); | ||
NodeJSKernelBackend.prototype.minimum = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('Minimum', opAttrs, [a, b]); | ||
@@ -341,3 +332,3 @@ }; | ||
NodeJSKernelBackend.prototype.maximum = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', types_1.upcastType(a.dtype, b.dtype))]; | ||
return this.executeSingleOutput('Maximum', opAttrs, [a, b]); | ||
@@ -348,3 +339,3 @@ }; | ||
{ name: 'keep_dims', type: this.binding.TF_ATTR_BOOL, value: false }, | ||
this.createTypeOpAttr('Tidx', 'int32') | ||
op_utils_1.createTypeOpAttr('Tidx', 'int32') | ||
]; | ||
@@ -357,3 +348,3 @@ var axesTensor = tfjs_core_1.tensor1d(axes, 'int32'); | ||
{ name: 'keep_dims', type: this.binding.TF_ATTR_BOOL, value: false }, | ||
this.createTypeOpAttr('Tidx', 'int32') | ||
op_utils_1.createTypeOpAttr('Tidx', 'int32') | ||
]; | ||
@@ -371,3 +362,3 @@ var axesTensor = tfjs_core_1.tensor1d(axes, 'int32'); | ||
var dtype = types_1.upcastType(a.dtype, b.dtype); | ||
var opAttrs = [this.createTypeOpAttr('T', dtype)]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', dtype)]; | ||
return this.executeSingleOutput('Pow', opAttrs, [a.cast(dtype), b.cast(dtype)]); | ||
@@ -398,3 +389,3 @@ }; | ||
NodeJSKernelBackend.prototype.eluDer = function (dy, y) { | ||
var opAttrs = [this.createTypeOpAttr('T', y.dtype)]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', y.dtype)]; | ||
return this.executeSingleOutput('EluGrad', opAttrs, [dy, y]); | ||
@@ -446,3 +437,3 @@ }; | ||
NodeJSKernelBackend.prototype.mod = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', a.dtype)]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', a.dtype)]; | ||
return this.executeSingleOutput('FloorMod', opAttrs, [a, b]); | ||
@@ -475,3 +466,3 @@ }; | ||
NodeJSKernelBackend.prototype.squaredDifference = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', a.dtype)]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', a.dtype)]; | ||
return this.executeSingleOutput('SquaredDifference', opAttrs, [a, b]); | ||
@@ -486,3 +477,3 @@ }; | ||
NodeJSKernelBackend.prototype.atan2 = function (a, b) { | ||
var opAttrs = [this.createTypeOpAttr('T', a.dtype)]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', a.dtype)]; | ||
return this.executeSingleOutput('Atan2', opAttrs, [a, b]); | ||
@@ -493,4 +484,4 @@ }; | ||
var nans = this.isNaN(x); | ||
var stepNoNans = this.where(this.greater(x, tfjs_core_1.scalar(0, dtype)), tfjs_core_1.ones(x.shape), tfjs_core_1.fill(x.shape, alpha, dtype), dtype); | ||
return this.where(nans, x, stepNoNans, dtype); | ||
var stepNoNans = this.select(this.greater(x, tfjs_core_1.scalar(0, dtype)), tfjs_core_1.ones(x.shape), tfjs_core_1.fill(x.shape, alpha, dtype)); | ||
return this.select(nans, x, stepNoNans); | ||
}; | ||
@@ -507,3 +498,3 @@ NodeJSKernelBackend.prototype.conv2d = function (x, filter, convInfo) { | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
op_utils_1.createTypeOpAttr('T', x.dtype), | ||
{ name: 'strides', type: this.binding.TF_ATTR_INT, value: strides }, | ||
@@ -531,3 +522,3 @@ { name: 'padding', type: this.binding.TF_ATTR_STRING, value: padding }, | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', 'float32'), | ||
op_utils_1.createTypeOpAttr('T', 'float32'), | ||
{ name: 'strides', type: this.binding.TF_ATTR_INT, value: strides }, | ||
@@ -555,3 +546,3 @@ { name: 'padding', type: this.binding.TF_ATTR_STRING, value: padding }, { | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', 'float32'), | ||
op_utils_1.createTypeOpAttr('T', 'float32'), | ||
{ name: 'strides', type: this.binding.TF_ATTR_INT, value: strides }, | ||
@@ -575,3 +566,3 @@ { name: 'padding', type: this.binding.TF_ATTR_STRING, value: padding }, { | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', 'float32'), | ||
op_utils_1.createTypeOpAttr('T', 'float32'), | ||
{ name: 'strides', type: this.binding.TF_ATTR_INT, value: strides }, | ||
@@ -594,3 +585,3 @@ { name: 'padding', type: this.binding.TF_ATTR_STRING, value: padding }, { | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', 'float32'), | ||
op_utils_1.createTypeOpAttr('T', 'float32'), | ||
{ name: 'strides', type: this.binding.TF_ATTR_INT, value: strides }, | ||
@@ -617,3 +608,3 @@ { name: 'padding', type: this.binding.TF_ATTR_STRING, value: padding }, { | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', input.dtype), | ||
op_utils_1.createTypeOpAttr('T', input.dtype), | ||
{ name: 'strides', type: this.binding.TF_ATTR_INT, value: strides }, | ||
@@ -639,3 +630,3 @@ { name: 'padding', type: this.binding.TF_ATTR_STRING, value: padding }, { | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
op_utils_1.createTypeOpAttr('T', x.dtype), | ||
{ name: 'ksize', type: this.binding.TF_ATTR_INT, value: ksize }, | ||
@@ -661,3 +652,3 @@ { name: 'strides', type: this.binding.TF_ATTR_INT, value: strides }, | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
op_utils_1.createTypeOpAttr('T', x.dtype), | ||
{ name: 'ksize', type: this.binding.TF_ATTR_INT, value: ksize }, | ||
@@ -684,3 +675,3 @@ { name: 'strides', type: this.binding.TF_ATTR_INT, value: strides }, | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
op_utils_1.createTypeOpAttr('T', x.dtype), | ||
{ name: 'ksize', type: this.binding.TF_ATTR_INT, value: ksize }, | ||
@@ -707,3 +698,3 @@ { name: 'strides', type: this.binding.TF_ATTR_INT, value: strides }, | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
op_utils_1.createTypeOpAttr('T', x.dtype), | ||
{ name: 'ksize', type: this.binding.TF_ATTR_INT, value: ksize }, | ||
@@ -724,4 +715,4 @@ { name: 'strides', type: this.binding.TF_ATTR_INT, value: strides }, | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
this.createTypeOpAttr('Tshape', shapeTensor.dtype) | ||
op_utils_1.createTypeOpAttr('T', x.dtype), | ||
op_utils_1.createTypeOpAttr('Tshape', shapeTensor.dtype) | ||
]; | ||
@@ -731,6 +722,3 @@ return this.executeSingleOutput('Reshape', opAttrs, [x, shapeTensor]); | ||
NodeJSKernelBackend.prototype.cast = function (x, dtype) { | ||
var opAttrs = [ | ||
this.createTypeOpAttr('SrcT', x.dtype), | ||
this.createTypeOpAttr('DstT', dtype) | ||
]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('SrcT', x.dtype), op_utils_1.createTypeOpAttr('DstT', dtype)]; | ||
return this.executeSingleOutput('Cast', opAttrs, [x]); | ||
@@ -740,4 +728,3 @@ }; | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
this.createTypeOpAttr('Tmultiples', 'int32') | ||
op_utils_1.createTypeOpAttr('T', x.dtype), op_utils_1.createTypeOpAttr('Tmultiples', 'int32') | ||
]; | ||
@@ -751,4 +738,4 @@ var multiples = tfjs_core_1.tensor1d(reps, 'int32'); | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
this.createTypeOpAttr('Tpaddings', paddingsTensor.dtype) | ||
op_utils_1.createTypeOpAttr('T', x.dtype), | ||
op_utils_1.createTypeOpAttr('Tpaddings', paddingsTensor.dtype) | ||
]; | ||
@@ -759,6 +746,3 @@ return this.executeSingleOutput('PadV2', opAttrs, [x, paddingsTensor, constantTensor]); | ||
var permTensor = tfjs_core_1.tensor1d(perm, 'int32'); | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
this.createTypeOpAttr('Tperm', 'int32') | ||
]; | ||
var opAttrs = [op_utils_1.createTypeOpAttr('T', x.dtype), op_utils_1.createTypeOpAttr('Tperm', 'int32')]; | ||
return this.executeSingleOutput('Transpose', opAttrs, [x, permTensor]); | ||
@@ -769,11 +753,29 @@ }; | ||
var opAttrs = [ | ||
this.createTypeOpAttr('Tparams', x.dtype), | ||
this.createTypeOpAttr('Tindices', indices.dtype), | ||
this.createTypeOpAttr('Taxis', 'int32') | ||
op_utils_1.createTypeOpAttr('Tparams', x.dtype), | ||
op_utils_1.createTypeOpAttr('Tindices', indices.dtype), | ||
op_utils_1.createTypeOpAttr('Taxis', 'int32') | ||
]; | ||
return this.executeSingleOutput('GatherV2', opAttrs, [x, indices, axisTensor]); | ||
}; | ||
NodeJSKernelBackend.prototype.batchToSpaceND = function (x, blockShape, crops) { | ||
var blockShapeTensor = tfjs_core_1.tensor1d(blockShape, 'int32'); | ||
var cropsTensor = tfjs_core_1.tensor2d(crops, [crops.length, crops[0].length], 'int32'); | ||
var opAttrs = [ | ||
op_utils_1.createTypeOpAttr('T', x.dtype), op_utils_1.createTypeOpAttr('Tblock_shape', 'int32'), | ||
op_utils_1.createTypeOpAttr('Tcrops', cropsTensor.dtype) | ||
]; | ||
return this.executeSingleOutput('BatchToSpaceND', opAttrs, [x, blockShapeTensor, cropsTensor]); | ||
}; | ||
NodeJSKernelBackend.prototype.spaceToBatchND = function (x, blockShape, paddings) { | ||
var blockShapeTensor = tfjs_core_1.tensor1d(blockShape, 'int32'); | ||
var paddingsTensor = tfjs_core_1.tensor2d(paddings, [paddings.length, paddings[0].length], 'int32'); | ||
var opAttrs = [ | ||
op_utils_1.createTypeOpAttr('T', x.dtype), op_utils_1.createTypeOpAttr('Tblock_shape', 'int32'), | ||
op_utils_1.createTypeOpAttr('Tpaddings', paddingsTensor.dtype) | ||
]; | ||
return this.executeSingleOutput('SpaceToBatchND', opAttrs, [x, blockShapeTensor, paddingsTensor]); | ||
}; | ||
NodeJSKernelBackend.prototype.resizeBilinear = function (x, newHeight, newWidth, alignCorners) { | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
op_utils_1.createTypeOpAttr('T', x.dtype), | ||
{ | ||
@@ -790,3 +792,3 @@ name: 'align_corners', | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), { | ||
op_utils_1.createTypeOpAttr('T', x.dtype), { | ||
name: 'align_corners', | ||
@@ -801,3 +803,3 @@ type: this.binding.TF_ATTR_BOOL, | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
op_utils_1.createTypeOpAttr('T', x.dtype), | ||
{ | ||
@@ -814,3 +816,3 @@ name: 'align_corners', | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), { | ||
op_utils_1.createTypeOpAttr('T', x.dtype), { | ||
name: 'align_corners', | ||
@@ -837,3 +839,3 @@ type: this.binding.TF_ATTR_BOOL, | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
op_utils_1.createTypeOpAttr('T', x.dtype), | ||
{ | ||
@@ -862,3 +864,3 @@ name: 'epsilon', | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', x.dtype), | ||
op_utils_1.createTypeOpAttr('T', x.dtype), | ||
{ name: 'depth_radius', type: this.binding.TF_ATTR_INT, value: radius }, | ||
@@ -871,2 +873,12 @@ { name: 'bias', type: this.binding.TF_ATTR_FLOAT, value: bias }, | ||
}; | ||
NodeJSKernelBackend.prototype.LRNGrad = function (dy, inputImage, outputImage, radius, bias, alpha, beta) { | ||
var opAttrs = [ | ||
op_utils_1.createTypeOpAttr('T', dy.dtype), | ||
{ name: 'depth_radius', type: this.binding.TF_ATTR_INT, value: radius }, | ||
{ name: 'bias', type: this.binding.TF_ATTR_FLOAT, value: bias }, | ||
{ name: 'alpha', type: this.binding.TF_ATTR_FLOAT, value: alpha }, | ||
{ name: 'beta', type: this.binding.TF_ATTR_FLOAT, value: beta }, | ||
]; | ||
return this.executeSingleOutput('LRNGrad', opAttrs, [dy, inputImage, outputImage]); | ||
}; | ||
NodeJSKernelBackend.prototype.multinomial = function (logits, normalized, numSamples, seed) { | ||
@@ -878,4 +890,4 @@ if (normalized) { | ||
var opAttrs = [ | ||
this.createTypeOpAttr('T', logits.dtype), | ||
this.createTypeOpAttr('output_dtype', 'int32'), | ||
op_utils_1.createTypeOpAttr('T', logits.dtype), | ||
op_utils_1.createTypeOpAttr('output_dtype', 'int32'), | ||
{ name: 'seed', type: this.binding.TF_ATTR_INT, value: seed }, | ||
@@ -892,4 +904,4 @@ { name: 'seed2', type: this.binding.TF_ATTR_INT, value: seed * seed }, | ||
{ name: 'axis', type: this.binding.TF_ATTR_INT, value: -1 }, | ||
this.createTypeOpAttr('T', indices.dtype), | ||
this.createTypeOpAttr('TI', indices.dtype) | ||
op_utils_1.createTypeOpAttr('T', indices.dtype), | ||
op_utils_1.createTypeOpAttr('TI', indices.dtype) | ||
]; | ||
@@ -905,7 +917,16 @@ return this.executeSingleOutput('OneHot', opAttrs, [ | ||
{ name: 'reverse', type: this.binding.TF_ATTR_BOOL, value: reverse }, | ||
this.createTypeOpAttr('T', x.dtype), | ||
this.createTypeOpAttr('Tidx', 'int32') | ||
op_utils_1.createTypeOpAttr('T', x.dtype), op_utils_1.createTypeOpAttr('Tidx', 'int32') | ||
]; | ||
return this.executeSingleOutput('Cumsum', opAttrs, [x, axisTensor]); | ||
}; | ||
NodeJSKernelBackend.prototype.nonMaxSuppression = function (boxes, scores, maxOutputSize, iouThreshold, scoreThreshold) { | ||
var opAttrs = []; | ||
var maxOutputSizeTensor = tfjs_core_1.scalar(maxOutputSize, 'int32'); | ||
var iouThresholdTensor = tfjs_core_1.scalar(iouThreshold); | ||
var scoreThresholdTensor = tfjs_core_1.scalar(scoreThreshold); | ||
return this.executeSingleOutput('NonMaxSuppressionV3', opAttrs, [ | ||
boxes, scores, maxOutputSizeTensor, iouThresholdTensor, | ||
scoreThresholdTensor | ||
]); | ||
}; | ||
NodeJSKernelBackend.prototype.fromPixels = function (pixels, numChannels) { | ||
@@ -912,0 +933,0 @@ if (pixels == null) { |
@@ -1,1 +0,1 @@ | ||
import './index'; | ||
import '.'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
require("./index"); | ||
require("."); | ||
var jasmine_util = require("@tensorflow/tfjs-core/dist/jasmine_util"); | ||
Error.stackTraceLimit = Infinity; | ||
var jasmineCtor = require('jasmine'); | ||
var bindings = require("bindings"); | ||
var nodejs_kernel_backend_1 = require("./nodejs_kernel_backend"); | ||
process.on('unhandledRejection', function (e) { throw e; }); | ||
jasmine_util.setTestEnvs([{ | ||
name: 'test-tensorflow', | ||
factory: function () { | ||
return new nodejs_kernel_backend_1.NodeJSKernelBackend(bindings('tfjs_binding.node')); | ||
}, | ||
features: {} | ||
}]); | ||
var op_utils_1 = require("./ops/op_utils"); | ||
process.on('unhandledRejection', function (e) { | ||
throw e; | ||
}); | ||
jasmine_util.setTestEnvs([{ name: 'test-tensorflow', factory: function () { return op_utils_1.nodeBackend(); }, features: {} }]); | ||
var IGNORE_LIST = [ | ||
@@ -40,2 +35,3 @@ 'depthwiseConv2D', | ||
}; | ||
console.log("Running tests against TensorFlow: " + op_utils_1.nodeBackend().binding.TF_Version); | ||
runner.execute(); |
@@ -1,2 +0,2 @@ | ||
declare const version = "0.1.9"; | ||
declare const version = "0.1.10"; | ||
export { version }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var version = '0.1.9'; | ||
var version = '0.1.10'; | ||
exports.version = version; |
{ | ||
"name": "@tensorflow/tfjs-node", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"main": "dist/index.js", | ||
@@ -25,3 +25,3 @@ "types": "dist/index.d.ts", | ||
"devDependencies": { | ||
"@tensorflow/tfjs-core": "~0.12.1", | ||
"@tensorflow/tfjs-core": "~0.12.8", | ||
"@types/bindings": "~1.3.0", | ||
@@ -43,4 +43,4 @@ "@types/jasmine": "~2.8.6", | ||
"peerDependencies": { | ||
"@tensorflow/tfjs-core": "~0.12.1" | ||
"@tensorflow/tfjs-core": "~0.12.8" | ||
} | ||
} |
@@ -14,4 +14,4 @@ <a id="travis-badge" href="https://travis-ci.org/tensorflow/tfjs-node" alt="Build Status"> | ||
- Mac OS X CPU (10.12.6 Siera or higher) | ||
- Linux CPU (Ubuntu 16.04 or higher) | ||
- Linux GPU (Ubuntu 16.04 or higher and Cuda 9.0 w/ CUDNN v7) ([see installation instructions](https://www.tensorflow.org/install/install_linux)) | ||
- Linux CPU (Ubuntu 14.04 or higher) | ||
- Linux GPU (Ubuntu 14.04 or higher and Cuda 9.0 w/ CUDNN v7) ([see installation instructions](https://www.tensorflow.org/install/install_linux)) | ||
@@ -18,0 +18,0 @@ *Other Linux variants might also work but this project matches [core TensorFlow installation requirements](https://www.tensorflow.org/install/install_linux).* |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
247470
55
2236