• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2020 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_CORE_TPU_KERNELS_TPU_COMPILATION_CACHE_LOCAL_LOOKUP_H_
16 #define TENSORFLOW_CORE_TPU_KERNELS_TPU_COMPILATION_CACHE_LOCAL_LOOKUP_H_
17 
18 #include "tensorflow/core/platform/status.h"
19 #include "tensorflow/core/tpu/kernels/tpu_compilation_cache_common.pb.h"
20 #include "tensorflow/core/tpu/kernels/tpu_compilation_cache_entry.h"
21 #include "tensorflow/core/tpu/kernels/tpu_compilation_cache_interface.h"
22 #include "tensorflow/core/tpu/kernels/tpu_compilation_cache_lookup.h"
23 
24 namespace tensorflow {
25 namespace tpu {
26 
27 // Class for looking up TPU programs when the execute and compile Op are in the
28 // same address space. The proto is simply looked up in the compilation cache,
29 // without any serialization taking place.
30 class TpuCompilationCacheLocalLookup : public TpuCompilationCacheLookup {
31  public:
32   explicit TpuCompilationCacheLocalLookup(TpuCompilationCacheInterface* cache);
33   ~TpuCompilationCacheLocalLookup() override;
34 
35   Status Lookup(const string& proto_key,
36                 std::unique_ptr<CompilationCacheEntryRef>* entry,
37                 CompilationCacheFetchTarget fetch_target) override;
38 
39   Status Lookup(int64 uid, int proto_index,
40                 std::unique_ptr<CompilationCacheEntryRef>* entry,
41                 CompilationCacheFetchTarget fetch_target) override;
42 
43   string DebugString() const override;
44 
45  private:
46   // The subgraph compilation cache, in the same process address space where the
47   // lookups are happening.
48   TpuCompilationCacheInterface* cache_;
49 };
50 
51 }  // namespace tpu
52 }  // namespace tensorflow
53 
54 #endif  // TENSORFLOW_CORE_TPU_KERNELS_TPU_COMPILATION_CACHE_LOCAL_LOOKUP_H_
55