UNPKG

5.69 kBSource Map (JSON)View Raw
1{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/operations/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @license\n * Copyright 2018 Google LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n * =============================================================================\n */\nimport {Tensor} from '@tensorflow/tfjs-core';\n\nimport * as tensorflow from '../data/compiled_api';\nimport {NamedTensorsMap} from '../data/types';\nimport {ExecutionContext} from '../executor/execution_context';\nimport {ResourceManager} from '../executor/resource_manager';\n\nexport type ParamType = 'number'|'string'|'string[]'|'number[]'|'bool'|'bool[]'|\n 'shape'|'shape[]'|'tensor'|'tensors'|'dtype'|'dtype[]'|'func';\nexport type Category = 'arithmetic'|'basic_math'|'control'|'convolution'|\n 'creation'|'custom'|'dynamic'|'evaluation'|'graph'|'hash_table'|'image'|\n 'logical'|'matrices'|'normalization'|'reduction'|'slice_join'|'sparse'|\n 'spectral'|'string'|'transformation';\n\n// For mapping input or attributes of NodeDef into TensorFlow.js op param.\nexport declare interface ParamMapper {\n // tensorflow.js name for the field, it should be in camelcase format.\n name: string;\n type: ParamType;\n defaultValue?: ValueType;\n notSupported?: boolean;\n}\n\n// For mapping the input of TensorFlow NodeDef into TensorFlow.js Op param.\nexport declare interface InputParamMapper extends ParamMapper {\n // The first number is the starting index of the param, the second number is\n // the length of the param. If the length value is positive number, it\n // represents the true length of the param. Otherwise, it represents a\n // variable length, the value is the index go backward from the end of the\n // array.\n // For example `[0, 5]`: this param is the array of input tensors starting at\n // index 0 and with the length of 5.\n // For example `[1, -1]`: this param is the array of input tensors starting at\n // index 1 and with the `inputs.length - 1`.\n // Zero-based index at where in the input array this param starts.\n // A negative index can be used, indicating an offset from the end of the\n // sequence. slice(-2) extracts the last two elements in the sequence.\n start: number;\n // Zero-based index before where in the input array the param ends. The\n // mapping is up to but not including end. For example, start = 1, end = 4\n // includes the second element through the fourth element (elements indexed 1,\n // 2, and 3). A negative index can be used, indicating an offset from the end\n // of the sequence. start = 2, end = -1 includes the third element through the\n // second-to-last element in the sequence. If end is omitted, end is set to\n // start + 1, the mapping only include the single element at start index. If\n // end is set to 0, the mapping is through the end of the input array\n // (arr.length). If end is greater than the length of the inputs, mapping\n // inncludes through to the end of the sequence (arr.length).\n end?: number;\n}\n\n// For mapping the attributes of TensorFlow NodeDef into TensorFlow.js op param.\nexport declare interface AttrParamMapper extends ParamMapper {\n // TensorFlow attribute name, this should be set if the tensorflow attribute\n // name is different form the tensorflow.js name.\n tfName?: string;\n // TensorFlow deprecated attribute name, this is used to support old models.\n tfDeprecatedName?: string;\n}\n\nexport interface InternalOpExecutor {\n (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext): Tensor\n |Tensor[];\n}\n\nexport interface InternalOpAsyncExecutor {\n (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext,\n resourceManager?: ResourceManager): Promise<Tensor[]>;\n}\n\nexport declare interface OpMapper {\n tfOpName: string;\n category?: Category;\n inputs?: InputParamMapper[];\n attrs?: AttrParamMapper[];\n outputs?: string[];\n customExecutor?: OpExecutor;\n}\n\nexport declare interface Node {\n signatureKey?: string;\n name: string;\n op: string;\n category: Category;\n inputNames: string[];\n inputs: Node[];\n inputParams: {[key: string]: InputParamValue};\n attrParams: {[key: string]: ParamValue};\n children: Node[];\n rawAttrs?: {[k: string]: tensorflow.IAttrValue};\n defaultOutput?: number;\n outputs?: string[];\n}\n\nexport declare interface Graph {\n nodes: {[key: string]: Node};\n placeholders: Node[];\n inputs: Node[];\n outputs: Node[];\n weights: Node[];\n signature?: tensorflow.ISignatureDef;\n functions?: {[key: string]: Graph};\n initNodes?: Node[];\n}\n\nexport type ValueType = string|string[]|number|number[]|number[][]|boolean|\n boolean[]|Tensor|Tensor[];\nexport declare interface ParamValue {\n value?: ValueType;\n type: ParamType;\n}\n\nexport declare interface InputParamValue extends ParamValue {\n inputIndexStart?: number;\n inputIndexEnd?: number;\n}\n\nexport interface OpExecutor {\n (node: GraphNode): Tensor|Tensor[]|Promise<Tensor|Tensor[]>;\n}\n\nexport interface GraphNode {\n inputs: Tensor[];\n attrs: {[key: string]: ValueType};\n}\n"]}
\No newline at end of file