• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 #ifndef TENSORFLOW_LITE_EXPERIMENTAL_RESOURCE_RESOURCE_BASE_H_
16 #define TENSORFLOW_LITE_EXPERIMENTAL_RESOURCE_RESOURCE_BASE_H_
17 
18 #include <cstdint>
19 #include <map>
20 #include <memory>
21 #include <string>
22 #include <unordered_map>
23 #include <utility>
24 
25 namespace tflite {
26 namespace resource {
27 
28 // ResourceBase is an abstract base class for resources.
29 /// WARNING: Experimental interface, subject to change.
30 class ResourceBase {
31  public:
ResourceBase()32   explicit ResourceBase() {}
~ResourceBase()33   virtual ~ResourceBase() {}
34 
35   // Returns true if it is initialized.
36   virtual bool IsInitialized() = 0;
37 
GetMemoryUsage()38   virtual size_t GetMemoryUsage() {
39     return 0;
40   }  // TODO(b/242603814): Make it pure virtual.
41 };
42 
43 /// WARNING: Experimental interface, subject to change.
44 using ResourceMap =
45     std::unordered_map<std::int32_t, std::unique_ptr<ResourceBase>>;
46 
47 using ResourceIDMap = std::map<std::pair<std::string, std::string>, int>;
48 
49 }  // namespace resource
50 }  // namespace tflite
51 
52 #endif  // TENSORFLOW_LITE_EXPERIMENTAL_RESOURCE_RESOURCE_BASE_H_
53