Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tensorflow/tfjs-converter

Package Overview
Dependencies
Maintainers
12
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tensorflow/tfjs-converter - npm Package Compare versions

Comparing version 1.7.1 to 1.7.2

8

dist/operations/executors/convolution_executor.js

@@ -116,2 +116,10 @@ "use strict";

}
case 'MaxPoolWithArgmax': {
var stride = utils_1.getParamValue('strides', node, tensorMap, context);
var pad = utils_1.getParamValue('pad', node, tensorMap, context);
var kernelSize = utils_1.getParamValue('kernelSize', node, tensorMap, context);
var includeBatchInIndex = utils_1.getParamValue('includeBatchInIndex', node, tensorMap, context);
var _c = tfc.maxPoolWithArgmax(utils_1.getParamValue('x', node, tensorMap, context), [kernelSize[1], kernelSize[2]], [stride[1], stride[2]], pad, includeBatchInIndex), result = _c.result, indexes = _c.indexes;
return [result, indexes];
}
case 'AvgPool3D': {

@@ -118,0 +126,0 @@ var stride = utils_1.getParamValue('strides', node, tensorMap, context);

@@ -57,2 +57,19 @@ "use strict";

{
'tfOpName': 'MaxPoolWithArgmax',
'category': 'convolution',
'inputs': [
{ 'start': 0, 'name': 'x', 'type': 'tensor' },
],
'attrs': [
{ 'tfName': 'strides', 'name': 'strides', 'type': 'number[]' },
{ 'tfName': 'padding', 'name': 'pad', 'type': 'string' },
{ 'tfName': 'ksize', 'name': 'kernelSize', 'type': 'number[]' }, {
'tfName': 'include_batch_in_index',
'name': 'includeBatchInIndex',
'type': 'bool'
},
{ 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true }
]
},
{
'tfOpName': 'AvgPool3D',

@@ -59,0 +76,0 @@ 'category': 'convolution',

2

dist/operations/operation_mapper.js

@@ -298,2 +298,4 @@ "use strict";

case tensorflow.DataType.DT_INT64:
case tensorflow.DataType.DT_INT8:
case tensorflow.DataType.DT_UINT8:
return 'int32';

@@ -300,0 +302,0 @@ case tensorflow.DataType.DT_BOOL:

2

dist/version.d.ts
/** @license See the LICENSE file. */
declare const version = "1.7.1";
declare const version = "1.7.2";
export { version };

@@ -5,4 +5,4 @@ "use strict";

// This code is auto-generated, do not modify this file!
var version = '1.7.1';
var version = '1.7.2';
exports.version = version;
//# sourceMappingURL=version.js.map
{
"name": "@tensorflow/tfjs-converter",
"version": "1.7.1",
"version": "1.7.2",
"description": "Tensorflow model converter for javascript",

@@ -18,6 +18,6 @@ "main": "dist/index.js",

"peerDependencies": {
"@tensorflow/tfjs-core": "1.7.1"
"@tensorflow/tfjs-core": "1.7.2"
},
"devDependencies": {
"@tensorflow/tfjs-core": "1.7.1",
"@tensorflow/tfjs-core": "1.7.2",
"@types/deep-equal": "^1.0.1",

@@ -24,0 +24,0 @@ "@types/jasmine": "~2.8.6",

@@ -26,202 +26,215 @@ /**

export const executeOp: InternalOpExecutor =
(node: Node, tensorMap: NamedTensorsMap,
context: ExecutionContext): tfc.Tensor[] => {
switch (node.op) {
case 'Conv1D': {
const stride =
getParamValue('stride', node, tensorMap, context) as number;
const pad = getParamValue('pad', node, tensorMap, context);
const dataFormat =
(getParamValue('dataFormat', node, tensorMap, context) as string)
.toUpperCase();
const dilation =
getParamValue('dilation', node, tensorMap, context) as number;
return [tfc.conv1d(
getParamValue('x', node, tensorMap, context) as tfc.Tensor3D,
getParamValue('filter', node, tensorMap, context) as tfc.Tensor3D,
stride, pad as 'valid' | 'same', dataFormat as 'NWC' | 'NCW',
dilation)];
}
case 'Conv2D': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const dataFormat =
(getParamValue('dataFormat', node, tensorMap, context) as string)
.toUpperCase();
const dilations =
getParamValue('dilations', node, tensorMap, context) as number[];
return [tfc.conv2d(
getParamValue('x', node, tensorMap, context) as tfc.Tensor3D |
tfc.Tensor4D,
getParamValue('filter', node, tensorMap, context) as tfc.Tensor4D,
[stride[1], stride[2]], pad as 'valid' | 'same',
dataFormat as 'NHWC' | 'NCHW', [dilations[1], dilations[2]])];
}
case '_FusedConv2D':
case 'FusedDepthwiseConv2dNative': {
const [extraOp, activationFunc] =
(getParamValue('fusedOps', node, tensorMap, context) as string[]);
export const executeOp: InternalOpExecutor = (node: Node,
tensorMap: NamedTensorsMap,
context: ExecutionContext):
tfc.Tensor[] => {
switch (node.op) {
case 'Conv1D': {
const stride =
getParamValue('stride', node, tensorMap, context) as number;
const pad = getParamValue('pad', node, tensorMap, context);
const dataFormat =
(getParamValue('dataFormat', node, tensorMap, context) as string)
.toUpperCase();
const dilation =
getParamValue('dilation', node, tensorMap, context) as number;
return [tfc.conv1d(
getParamValue('x', node, tensorMap, context) as tfc.Tensor3D,
getParamValue('filter', node, tensorMap, context) as tfc.Tensor3D,
stride, pad as 'valid' | 'same', dataFormat as 'NWC' | 'NCW',
dilation)];
}
case 'Conv2D': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const dataFormat =
(getParamValue('dataFormat', node, tensorMap, context) as string)
.toUpperCase();
const dilations =
getParamValue('dilations', node, tensorMap, context) as number[];
return [tfc.conv2d(
getParamValue('x', node, tensorMap, context) as tfc.Tensor3D |
tfc.Tensor4D,
getParamValue('filter', node, tensorMap, context) as tfc.Tensor4D,
[stride[1], stride[2]], pad as 'valid' | 'same',
dataFormat as 'NHWC' | 'NCHW', [dilations[1], dilations[2]])];
}
case '_FusedConv2D':
case 'FusedDepthwiseConv2dNative': {
const [extraOp, activationFunc] =
(getParamValue('fusedOps', node, tensorMap, context) as string[]);
const isBiasAdd = extraOp === 'biasadd';
const isPrelu = activationFunc === 'prelu';
const isBatchNorm = extraOp === 'fusedbatchnorm';
const isBiasAdd = extraOp === 'biasadd';
const isPrelu = activationFunc === 'prelu';
const isBatchNorm = extraOp === 'fusedbatchnorm';
const numArgs =
(getParamValue('numArgs', node, tensorMap, context) as number);
if (isBiasAdd) {
if (isPrelu && numArgs !== 2) {
throw new Error(
'FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu ' +
'must have two extra arguments: bias and alpha.');
}
if (!isPrelu && numArgs !== 1) {
throw new Error(
'FusedConv2d and DepthwiseConv2d with BiasAdd must have ' +
'one extra argument: bias.');
}
}
if (isBatchNorm) {
throw new Error(
'FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported.');
}
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const dataFormat =
(getParamValue('dataFormat', node, tensorMap, context) as string)
.toUpperCase();
const dilations =
getParamValue('dilations', node, tensorMap, context) as number[];
const [biasArg, preluArg] =
getParamValue('args', node, tensorMap, context) as tfc.Tensor[];
const kernelMethod = node.op === '_FusedConv2D' ?
tfc.fused.conv2d :
tfc.fused.depthwiseConv2d;
return [kernelMethod({
x: getParamValue('x', node, tensorMap, context) as tfc.Tensor3D |
tfc.Tensor4D,
filter: getParamValue('filter', node, tensorMap, context) as
tfc.Tensor4D,
strides: [stride[1], stride[2]],
pad: pad as 'valid' | 'same',
dataFormat: dataFormat as 'NHWC' | 'NCHW',
dilations: [dilations[1], dilations[2]],
bias: biasArg,
activation: activationFunc as tfc.fused.Activation,
preluActivationWeights: preluArg
})];
const numArgs =
(getParamValue('numArgs', node, tensorMap, context) as number);
if (isBiasAdd) {
if (isPrelu && numArgs !== 2) {
throw new Error(
'FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu ' +
'must have two extra arguments: bias and alpha.');
}
case 'Conv2DBackpropInput':
case 'Conv2dTranspose': {
const shape = getParamValue(
'outputShape', node, tensorMap,
context) as [number, number, number] |
[number, number, number, number];
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
return [tfc.conv2dTranspose(
getParamValue('x', node, tensorMap, context) as tfc.Tensor3D |
tfc.Tensor4D,
getParamValue('filter', node, tensorMap, context) as tfc.Tensor4D,
shape, [stride[1], stride[2]], pad as 'valid' | 'same')];
if (!isPrelu && numArgs !== 1) {
throw new Error(
'FusedConv2d and DepthwiseConv2d with BiasAdd must have ' +
'one extra argument: bias.');
}
case 'DepthwiseConv2dNative':
case 'DepthwiseConv2d': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const dilations =
getParamValue('dilations', node, tensorMap, context) as number[];
const dataFormat =
(getParamValue('dataFormat', node, tensorMap, context) as string)
.toUpperCase();
}
if (isBatchNorm) {
throw new Error(
'FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported.');
}
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const dataFormat =
(getParamValue('dataFormat', node, tensorMap, context) as string)
.toUpperCase();
const dilations =
getParamValue('dilations', node, tensorMap, context) as number[];
const [biasArg, preluArg] =
getParamValue('args', node, tensorMap, context) as tfc.Tensor[];
const kernelMethod = node.op === '_FusedConv2D' ?
tfc.fused.conv2d :
tfc.fused.depthwiseConv2d;
return [kernelMethod({
x: getParamValue('x', node, tensorMap, context) as tfc.Tensor3D |
tfc.Tensor4D,
filter: getParamValue('filter', node, tensorMap, context) as
tfc.Tensor4D,
strides: [stride[1], stride[2]],
pad: pad as 'valid' | 'same',
dataFormat: dataFormat as 'NHWC' | 'NCHW',
dilations: [dilations[1], dilations[2]],
bias: biasArg,
activation: activationFunc as tfc.fused.Activation,
preluActivationWeights: preluArg
})];
}
case 'Conv2DBackpropInput':
case 'Conv2dTranspose': {
const shape = getParamValue(
'outputShape', node, tensorMap,
context) as [number, number, number] |
[number, number, number, number];
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
return [tfc.conv2dTranspose(
getParamValue('x', node, tensorMap, context) as tfc.Tensor3D |
tfc.Tensor4D,
getParamValue('filter', node, tensorMap, context) as tfc.Tensor4D,
shape, [stride[1], stride[2]], pad as 'valid' | 'same')];
}
case 'DepthwiseConv2dNative':
case 'DepthwiseConv2d': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const dilations =
getParamValue('dilations', node, tensorMap, context) as number[];
const dataFormat =
(getParamValue('dataFormat', node, tensorMap, context) as string)
.toUpperCase();
return [tfc.depthwiseConv2d(
getParamValue('input', node, tensorMap, context) as tfc.Tensor3D |
tfc.Tensor4D,
getParamValue('filter', node, tensorMap, context) as tfc.Tensor4D,
[stride[1], stride[2]], pad as 'valid' | 'same',
dataFormat as 'NHWC' | 'NCHW', [dilations[1], dilations[2]])];
}
case 'Conv3D': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const dataFormat =
(getParamValue('dataFormat', node, tensorMap, context) as string)
.toUpperCase();
const dilations =
getParamValue('dilations', node, tensorMap, context) as number[];
return [tfc.conv3d(
getParamValue('x', node, tensorMap, context) as tfc.Tensor4D |
tfc.Tensor<tfc.Rank.R5>,
getParamValue('filter', node, tensorMap, context) as
tfc.Tensor<tfc.Rank.R5>,
[stride[1], stride[2], stride[3]], pad as 'valid' | 'same',
dataFormat as 'NDHWC' | 'NCDHW',
[dilations[1], dilations[2], dilations[3]])];
}
return [tfc.depthwiseConv2d(
getParamValue('input', node, tensorMap, context) as tfc.Tensor3D |
tfc.Tensor4D,
getParamValue('filter', node, tensorMap, context) as tfc.Tensor4D,
[stride[1], stride[2]], pad as 'valid' | 'same',
dataFormat as 'NHWC' | 'NCHW', [dilations[1], dilations[2]])];
}
case 'Conv3D': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const dataFormat =
(getParamValue('dataFormat', node, tensorMap, context) as string)
.toUpperCase();
const dilations =
getParamValue('dilations', node, tensorMap, context) as number[];
return [tfc.conv3d(
getParamValue('x', node, tensorMap, context) as tfc.Tensor4D |
tfc.Tensor<tfc.Rank.R5>,
getParamValue('filter', node, tensorMap, context) as
tfc.Tensor<tfc.Rank.R5>,
[stride[1], stride[2], stride[3]], pad as 'valid' | 'same',
dataFormat as 'NDHWC' | 'NCDHW',
[dilations[1], dilations[2], dilations[3]])];
}
case 'AvgPool': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const kernelSize =
getParamValue('kernelSize', node, tensorMap, context) as number[];
case 'AvgPool': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const kernelSize =
getParamValue('kernelSize', node, tensorMap, context) as number[];
return [tfc.avgPool(
getParamValue('x', node, tensorMap, context) as tfc.Tensor3D |
tfc.Tensor4D,
[kernelSize[1], kernelSize[2]], [stride[1], stride[2]],
pad as 'valid' | 'same')];
}
case 'MaxPool': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const kernelSize =
getParamValue('kernelSize', node, tensorMap, context) as number[];
return [tfc.avgPool(
getParamValue('x', node, tensorMap, context) as tfc.Tensor3D |
tfc.Tensor4D,
[kernelSize[1], kernelSize[2]], [stride[1], stride[2]],
pad as 'valid' | 'same')];
}
return [tfc.maxPool(
getParamValue('x', node, tensorMap, context) as tfc.Tensor3D |
tfc.Tensor4D,
[kernelSize[1], kernelSize[2]], [stride[1], stride[2]],
pad as 'valid' | 'same')];
}
case 'MaxPoolWithArgmax': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const kernelSize =
getParamValue('kernelSize', node, tensorMap, context) as number[];
const includeBatchInIndex =
getParamValue('includeBatchInIndex', node, tensorMap, context) as
boolean;
const {result, indexes} = tfc.maxPoolWithArgmax(
getParamValue('x', node, tensorMap, context) as tfc.Tensor4D,
[kernelSize[1], kernelSize[2]], [stride[1], stride[2]],
pad as 'valid' | 'same', includeBatchInIndex);
return [result, indexes];
}
case 'AvgPool3D': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const kernelSize =
getParamValue('kernelSize', node, tensorMap, context) as number[];
case 'MaxPool': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const kernelSize =
getParamValue('kernelSize', node, tensorMap, context) as number[];
return [tfc.avgPool3d(
getParamValue('x', node, tensorMap, context) as tfc.Tensor5D,
[kernelSize[1], kernelSize[2], kernelSize[3]],
[stride[1], stride[2], stride[3]], pad as 'valid' | 'same')];
}
return [tfc.maxPool(
getParamValue('x', node, tensorMap, context) as tfc.Tensor3D |
tfc.Tensor4D,
[kernelSize[1], kernelSize[2]], [stride[1], stride[2]],
pad as 'valid' | 'same')];
}
case 'MaxPool3D': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const kernelSize =
getParamValue('kernelSize', node, tensorMap, context) as number[];
case 'AvgPool3D': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const kernelSize =
getParamValue('kernelSize', node, tensorMap, context) as number[];
return [tfc.maxPool3d(
getParamValue('x', node, tensorMap, context) as tfc.Tensor5D,
[kernelSize[1], kernelSize[2], kernelSize[3]],
[stride[1], stride[2], stride[3]], pad as 'valid' | 'same')];
}
return [tfc.avgPool3d(
getParamValue('x', node, tensorMap, context) as tfc.Tensor5D,
[kernelSize[1], kernelSize[2], kernelSize[3]],
[stride[1], stride[2], stride[3]], pad as 'valid' | 'same')];
}
default:
throw TypeError(`Node type ${node.op} is not implemented`);
}
};
case 'MaxPool3D': {
const stride =
getParamValue('strides', node, tensorMap, context) as number[];
const pad = getParamValue('pad', node, tensorMap, context);
const kernelSize =
getParamValue('kernelSize', node, tensorMap, context) as number[];
return [tfc.maxPool3d(
getParamValue('x', node, tensorMap, context) as tfc.Tensor5D,
[kernelSize[1], kernelSize[2], kernelSize[3]],
[stride[1], stride[2], stride[3]], pad as 'valid' | 'same')];
}
default:
throw TypeError(`Node type ${node.op} is not implemented`);
}
};
export const CATEGORY = 'convolution';

@@ -58,2 +58,19 @@ import {OpMapper} from '../types';

{
'tfOpName': 'MaxPoolWithArgmax',
'category': 'convolution',
'inputs': [
{'start': 0, 'name': 'x', 'type': 'tensor'},
],
'attrs': [
{'tfName': 'strides', 'name': 'strides', 'type': 'number[]'},
{'tfName': 'padding', 'name': 'pad', 'type': 'string'},
{'tfName': 'ksize', 'name': 'kernelSize', 'type': 'number[]'}, {
'tfName': 'include_batch_in_index',
'name': 'includeBatchInIndex',
'type': 'bool'
},
{'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true}
]
},
{
'tfOpName': 'AvgPool3D',

@@ -60,0 +77,0 @@ 'category': 'convolution',

@@ -355,2 +355,4 @@ /**

case tensorflow.DataType.DT_INT64:
case tensorflow.DataType.DT_INT8:
case tensorflow.DataType.DT_UINT8:
return 'int32';

@@ -357,0 +359,0 @@ case tensorflow.DataType.DT_BOOL:

/** @license See the LICENSE file. */
// This code is auto-generated, do not modify this file!
const version = '1.7.1';
const version = '1.7.2';
export {version};

Sorry, the diff of this file is too big to display

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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc