UNPKG

2.19 kBTypeScriptView Raw
1/// <amd-module name="@tensorflow/tfjs-converter/dist/executor/resource_manager" />
2/**
3 * @license
4 * Copyright 2020 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 { HashTableMap, NamedTensorMap } from '../data/types';
19import { HashTable } from './hash_table';
20/**
21 * Contains global resources of a model.
22 */
23export declare class ResourceManager {
24 readonly hashTableNameToHandle: NamedTensorMap;
25 readonly hashTableMap: HashTableMap;
26 constructor(hashTableNameToHandle?: NamedTensorMap, hashTableMap?: HashTableMap);
27 /**
28 * Register a `HashTable` in the resource manager.
29 *
30 * The `HashTable` can be retrieved by `resourceManager.getHashTableById`,
31 * where id is the table handle tensor's id.
32 *
33 * @param name Op node name that creates the `HashTable`.
34 * @param hashTable The `HashTable` to be added to resource manager.
35 */
36 addHashTable(name: string, hashTable: HashTable): void;
37 /**
38 * Get the table handle by node name.
39 * @param name Op node name that creates the `HashTable`. This name is also
40 * used in the inputs list of lookup and import `HashTable` ops.
41 */
42 getHashTableHandleByName(name: string): import("@tensorflow/tfjs-core").Tensor<import("@tensorflow/tfjs-core").Rank>;
43 /**
44 * Get the actual `HashTable` by its handle tensor's id.
45 * @param id The id of the handle tensor.
46 */
47 getHashTableById(id: number): HashTable;
48 /**
49 * Dispose `ResourceManager`, including its hashTables and tensors in them.
50 */
51 dispose(): void;
52}