1 /* 2 * Copyright (c) Meta Platforms, Inc. and affiliates. 3 * All rights reserved. 4 * 5 * This source code is licensed under the BSD-style license found in the 6 * LICENSE file in the root directory of this source tree. 7 */ 8 9 #include <executorch/backends/vulkan/runtime/graph/ops/OperatorRegistry.h> 10 11 namespace vkcompute { 12 has_op(const std::string & name)13bool OperatorRegistry::has_op(const std::string& name) { 14 return table_.count(name) > 0; 15 } 16 get_op_fn(const std::string & name)17OperatorRegistry::OpFunction& OperatorRegistry::get_op_fn( 18 const std::string& name) { 19 const auto it = table_.find(name); 20 VK_CHECK_COND(it != table_.end(), "Could not find operator with name ", name); 21 return it->second; 22 } 23 register_op(const std::string & name,OpFunction & fn)24void OperatorRegistry::register_op(const std::string& name, OpFunction& fn) { 25 table_.insert(std::make_pair(name, fn)); 26 } 27 operator_registry()28OperatorRegistry& operator_registry() { 29 static OperatorRegistry registry; 30 return registry; 31 } 32 33 } // namespace vkcompute 34