1 /* Copyright 2021 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_TFRT_EAGER_OP_HANDLER_REGISTRY_H_ 16 #define TENSORFLOW_CORE_TFRT_EAGER_OP_HANDLER_REGISTRY_H_ 17 18 #include "tfrt/support/forward_decls.h" // from @tf_runtime 19 20 namespace tensorflow { 21 class DeviceMgr; 22 } // namespace tensorflow 23 24 namespace tfrt { 25 26 class CoreRuntime; 27 class ResourceContext; 28 29 namespace tf { 30 31 using ::tensorflow::DeviceMgr; 32 33 // TODO(fishx): Change the second argument to tfrt::DeviceManager and move this 34 // file into TFRT. 35 using OpHandlerRegistrationFn = void (*)(CoreRuntime* core_runtime, 36 ResourceContext* resource_context, 37 const DeviceMgr* device_mgr); 38 39 // This is called to register all OpHandlers into the given core_runtime. 40 void RegisterOpHandlers(CoreRuntime* core_runtime, 41 ResourceContext* resource_context, 42 const DeviceMgr* device_mgr); 43 44 // A helper class for registering a new OpHandler registration function. 45 struct OpHandlerRegistration { 46 explicit OpHandlerRegistration(OpHandlerRegistrationFn fn); 47 }; 48 49 } // namespace tf 50 } // namespace tfrt 51 52 #endif // TENSORFLOW_CORE_TFRT_EAGER_OP_HANDLER_REGISTRY_H_ 53