• 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_ENTRY_H_
16 #define TENSORFLOW_CORE_TPU_KERNELS_TPU_COMPILATION_CACHE_ENTRY_H_
17 
18 #include "tensorflow/compiler/xla/service/hlo.pb.h"
19 #include "tensorflow/core/lib/core/refcount.h"
20 #include "tensorflow/core/tpu/kernels/tpu_executable_info.pb.h"
21 #include "tensorflow/core/tpu/kernels/tpu_program_group_interface.h"
22 
23 namespace tensorflow {
24 namespace tpu {
25 
26 // Cache entry to hold a `TpuProgramGroupInterface` object that can be used to
27 // fetch a TPU program for a given TPU core index.
28 class TpuCompilationCacheEntry {
29  public:
TpuCompilationCacheEntry(const TpuProgramGroupInterface * tpu_program_group,int core_index)30   explicit TpuCompilationCacheEntry(
31       const TpuProgramGroupInterface* tpu_program_group, int core_index)
32       : tpu_program_group_(tpu_program_group), core_index_(core_index) {}
33 
34   // Constructor for an empty entry.
TpuCompilationCacheEntry()35   TpuCompilationCacheEntry() : tpu_program_group_(nullptr), core_index_(-1) {}
36 
tpu_program_group()37   const TpuProgramGroupInterface* tpu_program_group() const {
38     return tpu_program_group_;
39   }
40 
core_index()41   int core_index() const { return core_index_; }
42 
43  private:
44   const TpuProgramGroupInterface* tpu_program_group_;
45   int core_index_;
46 };
47 }  // namespace tpu
48 }  // namespace tensorflow
49 
50 #endif  // TENSORFLOW_CORE_TPU_KERNELS_TPU_COMPILATION_CACHE_ENTRY_H_
51