UNPKG

@tensorflow/tfjs-converter

Version:

Tensorflow model converter for javascript

1,491 lines (1,478 loc) 1.38 MB
/** * @license * Copyright 2024 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tensorflow/tfjs-core')) : typeof define === 'function' && define.amd ? define(['exports', '@tensorflow/tfjs-core'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.tf = global.tf || {}, global.tf)); })(this, (function (exports, tfc) { 'use strict'; function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n.default = e; return n; } function _mergeNamespaces(n, m) { m.forEach(function (e) { e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { if (k !== 'default' && !(k in n)) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); }); return n; } var tfc__namespace = /*#__PURE__*/_interopNamespaceDefault(tfc); /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ var ENV$1 = tfc.env(); /** Whether to keep intermediate tensors. */ ENV$1.registerFlag('KEEP_INTERMEDIATE_TENSORS', function () { return false; }, function (debugValue) { if (debugValue) { console.warn('Keep intermediate tensors is ON. This will print the values of all ' + 'intermediate tensors during model inference. Not all models ' + 'support this mode. For details, check e2e/benchmarks/ ' + 'model_config.js. This significantly impacts performance.'); } }); /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } function __awaiter(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()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function () { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); } /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ /** DataType enum. */ var DataType; (function (DataType) { // These properties must be quoted since they are used by parseDtypeParam // in tfjs-converter/src/operations/operation_mapper.ts to look up dtypes // by string name. If they are not quoted, Closure will mangle their names. // Not a legal value for DataType. Used to indicate a DataType field // has not been set. DataType[DataType["DT_INVALID"] = 0] = "DT_INVALID"; // Data types that all computation devices are expected to be // capable to support. DataType[DataType["DT_FLOAT"] = 1] = "DT_FLOAT"; DataType[DataType["DT_DOUBLE"] = 2] = "DT_DOUBLE"; DataType[DataType["DT_INT32"] = 3] = "DT_INT32"; DataType[DataType["DT_UINT8"] = 4] = "DT_UINT8"; DataType[DataType["DT_INT16"] = 5] = "DT_INT16"; DataType[DataType["DT_INT8"] = 6] = "DT_INT8"; DataType[DataType["DT_STRING"] = 7] = "DT_STRING"; DataType[DataType["DT_COMPLEX64"] = 8] = "DT_COMPLEX64"; DataType[DataType["DT_INT64"] = 9] = "DT_INT64"; DataType[DataType["DT_BOOL"] = 10] = "DT_BOOL"; DataType[DataType["DT_QINT8"] = 11] = "DT_QINT8"; DataType[DataType["DT_QUINT8"] = 12] = "DT_QUINT8"; DataType[DataType["DT_QINT32"] = 13] = "DT_QINT32"; DataType[DataType["DT_BFLOAT16"] = 14] = "DT_BFLOAT16"; DataType[DataType["DT_QINT16"] = 15] = "DT_QINT16"; DataType[DataType["DT_QUINT16"] = 16] = "DT_QUINT16"; DataType[DataType["DT_UINT16"] = 17] = "DT_UINT16"; DataType[DataType["DT_COMPLEX128"] = 18] = "DT_COMPLEX128"; DataType[DataType["DT_HALF"] = 19] = "DT_HALF"; DataType[DataType["DT_RESOURCE"] = 20] = "DT_RESOURCE"; DataType[DataType["DT_VARIANT"] = 21] = "DT_VARIANT"; DataType[DataType["DT_UINT32"] = 22] = "DT_UINT32"; DataType[DataType["DT_UINT64"] = 23] = "DT_UINT64"; // Do not use! These are only for parameters. Every enum above // should have a corresponding value below (verified by types_test). DataType[DataType["DT_FLOAT_REF"] = 101] = "DT_FLOAT_REF"; DataType[DataType["DT_DOUBLE_REF"] = 102] = "DT_DOUBLE_REF"; DataType[DataType["DT_INT32_REF"] = 103] = "DT_INT32_REF"; DataType[DataType["DT_UINT8_REF"] = 104] = "DT_UINT8_REF"; DataType[DataType["DT_INT16_REF"] = 105] = "DT_INT16_REF"; DataType[DataType["DT_INT8_REF"] = 106] = "DT_INT8_REF"; DataType[DataType["DT_STRING_REF"] = 107] = "DT_STRING_REF"; DataType[DataType["DT_COMPLEX64_REF"] = 108] = "DT_COMPLEX64_REF"; DataType[DataType["DT_INT64_REF"] = 109] = "DT_INT64_REF"; DataType[DataType["DT_BOOL_REF"] = 110] = "DT_BOOL_REF"; DataType[DataType["DT_QINT8_REF"] = 111] = "DT_QINT8_REF"; DataType[DataType["DT_QUINT8_REF"] = 112] = "DT_QUINT8_REF"; DataType[DataType["DT_QINT32_REF"] = 113] = "DT_QINT32_REF"; DataType[DataType["DT_BFLOAT16_REF"] = 114] = "DT_BFLOAT16_REF"; DataType[DataType["DT_QINT16_REF"] = 115] = "DT_QINT16_REF"; DataType[DataType["DT_QUINT16_REF"] = 116] = "DT_QUINT16_REF"; DataType[DataType["DT_UINT16_REF"] = 117] = "DT_UINT16_REF"; DataType[DataType["DT_COMPLEX128_REF"] = 118] = "DT_COMPLEX128_REF"; DataType[DataType["DT_HALF_REF"] = 119] = "DT_HALF_REF"; DataType[DataType["DT_RESOURCE_REF"] = 120] = "DT_RESOURCE_REF"; DataType[DataType["DT_VARIANT_REF"] = 121] = "DT_VARIANT_REF"; DataType[DataType["DT_UINT32_REF"] = 122] = "DT_UINT32_REF"; DataType[DataType["DT_UINT64_REF"] = 123] = "DT_UINT64_REF"; })(DataType || (DataType = {})); var SaverDef; (function (SaverDef) { (function (CheckpointFormatVersion) { CheckpointFormatVersion[CheckpointFormatVersion["LEGACY"] = 0] = "LEGACY"; CheckpointFormatVersion[CheckpointFormatVersion["V1"] = 1] = "V1"; CheckpointFormatVersion[CheckpointFormatVersion["V2"] = 2] = "V2"; })(SaverDef.CheckpointFormatVersion || (SaverDef.CheckpointFormatVersion = {})); })(SaverDef || (SaverDef = {})); /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ var CUSTOM_OPS = {}; /** * Register an Op for graph model executor. This allows you to register * TensorFlow custom op or override existing op. * * Here is an example of registering a new MatMul Op. * ```js * const customMatmul = (node) => * tf.matMul( * node.inputs[0], node.inputs[1], * node.attrs['transpose_a'], node.attrs['transpose_b']); * * tf.registerOp('MatMul', customMatmul); * ``` * The inputs and attrs of the node object are based on the TensorFlow op * registry. * * @param name The Tensorflow Op name. * @param opFunc An op function which is called with the current graph node * during execution and needs to return a tensor or a list of tensors. The node * has the following attributes: * - attr: A map from attribute name to its value * - inputs: A list of input tensors * * @doc {heading: 'Models', subheading: 'Op Registry'} */ function registerOp(name, opFunc) { var opMapper = { tfOpName: name, category: 'custom', inputs: [], attrs: [], customExecutor: opFunc }; CUSTOM_OPS[name] = opMapper; } /** * Retrieve the OpMapper object for the registered op. * * @param name The Tensorflow Op name. * * @doc {heading: 'Models', subheading: 'Op Registry'} */ function getRegisteredOp(name) { return CUSTOM_OPS[name]; } /** * Deregister the Op for graph model executor. * * @param name The Tensorflow Op name. * * @doc {heading: 'Models', subheading: 'Op Registry'} */ function deregisterOp(name) { delete CUSTOM_OPS[name]; } function getParamValue(paramName, node, tensorMap, context, resourceManager) { var inputParam = node.inputParams[paramName]; if (inputParam && inputParam.inputIndexStart !== undefined) { var start = inputParam.inputIndexStart; var end = inputParam.inputIndexEnd === 0 ? undefined : (inputParam.inputIndexEnd === undefined ? start + 1 : inputParam.inputIndexEnd); var shiftedStart = start < 0 ? node.inputNames.length + start : start; if (inputParam.type === 'tensor') { return getTensor(node.inputNames[shiftedStart], tensorMap, context, resourceManager); } if (inputParam.type === 'tensors') { // TODO(mattSoulanille): This filters out NoOp nodes during execution, but // these should really never be in the execution graph in the first place. // They're necessary for ordering the graph, but should not be visible // during execution. Perhaps have different sets of children, one for // control dependencies and another for real dependencies. var inputs_1 = node.inputs.slice(start, end); var inputNames = node.inputNames.slice(start, end) .filter(function (_name, index) { var _a; return ((_a = inputs_1[index]) === null || _a === void 0 ? void 0 : _a.op) !== 'NoOp'; }); return inputNames.map(function (name) { return getTensor(name, tensorMap, context, resourceManager); }); } var tensor = getTensor(node.inputNames[shiftedStart], tensorMap, context, resourceManager); var data = tensor.dataSync(); return inputParam.type === 'number' ? data[0] : tfc.util.toNestedArray(tensor.shape, data); } var attrParam = node.attrParams[paramName]; return attrParam && attrParam.value; } /** * Retrieve the tensor from tensorsMap based on input name. * @param name Node input name * @param tensorsMap Tensors map keyed by the node * @param context contains tensors and information for running the current node. * @param resourceManager Optional. Contains global resources of the model. */ function getTensor(name, tensorsMap, context, resourceManager) { var _b = __read(parseNodeName(name, context), 2), nodeName = _b[0], index = _b[1]; if (resourceManager != null) { var tensor = resourceManager.getHashTableHandleByName(nodeName); if (tensor != null) { return tensor; } } var contextId = context.currentContextIds.find(function (contextId) { return !!tensorsMap[getNodeNameWithContextId(nodeName, contextId)]; }); return contextId !== undefined ? tensorsMap[getNodeNameWithContextId(nodeName, contextId)][index] : undefined; } /** * Retrieve the tensors based on input name for current context. * @param name Node input name * @param tensorsMap Tensors map keyed by the node */ function getTensorsForCurrentContext(name, tensorsMap, context) { return tensorsMap[getNodeNameWithContextId(name, context.currentContextId)]; } /** * Returns the node name, outputName and index from the Node input name. * @param inputName The input name of the node, in format of * node_name:output_index, i.e. MatMul:0, if the output_index is not set, it is * default to 0. * If the input name contains output name i.e. StringSplit:indices:0, it will * return ['StringSplit', 0, 'indices']. */ function getNodeNameAndIndex(inputName, context) { var _b = __read(parseNodeName(inputName, context), 3), nodeName = _b[0], index = _b[1], outputName = _b[2]; return [ getNodeNameWithContextId(nodeName, context && context.currentContextId), index, outputName ]; } function getNodeNameWithContextId(name, contextId) { return !!contextId ? "".concat(name, "-").concat(contextId) : name; } function parseNodeName(name, context) { if (name === '') { return ['', 0, undefined]; } var isCacheEnabled = context != null && context.parseNodeNameCache != null; if (isCacheEnabled) { var cachedResult = context.parseNodeNameCache.get(name); if (cachedResult != null) { return cachedResult; } } var parts = name.split(':'); var result; if (parts.length === 1) { result = [name, 0, undefined]; } else { var nodeName = parts[0]; var outputName = parts.length === 3 ? parts[1] : undefined; var index = Number(parts[parts.length - 1]); result = [nodeName, index, outputName]; } if (isCacheEnabled) { context.parseNodeNameCache.set(name, result); } return result; } function getPadding(node, tensorMap, context) { var pad = getParamValue('pad', node, tensorMap, context); if (pad === 'explicit') { // This is 1d array, we need to convert it to 2d array pad = getParamValue('explicitPaddings', node, tensorMap, context); var explicitPadding = [[0, 0], [0, 0], [0, 0], [0, 0]]; for (var i = 0; i < 4; i++) { explicitPadding[i][0] = pad[i * 2]; explicitPadding[i][1] = pad[i * 2 + 1]; } return explicitPadding; } return pad; } /** * Reuse the tensor if it is marked as keep, otherwise clone the tensor to * avoid disposal. This is important for TensorArray and TensorList ops, since * internally they use a tensor as the id for TensorArray and TensorList, and * to simplify lookup, they also use Tensor.id as the key to the internal map. * These id tensors have been marked as kept in the backend, we need avoid clone * them in order to create new Tensor.id. * @param tensor */ function cloneTensor(tensor) { return tensor.kept ? tensor : tfc.clone(tensor); } /** * @license * Copyright 2023 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ var json$i = [ { 'tfOpName': 'Add', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'AddV2', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'AddN', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'end': 0, 'name': 'tensors', 'type': 'tensors' } ] }, { 'tfOpName': 'BiasAdd', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true }, { 'tfName': 'data_format', 'name': 'dataFormat', 'type': 'string', 'notSupported': true } ] }, { 'tfOpName': 'Sub', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'RealDiv', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Div', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'DivNoNan', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'FloorDiv', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Mul', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Maximum', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Minimum', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Pow', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'SquaredDifference', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Mod', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'FloorMod', 'category': 'arithmetic', 'inputs': [ { 'start': 0, 'name': 'a', 'type': 'tensor' }, { 'start': 1, 'name': 'b', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] } ]; var arithmetic = { __proto__: null, json: json$i }; /** * @license * Copyright 2023 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ var json$h = [ { 'tfOpName': 'Abs', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Acos', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Asin', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Atan', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Atan2', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' }, { 'start': 1, 'name': 'y', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Ceil', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'ClipByValue', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' }, { 'start': 1, 'name': 'clipValueMin', 'type': 'number' }, { 'start': 2, 'name': 'clipValueMax', 'type': 'number' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Complex', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'real', 'type': 'tensor' }, { 'start': 1, 'name': 'imag', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'ComplexAbs', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Cos', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Cosh', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Elu', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Exp', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Floor', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Log', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Imag', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true }, { 'tfName': 'Tout', 'name': 'outputType', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Neg', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Real', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true }, { 'tfName': 'Tout', 'name': 'outputType', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Prelu', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' }, { 'start': 1, 'name': 'alpha', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Relu', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Relu6', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Selu', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Sigmoid', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Sin', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Sinh', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupported': true } ] }, { 'tfOpName': 'Sqrt', 'category': 'basic_math', 'inputs': [ { 'start': 0, 'name': 'x', 'type': 'tensor' } ], 'attrs': [ { 'tfName': 'T', 'name': 'dtype', 'type': 'dtype', 'notSupporte