Socket
Socket
Sign inDemoInstall

@tensorflow/tfjs-converter

Package Overview
Dependencies
Maintainers
11
Versions
152
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 0.5.2 to 0.5.3

dist/operations/executors/dynamic_executor.d.ts

9

dist/executor/frozen_model.js

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

}
if (this.executor.isControlFlowModel) {
throw new Error('The model contains control flow ops, ' +
if (this.executor.isControlFlowModel || this.executor.isDynamicShapeModel) {
throw new Error('The model contains control flow or dynamic shape ops, ' +
'please use executeAsync method');

@@ -205,4 +205,5 @@ }

case 0:
if (!this.executor.isControlFlowModel) {
throw new Error('The model does not contain control flow ops, ' +
if (!(this.executor.isControlFlowModel &&
this.executor.isDynamicShapeModel)) {
throw new Error('The model does not contain control flow or dynamic shape ops, ' +
'please use execute method for better performance.');

@@ -209,0 +210,0 @@ }

@@ -17,2 +17,3 @@ import { NamedTensorMap, NamedTensorsMap, TensorInfo } from '../data/types';

readonly isControlFlowModel: boolean;
readonly isDynamicShapeModel: boolean;
private compile();

@@ -19,0 +20,0 @@ execute(inputs: NamedTensorsMap, outputs?: string | string[]): NamedTensorMap;

@@ -122,4 +122,11 @@ "use strict";

});
Object.defineProperty(GraphExecutor.prototype, "isDynamicShapeModel", {
get: function () {
return this.graph.withDynamicShape;
},
enumerable: true,
configurable: true
});
GraphExecutor.prototype.compile = function () {
if (this.graph.withControlFlow) {
if (this.graph.withControlFlow || this.graph.withDynamicShape) {
return;

@@ -126,0 +133,0 @@ }

@@ -24,2 +24,12 @@ "use strict";

}
case 'spaceToBatchND': {
var blockShape = utils_1.getParamValue('blockShape', node, tensorMap, context);
var paddings = utils_1.split(utils_1.getParamValue('paddings', node, tensorMap, context), 2);
return [tfc.spaceToBatchND(utils_1.getParamValue('x', node, tensorMap, context), blockShape, paddings)];
}
case 'batchToSpaceND': {
var blockShape = utils_1.getParamValue('blockShape', node, tensorMap, context);
var crops = utils_1.split(utils_1.getParamValue('crops', node, tensorMap, context), 2);
return [tfc.batchToSpaceND(utils_1.getParamValue('x', node, tensorMap, context), blockShape, crops)];
}
default:

@@ -26,0 +36,0 @@ throw TypeError("Node type " + node.op + " is not implemented");

@@ -57,3 +57,62 @@ [

]
},
{
"tfOpName": "NonMaxSuppressionV2",
"dlOpName": "nonMaxSuppression",
"category": "image",
"params": [
{
"tfInputIndex": 0,
"dlParamName": "boxes",
"type": "tensor"
},
{
"tfInputIndex": 1,
"dlParamName": "scores",
"type": "tensor"
},
{
"tfInputIndex": 2,
"dlParamName": "maxOutputSize",
"type": "number"
},
{
"tfInputIndex": 3,
"dlParamName": "iouThreshold",
"type": "number"
}
]
},
{
"tfOpName": "NonMaxSuppressionV3",
"dlOpName": "nonMaxSuppression",
"category": "image",
"params": [
{
"tfInputIndex": 0,
"dlParamName": "boxes",
"type": "tensor"
},
{
"tfInputIndex": 1,
"dlParamName": "scores",
"type": "tensor"
},
{
"tfInputIndex": 2,
"dlParamName": "maxOutputSize",
"type": "number"
},
{
"tfInputIndex": 3,
"dlParamName": "iouThreshold",
"type": "number"
},
{
"tfInputIndex": 4,
"dlParamName": "scoreThreshold",
"type": "number"
}
]
}
]

@@ -118,3 +118,45 @@ [

]
},
{
"tfOpName": "SpaceToBatchND",
"dlOpName": "spaceToBatchND",
"category": "transformation",
"params": [{
"tfInputIndex": 0,
"dlParamName": "x",
"type": "tensor"
},
{
"tfInputIndex": 1,
"dlParamName": "blockShape",
"type": "number[]"
},
{
"tfInputIndex": 2,
"dlParamName": "paddings",
"type": "number[]"
}
]
},
{
"tfOpName": "BatchToSpaceND",
"dlOpName": "batchToSpaceND",
"category": "transformation",
"params": [{
"tfInputIndex": 0,
"dlParamName": "x",
"type": "tensor"
},
{
"tfInputIndex": 1,
"dlParamName": "blockShape",
"type": "number[]"
},
{
"tfInputIndex": 2,
"dlParamName": "crops",
"type": "number[]"
}
]
}
]

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

var creation = require("./executors/creation_executor");
var dynamic = require("./executors/dynamic_executor");
var evaluation = require("./executors/evaluation_executor");
var graph = require("./executors/graph_executor");

@@ -29,2 +31,6 @@ var image = require("./executors/image_executor");

return creation.executeOp(node, tensorMap, context);
case 'dynamic':
return dynamic.executeOp(node, tensorMap, context);
case 'evaluation':
return evaluation.executeOp(node, tensorMap, context);
case 'image':

@@ -31,0 +37,0 @@ return image.executeOp(node, tensorMap, context);

@@ -9,2 +9,3 @@ import { tensorflow } from '../data/compiled_api';

private isControlFlow(node);
private isDynamicShape(node);
transformGraph(graph: tensorflow.IGraphDef): Graph;

@@ -11,0 +12,0 @@ private mapNode(node);

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

var creation = require("./op_list/creation.json");
var dynamic = require("./op_list/dynamic.json");
var evaluation = require("./op_list/evaluation.json");
var graph = require("./op_list/graph.json");

@@ -20,7 +22,9 @@ var image = require("./op_list/image.json");

var CONTROL_FLOW_OPS = ['Switch', 'Merge', 'Enter', 'Exit', 'NextIteration'];
var DYNAMIC_SHAPE_OPS = ['NonMaxSuppressionV2', 'NonMaxSuppressionV3', 'Where'];
var OperationMapper = (function () {
function OperationMapper() {
var ops = [
arithmetic, basicMath, control, convolution, creation, logical, image,
graph, matrices, normalization, reduction, sliceJoin, transformation
arithmetic, basicMath, control, convolution, creation, dynamic,
evaluation, logical, image, graph, matrices, normalization, reduction,
sliceJoin, transformation
];

@@ -43,2 +47,5 @@ var mappersJson = [].concat.apply([], ops.map(function (op) { return op.default ? op.default : op; }));

};
OperationMapper.prototype.isDynamicShape = function (node) {
return DYNAMIC_SHAPE_OPS.some(function (op) { return op === node.op; });
};
OperationMapper.prototype.transformGraph = function (graph) {

@@ -48,2 +55,3 @@ var _this = this;

var withControlFlow = false;
var withDynamicShape = false;
var placeholders = [];

@@ -54,2 +62,4 @@ var nodes = tfNodes.reduce(function (map, node) {

withControlFlow = true;
if (_this.isDynamicShape(node))
withDynamicShape = true;
if (node.op === 'Placeholder')

@@ -76,3 +86,10 @@ placeholders.push(map[node.name]);

});
return { nodes: nodes, inputs: inputs, outputs: outputs, placeholders: placeholders, withControlFlow: withControlFlow };
return {
nodes: nodes,
inputs: inputs,
outputs: outputs,
placeholders: placeholders,
withControlFlow: withControlFlow,
withDynamicShape: withDynamicShape
};
};

@@ -189,3 +206,5 @@ OperationMapper.prototype.mapNode = function (node) {

if (param && param.shape) {
return param.shape.dim.map(function (dim) { return dim.size; });
return param.shape.dim.map(function (dim) {
return (typeof dim.size === 'number') ? dim.size : dim.size['toInt']();
});
}

@@ -192,0 +211,0 @@ return def;

import { Tensor } from '@tensorflow/tfjs-core';
export declare type ParamTypes = 'number' | 'string' | 'number[]' | 'bool' | 'shape' | 'tensor' | 'tensors' | 'dtype';
export declare type Category = 'arithmetic' | 'basic_math' | 'control' | 'convolution' | 'image' | 'creation' | 'graph' | 'logical' | 'matrices' | 'normalization' | 'reduction' | 'slice_join' | 'transformation';
export declare type Category = 'arithmetic' | 'basic_math' | 'control' | 'convolution' | 'dynamic' | 'evaluation' | 'image' | 'creation' | 'graph' | 'logical' | 'matrices' | 'normalization' | 'reduction' | 'slice_join' | 'transformation';
export interface ParamMapper {

@@ -41,4 +41,5 @@ tfParamName?: string;

withControlFlow: boolean;
withDynamicShape: boolean;
}
export declare type ValueType = string | string[] | number | number[] | boolean | boolean[] | Tensor | Tensor[];
export declare type ValueType = string | string[] | number | number[] | number[][] | boolean | boolean[] | Tensor | Tensor[];
export interface ParamValue {

@@ -45,0 +46,0 @@ value?: ValueType;

@@ -1,2 +0,2 @@

declare const version = "0.5.2";
declare const version = "0.5.3";
export { version };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var version = '0.5.2';
var version = '0.5.3';
exports.version = version;
//# sourceMappingURL=version.js.map
{
"name": "@tensorflow/tfjs-converter",
"version": "0.5.2",
"version": "0.5.3",
"description": "Tensorflow model converter for javascript",

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

"peerDependencies": {
"@tensorflow/tfjs-core": "~0.12.4"
"@tensorflow/tfjs-core": "~0.12.5"
},
"devDependencies": {
"@tensorflow/tfjs-core": "~0.12.4",
"@tensorflow/tfjs-core": "~0.12.5",
"@types/jasmine": "~2.8.6",

@@ -23,0 +23,0 @@ "@types/node-fetch": "1.6.9",

@@ -92,2 +92,3 @@ [![Build Status](https://travis-ci.org/tensorflow/tfjs-converter.svg?branch=master)](https://travis-ci.org/tensorflow/tfjs-converter)

|`--signature_name` | Only applicable to TensorFlow Hub module conversion, signature to load. Defaults to `default`. See https://www.tensorflow.org/hub/common_signatures/.|
|`--strip_debug_ops` | Strips out TensorFlow debug operations `Print`, `Assert`, `CheckNumerics`. Defaults to `True`.|

@@ -94,0 +95,0 @@

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

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

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

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