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 | */
|
17 | import * as tfc from '@tensorflow/tfjs-core';
|
18 | import { NodeValueImpl } from './custom_op/node_value_impl';
|
19 | import { getRegisteredOp } from './custom_op/register';
|
20 | import * as arithmetic from './executors/arithmetic_executor';
|
21 | import * as basicMath from './executors/basic_math_executor';
|
22 | import * as control from './executors/control_executor';
|
23 | import * as convolution from './executors/convolution_executor';
|
24 | import * as creation from './executors/creation_executor';
|
25 | import * as dynamic from './executors/dynamic_executor';
|
26 | import * as evaluation from './executors/evaluation_executor';
|
27 | import * as graph from './executors/graph_executor';
|
28 | import * as hashTable from './executors/hash_table_executor';
|
29 | import * as image from './executors/image_executor';
|
30 | import * as logical from './executors/logical_executor';
|
31 | import * as matrices from './executors/matrices_executor';
|
32 | import * as normalization from './executors/normalization_executor';
|
33 | import * as ragged from './executors/ragged_executor';
|
34 | import * as reduction from './executors/reduction_executor';
|
35 | import * as sliceJoin from './executors/slice_join_executor';
|
36 | import * as sparse from './executors/sparse_executor';
|
37 | import * as spectral from './executors/spectral_executor';
|
38 | import * as string from './executors/string_executor';
|
39 | import * as transformation from './executors/transformation_executor';
|
40 | /**
|
41 | * Executes the op defined by the node object.
|
42 | * @param node
|
43 | * @param tensorMap contains tensors for executed nodes and weights
|
44 | * @param context contains tensors and information for running the current node.
|
45 | * @param resourceManager Optional. Contains global resources of the model.
|
46 | */
|
47 | export function executeOp(node, tensorMap, context, resourceManager, tidy = tfc.tidy) {
|
48 | const value = ((node, tensorMap, context) => {
|
49 | switch (node.category) {
|
50 | case 'arithmetic':
|
51 | return tidy(() => arithmetic.executeOp(node, tensorMap, context));
|
52 | case 'basic_math':
|
53 | return tidy(() => basicMath.executeOp(node, tensorMap, context));
|
54 | case 'control':
|
55 | return control.executeOp(node, tensorMap, context);
|
56 | case 'convolution':
|
57 | return tidy(() => convolution.executeOp(node, tensorMap, context));
|
58 | case 'creation':
|
59 | return tidy(() => creation.executeOp(node, tensorMap, context));
|
60 | case 'dynamic':
|
61 | return dynamic.executeOp(node, tensorMap, context);
|
62 | case 'evaluation':
|
63 | return tidy(() => evaluation.executeOp(node, tensorMap, context));
|
64 | case 'image':
|
65 | return tidy(() => image.executeOp(node, tensorMap, context));
|
66 | case 'graph':
|
67 | return tidy(() => graph.executeOp(node, tensorMap, context));
|
68 | case 'logical':
|
69 | return tidy(() => logical.executeOp(node, tensorMap, context));
|
70 | case 'matrices':
|
71 | return tidy(() => matrices.executeOp(node, tensorMap, context));
|
72 | case 'normalization':
|
73 | return tidy(() => normalization.executeOp(node, tensorMap, context));
|
74 | case 'ragged':
|
75 | return tidy(() => ragged.executeOp(node, tensorMap, context));
|
76 | case 'reduction':
|
77 | return tidy(() => reduction.executeOp(node, tensorMap, context));
|
78 | case 'slice_join':
|
79 | return tidy(() => sliceJoin.executeOp(node, tensorMap, context));
|
80 | case 'sparse':
|
81 | return tidy(() => sparse.executeOp(node, tensorMap, context));
|
82 | case 'spectral':
|
83 | return tidy(() => spectral.executeOp(node, tensorMap, context));
|
84 | case 'string':
|
85 | return tidy(() => string.executeOp(node, tensorMap, context));
|
86 | case 'transformation':
|
87 | return tidy(() => transformation.executeOp(node, tensorMap, context));
|
88 | case 'hash_table':
|
89 | return hashTable.executeOp(node, tensorMap, context, resourceManager);
|
90 | case 'custom':
|
91 | const opMapper = getRegisteredOp(node.op);
|
92 | if (opMapper && opMapper.customExecutor) {
|
93 | return opMapper.customExecutor(new NodeValueImpl(node, tensorMap, context));
|
94 | }
|
95 | else {
|
96 | throw TypeError(`Custom op ${node.op} is not registered.`);
|
97 | }
|
98 | default:
|
99 | throw TypeError(`Unknown op '${node.op}'. File an issue at ` +
|
100 | `https://github.com/tensorflow/tfjs/issues so we can add it` +
|
101 | `, or register a custom execution with tf.registerOp()`);
|
102 | }
|
103 | })(node, tensorMap, context);
|
104 | if (tfc.util.isPromise(value)) {
|
105 | return value.then((data) => [].concat(data));
|
106 | }
|
107 | return [].concat(value);
|
108 | }
|
109 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3BlcmF0aW9uX2V4ZWN1dG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vdGZqcy1jb252ZXJ0ZXIvc3JjL29wZXJhdGlvbnMvb3BlcmF0aW9uX2V4ZWN1dG9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRztBQUVILE9BQU8sS0FBSyxHQUFHLE1BQU0sdUJBQXVCLENBQUM7QUFNN0MsT0FBTyxFQUFDLGFBQWEsRUFBQyxNQUFNLDZCQUE2QixDQUFDO0FBQzFELE9BQU8sRUFBQyxlQUFlLEVBQUMsTUFBTSxzQkFBc0IsQ0FBQztBQUNyRCxPQUFPLEtBQUssVUFBVSxNQUFNLGlDQUFpQyxDQUFDO0FBQzlELE9BQU8sS0FBSyxTQUFTLE1BQU0saUNBQWlDLENBQUM7QUFDN0QsT0FBTyxLQUFLLE9BQU8sTUFBTSw4QkFBOEIsQ0FBQztBQUN4RCxPQUFPLEtBQUssV0FBVyxNQUFNLGtDQUFrQyxDQUFDO0FBQ2hFLE9BQU8sS0FBSyxRQUFRLE1BQU0sK0JBQStCLENBQUM7QUFDMUQsT0FBTyxLQUFLLE9BQU8sTUFBTSw4QkFBOEIsQ0FBQztBQUN4RCxPQUFPLEtB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XN0b21FeGVjdXRvcikge1xuICAgICAgICAgICAgICByZXR1cm4gb3BNYXBwZXIuY3VzdG9tRXhlY3V0b3IoXG4gICAgICAgICAgICAgICAgICBuZXcgTm9kZVZhbHVlSW1wbChub2RlLCB0ZW5zb3JNYXAsIGNvbnRleHQpKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcihgQ3VzdG9tIG9wICR7bm9kZS5vcH0gaXMgbm90IHJlZ2lzdGVyZWQuYCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcihcbiAgICAgICAgICAgICAgICBgVW5rbm93biBvcCAnJHtub2RlLm9wfScuIEZpbGUgYW4gaXNzdWUgYXQgYCArXG4gICAgICAgICAgICAgICAgYGh0dHBzOi8vZ2l0aHViLmNvbS90ZW5zb3JmbG93L3RmanMvaXNzdWVzIHNvIHdlIGNhbiBhZGQgaXRgICtcbiAgICAgICAgICAgICAgICBgLCBvciByZWdpc3RlciBhIGN1c3RvbSBleGVjdXRpb24gd2l0aCB0Zi5yZWdpc3Rlck9wKClgKTtcbiAgICAgICAgfVxuICAgICAgfSkobm9kZSwgdGVuc29yTWFwLCBjb250ZXh0KTtcbiAgaWYgKHRmYy51dGlsLmlzUHJvbWlzZSh2YWx1ZSkpIHtcbiAgICByZXR1cm4gdmFsdWUudGhlbigoZGF0YSkgPT4gW10uY29uY2F0KGRhdGEpKTtcbiAgfVxuICByZXR1cm4gW10uY29uY2F0KHZhbHVlKTtcbn1cbiJdfQ== |
\ | No newline at end of file |