UNPKG

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