1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | import { Tensor } from '@tensorflow/tfjs-core';
|
19 | import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter';
|
20 | import * as tensorflow from '../data/compiled_api';
|
21 | import { NamedTensorsMap } from '../data/types';
|
22 | import { ExecutionContext } from '../executor/execution_context';
|
23 | import { ResourceManager } from '../executor/resource_manager';
|
24 | export type ParamType = 'number' | 'string' | 'string[]' | 'number[]' | 'bool' | 'bool[]' | 'shape' | 'shape[]' | 'tensor' | 'tensors' | 'dtype' | 'dtype[]' | 'func';
|
25 | export type Category = 'arithmetic' | 'basic_math' | 'control' | 'convolution' | 'creation' | 'custom' | 'dynamic' | 'evaluation' | 'graph' | 'hash_table' | 'image' | 'logical' | 'matrices' | 'normalization' | 'ragged' | 'reduction' | 'slice_join' | 'sparse' | 'spectral' | 'string' | 'transformation';
|
26 | export declare interface ParamMapper {
|
27 | name: string;
|
28 | type: ParamType;
|
29 | defaultValue?: ValueType;
|
30 | notSupported?: boolean;
|
31 | }
|
32 | export declare interface InputParamMapper extends ParamMapper {
|
33 | start: number;
|
34 | end?: number;
|
35 | }
|
36 | export declare interface AttrParamMapper extends ParamMapper {
|
37 | tfName?: string;
|
38 | tfDeprecatedName?: string;
|
39 | }
|
40 | export interface InternalOpExecutor {
|
41 | (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, ops?: typeof tfOps): Tensor | Tensor[];
|
42 | }
|
43 | export interface InternalOpAsyncExecutor {
|
44 | (node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext, resourceManager?: ResourceManager, ops?: typeof tfOps): Promise<Tensor[]>;
|
45 | }
|
46 | export declare interface OpMapper {
|
47 | tfOpName: string;
|
48 | category?: Category;
|
49 | inputs?: InputParamMapper[];
|
50 | attrs?: AttrParamMapper[];
|
51 | outputs?: string[];
|
52 | customExecutor?: OpExecutor;
|
53 | }
|
54 | export 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 | }
|
74 | export 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 | }
|
88 | export type ValueType = string | string[] | number | number[] | number[][] | boolean | boolean[] | Tensor | Tensor[];
|
89 | export declare interface ParamValue {
|
90 | value?: ValueType;
|
91 | type: ParamType;
|
92 | }
|
93 | export declare interface InputParamValue extends ParamValue {
|
94 | inputIndexStart?: number;
|
95 | inputIndexEnd?: number;
|
96 | }
|
97 | export interface OpExecutor {
|
98 | (node: GraphNode): Tensor | Tensor[] | Promise<Tensor | Tensor[]>;
|
99 | }
|
100 | export interface GraphNode {
|
101 | inputs: Tensor[];
|
102 | attrs: {
|
103 | [key: string]: ValueType;
|
104 | };
|
105 | }
|