UNPKG

3.67 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 tensorflow from '../data/compiled_api';
20import { NamedTensorsMap } from '../data/types';
21import { ExecutionContext } from '../executor/execution_context';
22import { ResourceManager } from '../executor/resource_manager';
23export declare type ParamType = 'number' | 'string' | 'string[]' | 'number[]' | 'bool' | 'bool[]' | 'shape' | 'shape[]' | 'tensor' | 'tensors' | 'dtype' | 'dtype[]' | 'func';
24export 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';
25export declare interface ParamMapper {
26 name: string;
27 type: ParamType;
28 defaultValue?: ValueType;
29 notSupported?: boolean;
30}
31export declare interface InputParamMapper extends ParamMapper {
32 start: number;
33 end?: number;
34}
35export declare interface AttrParamMapper extends ParamMapper {
36 tfName?: string;
37 tfDeprecatedName?: string;
38}
39export interface InternalOpExecutor {
40 (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext): Tensor | Tensor[];
41}
42export interface InternalOpAsyncExecutor {
43 (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, resourceManager?: ResourceManager): Promise<Tensor[]>;
44}
45export declare interface OpMapper {
46 tfOpName: string;
47 category?: Category;
48 inputs?: InputParamMapper[];
49 attrs?: AttrParamMapper[];
50 outputs?: string[];
51 customExecutor?: OpExecutor;
52}
53export declare interface Node {
54 signatureKey?: string;
55 name: string;
56 op: string;
57 category: Category;
58 inputNames: string[];
59 inputs: Node[];
60 inputParams: {
61 [key: string]: InputParamValue;
62 };
63 attrParams: {
64 [key: string]: ParamValue;
65 };
66 children: Node[];
67 rawAttrs?: {
68 [k: string]: tensorflow.IAttrValue;
69 };
70 defaultOutput?: number;
71 outputs?: string[];
72}
73export declare interface Graph {
74 nodes: {
75 [key: string]: Node;
76 };
77 placeholders: Node[];
78 inputs: Node[];
79 outputs: Node[];
80 weights: Node[];
81 signature?: tensorflow.ISignatureDef;
82 functions?: {
83 [key: string]: Graph;
84 };
85 initNodes?: Node[];
86}
87export declare type ValueType = string | string[] | number | number[] | number[][] | boolean | boolean[] | Tensor | Tensor[];
88export declare interface ParamValue {
89 value?: ValueType;
90 type: ParamType;
91}
92export declare interface InputParamValue extends ParamValue {
93 inputIndexStart?: number;
94 inputIndexEnd?: number;
95}
96export interface OpExecutor {
97 (node: GraphNode): Tensor | Tensor[] | Promise<Tensor | Tensor[]>;
98}
99export interface GraphNode {
100 inputs: Tensor[];
101 attrs: {
102 [key: string]: ValueType;
103 };
104}