Skip to content

Commit c55fad6

Browse files
author
Kangyi Zhang
authored
Update tfjs-node to 1.2.9. (#1983)
INTERNAL * Update tfjs-node to 1.2.9. * save * save
1 parent a9e29eb commit c55fad6

File tree

4 files changed

+49
-50
lines changed

4 files changed

+49
-50
lines changed

tfjs-node/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tensorflow/tfjs-node",
3-
"version": "1.2.8",
3+
"version": "1.2.9",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"gypfile": true,
@@ -50,7 +50,7 @@
5050
"yalc": "~1.0.0-pre.21"
5151
},
5252
"dependencies": {
53-
"@tensorflow/tfjs": "1.2.8",
53+
"@tensorflow/tfjs": "1.2.9",
5454
"adm-zip": "^0.4.11",
5555
"https-proxy-agent": "^2.2.1",
5656
"node-pre-gyp": "0.13.0",

tfjs-node/src/nodejs_kernel_backend.ts

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
* =============================================================================
1616
*/
1717

18+
import * as tfc from '@tensorflow/tfjs-core';
1819
import {BackendTimingInfo, DataMover, DataType, fill, KernelBackend, ones, Rank, rsqrt, Scalar, scalar, ShapeMap, Tensor, Tensor1D, tensor1d, Tensor2D, tensor2d, Tensor3D, tensor3d, Tensor4D, tidy, util} from '@tensorflow/tfjs-core';
1920
import {EPSILON_FLOAT32} from '@tensorflow/tfjs-core/dist/backends/backend';
2021
import {Conv2DInfo, Conv3DInfo} from '@tensorflow/tfjs-core/dist/ops/conv_util';
21-
import * as tfc from '@tensorflow/tfjs-core';
22-
2322
import {Activation, FusedBatchMatMulConfig} from '@tensorflow/tfjs-core/dist/ops/fused_util';
2423
import {Tensor5D} from '@tensorflow/tfjs-core/dist/tensor';
2524
import {BackendValues, upcastType} from '@tensorflow/tfjs-core/dist/types';
26-
import {isNullOrUndefined, isArray} from 'util';
25+
import {isArray, isNullOrUndefined} from 'util';
2726

2827
import {Int64Scalar} from './int64_tensors';
2928
import {TensorMetadata, TFEOpAttr, TFJSBinding} from './tfjs_binding';
@@ -288,30 +287,26 @@ export class NodeJSKernelBackend extends KernelBackend {
288287
}
289288

290289
stridedSlice<T extends Tensor>(
291-
x: T, begin: number[], end: number[], strides: number[],
292-
beginMask: number, endMask: number, ellipsisMask: number,
293-
newAxisMask: number, shrinkAxisMask: number): T {
290+
x: T, begin: number[], end: number[], strides: number[]): T {
294291
const beginTensor = tensor1d(begin, 'int32');
292+
for (let axis = 0; axis < end.length; axis++) {
293+
// Unlike Numpy, when the strides are negative, TF C uses -n-1 instead of
294+
// -1 as the "end" in order to include the first element.
295+
if (strides[axis] < 0 && end[axis] === -1) {
296+
end[axis] -= x.shape[axis];
297+
}
298+
}
295299
const endTensor = tensor1d(end, 'int32');
296300
const stridesTensor = tensor1d(strides, 'int32');
301+
// All of the masks have already been accounted for in the high level op,
302+
// so the backend does NOT need to deal with masks.
297303
const opAttrs = [
298304
createTypeOpAttr('T', x.dtype), createTypeOpAttr('Index', 'int32'),
299-
{name: 'begin_mask', type: this.binding.TF_ATTR_INT, value: beginMask},
300-
{name: 'end_mask', type: this.binding.TF_ATTR_INT, value: endMask}, {
301-
name: 'ellipsis_mask',
302-
type: this.binding.TF_ATTR_INT,
303-
value: ellipsisMask
304-
},
305-
{
306-
name: 'new_axis_mask',
307-
type: this.binding.TF_ATTR_INT,
308-
value: newAxisMask
309-
},
310-
{
311-
name: 'shrink_axis_mask',
312-
type: this.binding.TF_ATTR_INT,
313-
value: shrinkAxisMask
314-
}
305+
{name: 'begin_mask', type: this.binding.TF_ATTR_INT, value: 0},
306+
{name: 'end_mask', type: this.binding.TF_ATTR_INT, value: 0},
307+
{name: 'ellipsis_mask', type: this.binding.TF_ATTR_INT, value: 0},
308+
{name: 'new_axis_mask', type: this.binding.TF_ATTR_INT, value: 0},
309+
{name: 'shrink_axis_mask', type: this.binding.TF_ATTR_INT, value: 0}
315310
];
316311
return this.executeSingleOutput(
317312
'StridedSlice', opAttrs,
@@ -359,6 +354,8 @@ export class NodeJSKernelBackend extends KernelBackend {
359354
result = this.relu(result);
360355
} else if (activation === 'prelu') {
361356
result = this.prelu(result, preluActivationWeights) as Tensor4D;
357+
} else if (activation === 'elu') {
358+
result = this.elu(result);
362359
} else {
363360
throw new Error(`Activation: ${
364361
activation} has not been implemented for the Node.js backend`);
@@ -384,6 +381,8 @@ export class NodeJSKernelBackend extends KernelBackend {
384381
result = this.relu(result);
385382
} else if (activation === 'prelu') {
386383
result = this.prelu(result, preluActivationWeights) as Tensor3D;
384+
} else if (activation === 'elu') {
385+
result = this.elu(result);
387386
} else {
388387
throw new Error(`Activation: ${
389388
activation} has not been implemented for the Node.js backend`);
@@ -2028,4 +2027,4 @@ export function ensureTensorflowBackend() {
20282027
tfc.getBackend() === 'tensorflow',
20292028
() => `Expect the current backend to be "tensorflow", but got "${
20302029
tfc.getBackend()}"`);
2031-
}
2030+
}

tfjs-node/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @license See the LICENSE file. */
22

33
// This code is auto-generated, do not modify this file!
4-
const version = '1.2.8';
4+
const version = '1.2.9';
55
export {version};

tfjs-node/yarn.lock

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@
9090
lodash "^4.17.13"
9191
to-fast-properties "^2.0.0"
9292

93-
"@tensorflow/tfjs-converter@1.2.8":
94-
version "1.2.8"
95-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-1.2.8.tgz#86fa47be3e92a90d4191956f08015a17b93c3ef9"
96-
integrity sha512-weHzkNRVgnY9TcbA3XTneNgCyuIXLjF8ks8YbFA+81i2w6qO90xiAdWtP2YmR+F9K9S4WR3bSSB0AQKZAp+mPQ==
93+
"@tensorflow/tfjs-converter@1.2.9":
94+
version "1.2.9"
95+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-1.2.9.tgz#4774dd9447ac81c0c6776f9fd186374b9fa3bf1a"
96+
integrity sha512-OKmiuZicIgadT3Bv9BvM+oom7wRz9eC5rTglQnuv7VN9H0syFVuhf5oD1Ff70tGDhJjJgL+cPz01fZRxTXjRWA==
9797

98-
"@tensorflow/tfjs-core@1.2.8":
99-
version "1.2.8"
100-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-1.2.8.tgz#d6873b88522f8cf25d34c10afd095866578d7d92"
101-
integrity sha512-lWV4vAnXAAmahXpCWBwdGGW9HO6iNw9pUeVYih7pDXeJahMk3OJs6SgjRNhwn+ldsGwRoorR0/RHg0yNLmqWxQ==
98+
"@tensorflow/tfjs-core@1.2.9":
99+
version "1.2.9"
100+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-1.2.9.tgz#125830270a0bdd0e856914778a300c4ad6f51e21"
101+
integrity sha512-s0hHZSx6rGTlkkB8u8gs5n7sIPv1GXDNHmISRy+kqGzmlpkfI2kr6WXqOWQy6wFgjzopRD8cJQjBZ9USPZnYTQ==
102102
dependencies:
103103
"@types/offscreencanvas" "~2019.3.0"
104104
"@types/seedrandom" "2.4.27"
@@ -107,28 +107,28 @@
107107
node-fetch "~2.1.2"
108108
seedrandom "2.4.3"
109109

110-
"@tensorflow/tfjs-data@1.2.8":
111-
version "1.2.8"
112-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-data/-/tfjs-data-1.2.8.tgz#04325ad01167b0168ca8e34e85bc6a475aa5e8a0"
113-
integrity sha512-KUJy55mRx33OodlDKy6Emt2vvV9EadumZ6JzbtZCf1ADK5ddRpRLhCrEmGauCk+Ay1Zj+p6MYx6CLYqhJsENFQ==
110+
"@tensorflow/tfjs-data@1.2.9":
111+
version "1.2.9"
112+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-data/-/tfjs-data-1.2.9.tgz#54030a7990eb58d20288cab099d966d496710760"
113+
integrity sha512-Ti9Cj3pte9butuEsK5OPq0Lcqdi4wVUdtQXm0o7iYOZ0umseRzfbIb6zbdqucc2MQzOMTnRoxN+FL7LZmncsHg==
114114
dependencies:
115115
"@types/node-fetch" "^2.1.2"
116116
node-fetch "~2.1.2"
117117

118-
"@tensorflow/tfjs-layers@1.2.8":
119-
version "1.2.8"
120-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-layers/-/tfjs-layers-1.2.8.tgz#6d696dcfa530708b1fdb0cd7614a0d2a1c8ae58a"
121-
integrity sha512-NMcA44U0rvVpo/VUTMpqkBP3jbvNhRXV7K8KovLi/WZ9FG/u5XIbIqFkcT3QXBDUyjDUNFToYQM/59dtnaut9Q==
118+
"@tensorflow/tfjs-layers@1.2.9":
119+
version "1.2.9"
120+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-layers/-/tfjs-layers-1.2.9.tgz#d30d1bdfed228a07a3d4e9dcb9a6884031ae56e7"
121+
integrity sha512-OlXYaIb1rCk5dYmpaNsPEkO7R+T0oxfS3vQGIztNJB+YxrN8mwCu3hqgpbdKhAITiP+jxO0o+7bny8MsOCkOSQ==
122122

123-
"@tensorflow/tfjs@1.2.8":
124-
version "1.2.8"
125-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-1.2.8.tgz#441b78294f1e2f7174c5773f82424b8d963f0f60"
126-
integrity sha512-pNgLMWNpzWn8AIaTV+1MOjg0a99IBgGjDLLhgDBJ6m6/mzfDdFv2TxcYtF0kdF4asSd4cHaupuELeOzSF2coFw==
123+
"@tensorflow/tfjs@1.2.9":
124+
version "1.2.9"
125+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-1.2.9.tgz#120f55a2826f71a5816e02b5bc0311fd583beedb"
126+
integrity sha512-9UAQnSp638FyM5eedYEM+j2R7VcNajiFmkeT5EXtf7YIurmMFNEm1sbajKJx7/ckz31YcYrVoUPc/iLhhDQl2A==
127127
dependencies:
128-
"@tensorflow/tfjs-converter" "1.2.8"
129-
"@tensorflow/tfjs-core" "1.2.8"
130-
"@tensorflow/tfjs-data" "1.2.8"
131-
"@tensorflow/tfjs-layers" "1.2.8"
128+
"@tensorflow/tfjs-converter" "1.2.9"
129+
"@tensorflow/tfjs-core" "1.2.9"
130+
"@tensorflow/tfjs-data" "1.2.9"
131+
"@tensorflow/tfjs-layers" "1.2.9"
132132

133133
"@types/events@*":
134134
version "3.0.0"

0 commit comments

Comments
 (0)