UNPKG

3.78 kBTypeScriptView Raw
1/// <amd-module name="@tensorflow/tfjs-converter/dist/operations/types" />
2/**
3 * @license
4 * Copyright 2018 Google LLC. All Rights Reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * =============================================================================
17 */
18import { Tensor } from '@tensorflow/tfjs-core';
19import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter';
20import * as tensorflow from '../data/compiled_api';
21import { NamedTensorsMap } from '../data/types';
22import { ExecutionContext } from '../executor/execution_context';
23import { ResourceManager } from '../executor/resource_manager';
24export declare type ParamType = 'number' | 'string' | 'string[]' | 'number[]' | 'bool' | 'bool[]' | 'shape' | 'shape[]' | 'tensor' | 'tensors' | 'dtype' | 'dtype[]' | 'func';
25export declare type Category = 'arithmetic' | 'basic_math' | 'control' | 'convolution' | 'creation' | 'custom' | 'dynamic' | 'evaluation' | 'graph' | 'hash_table' | 'image' | 'logical' | 'matrices' | 'normalization' | 'reduction' | 'slice_join' | 'sparse' | 'spectral' | 'string' | 'transformation';
26export declare interface ParamMapper {
27 name: string;
28 type: ParamType;
29 defaultValue?: ValueType;
30 notSupported?: boolean;
31}
32export declare interface InputParamMapper extends ParamMapper {
33 start: number;
34 end?: number;
35}
36export declare interface AttrParamMapper extends ParamMapper {
37 tfName?: string;
38 tfDeprecatedName?: string;
39}
40export interface InternalOpExecutor {
41 (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, ops?: typeof tfOps): Tensor | Tensor[];
42}
43export interface InternalOpAsyncExecutor {
44 (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, resourceManager?: ResourceManager, ops?: typeof tfOps): Promise<Tensor[]>;
45}
46export declare interface OpMapper {
47 tfOpName: string;
48 category?: Category;
49 inputs?: InputParamMapper[];
50 attrs?: AttrParamMapper[];
51 outputs?: string[];
52 customExecutor?: OpExecutor;
53}
54export declare interface Node {
55 signatureKey?: string;
56 name: string;
57 op: string;
58 category: Category;
59 inputNames: string[];
60 inputs: Node[];
61 inputParams: {
62 [key: string]: InputParamValue;
63 };
64 attrParams: {
65 [key: string]: ParamValue;
66 };
67 children: Node[];
68 rawAttrs?: {
69 [k: string]: tensorflow.IAttrValue;
70 };
71 defaultOutput?: number;
72 outputs?: string[];
73}
74export declare interface Graph {
75 nodes: {
76 [key: string]: Node;
77 };
78 placeholders: Node[];
79 inputs: Node[];
80 outputs: Node[];
81 weights: Node[];
82 signature?: tensorflow.ISignatureDef;
83 functions?: {
84 [key: string]: Graph;
85 };
86 initNodes?: Node[];
87}
88export declare type ValueType = string | string[] | number | number[] | number[][] | boolean | boolean[] | Tensor | Tensor[];
89export declare interface ParamValue {
90 value?: ValueType;
91 type: ParamType;
92}
93export declare interface InputParamValue extends ParamValue {
94 inputIndexStart?: number;
95 inputIndexEnd?: number;
96}
97export interface OpExecutor {
98 (node: GraphNode): Tensor | Tensor[] | Promise<Tensor | Tensor[]>;
99}
100export interface GraphNode {
101 inputs: Tensor[];
102 attrs: {
103 [key: string]: ValueType;
104 };
105}