xref: /aosp_15_r20/external/tensorflow/tensorflow/core/tpu/kernels/tpu_op_util.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
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_OP_UTIL_H_
16 #define TENSORFLOW_CORE_TPU_KERNELS_TPU_OP_UTIL_H_
17 
18 #include <vector>
19 
20 #include "absl/strings/string_view.h"
21 #include "tensorflow/compiler/xla/xla_data.pb.h"
22 #include "tensorflow/core/framework/op_kernel.h"
23 #include "tensorflow/core/framework/tensor_shape.h"
24 #include "tensorflow/core/protobuf/tpu/compile_metadata.pb.h"
25 #include "tensorflow/core/tpu/kernels/tpu_compilation_cache_key.h"
26 #include "tensorflow/core/tpu/kernels/tpu_mesh_state_interface.h"
27 
28 namespace tensorflow {
29 namespace tpu {
30 // Creates a fingerprint given the name and the vector of shapes.
31 uint64 CreateFingerprintWithNameAndShapes(
32     uint64 name, const std::vector<tensorflow::TensorShape>& shapes);
33 
34 // Creates a unique compilation cache `key`.
35 TpuCompilationCacheKey CreateCompilationCacheKey(
36     absl::string_view function_name, uint64 function_library_fingerprint,
37     uint64 mlir_module_fingerprint, const OpInputList& guaranteed_constants,
38     const std::vector<TensorShape>& dynamic_shapes,
39     const TPUCompileMetadataProto& metadata,
40     const TpuMeshStateInterface& mesh_state, uint64_t session_id = 0,
41     ResourceMgr* resource_mgr = nullptr);
42 }  // namespace tpu
43 }  // namespace tensorflow
44 
45 #endif  // TENSORFLOW_CORE_TPU_KERNELS_TPU_OP_UTIL_H_
46