Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-28 08:58:47

0001 // Copyright (c) ONNX Project Contributors
0002 
0003 /*
0004  * SPDX-License-Identifier: Apache-2.0
0005  */
0006 
0007 #pragma once
0008 
0009 #include <string>
0010 
0011 #include "onnx/common/constants.h"
0012 #include "onnx/onnx_pb.h"
0013 
0014 namespace ONNX_NAMESPACE {
0015 
0016 // ONNX (model-local) function identifiers are a tuple (domain, op, overload).
0017 // The pair (domain, op) represents a specification of a function, while
0018 // overload is used to disambiguate between multiple (specialized) implementations of
0019 // the same specification. Overload is optional and can be empty.
0020 // Multiple overloads may be used to distinguish implementations specialized
0021 // for a specific type or rank of input tensors or for specific attribute values.
0022 
0023 // A single string representation of (domain, op)
0024 using FunctionSpecId = std::string;
0025 
0026 // A single string representation of (domain, op, overload)
0027 using FunctionImplId = std::string;
0028 
0029 FunctionImplId GetFunctionImplId(const std::string& domain, const std::string& op, const std::string& overload) {
0030   if (overload.empty())
0031     return NormalizeDomain(domain) + "::" + op;
0032   return NormalizeDomain(domain) + "::" + op + "::" + overload;
0033 }
0034 
0035 FunctionImplId GetFunctionImplId(const FunctionProto& function) {
0036   return GetFunctionImplId(function.domain(), function.name(), function.overload());
0037 }
0038 
0039 FunctionImplId GetCalleeId(const NodeProto& node) {
0040   return GetFunctionImplId(node.domain(), node.op_type(), node.overload());
0041 }
0042 
0043 } // namespace ONNX_NAMESPACE