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_TPU_COMPILE_INTERFACE_H_ 16 #define TENSORFLOW_CORE_TPU_TPU_COMPILE_INTERFACE_H_ 17 18 #include "absl/strings/string_view.h" 19 20 // Some legacy code requires different implementations for operations like 21 // fingerprint/hashing during compilation and/or graph rewriting. These 22 // alternate implementations can be registered (via a module initializer) to 23 // change the default behavior. 24 class TpuCompileInterface { 25 public: ~TpuCompileInterface()26 virtual ~TpuCompileInterface() {} 27 static TpuCompileInterface* Get(); 28 static bool RegisterImplementation(TpuCompileInterface* impl); 29 30 virtual uint64_t FingerprintString(absl::string_view str) = 0; 31 32 static inline constexpr char kTpuCompileErrorPayloadKey[] = 33 "https://www.tensorflow.org/tpu-compile-error"; 34 }; 35 36 #endif // TENSORFLOW_CORE_TPU_TPU_COMPILE_INTERFACE_H_ 37