inliner.h#
-
namespace ONNX_LIGHT_NAMESPACE
-
namespace inliner#
Typedefs
-
using FunctionIdVector = std::vector<FunctionId>#
Functions
-
void InlineSelectedFunctions(ModelProto &model, const FunctionIdSet &to_inline, const ISchemaRegistry *schema_registry)#
Inlines the schema-defined functions in the given model that are in the given set.
Note
Only call-sites in the main graph are inlined.
- Parameters:
model – The model in which functions will be inlined.
to_inline – The set of functions to inline.
schema_registry – The schema registry used for function lookup. If nullptr, the default schema registry is used.
-
void InlineSelectedLocalFunctions(ModelProto &model, const FunctionIdSet &to_inline)#
Inlines the model-local functions in the given model that are in the given set.
This function processes the model and replaces all call-sites of the specified model-local functions with their inlined implementations. The inlined functions are also removed from the model’s list of functions.
Note
This function does not perform schema-defined function inlining. For schema-defined function inlining, use InlineSelectedFunctions instead.
- Parameters:
model – The model in which functions will be inlined.
to_inline – The set of functions to inline.
-
void InlineSelectedFunctions(ModelProto &model, const FunctionIdSet &to_inline)#
Inlines the model-local functions in the given model that are in the given set.
- Deprecated:
This function is deprecated. Use InlineSelectedLocalFunctions instead, to avoid confusion with the overloaded version of InlineSelectedFunctions that inlines schema-defined functions as well.
-
void InlineLocalFunctions(ModelProto &model, bool convert_version = false)#
-
void CheckFunctionCallCycles(const ModelProto &model)#
Checks for cycles in the model-local function call graph.
Throws checker::ValidationError if any function directly or indirectly references itself. Also raises if the model has too many local functions or duplicate function implementation ids.
- Parameters:
model – The model to check.
-
std::vector<std::string> GetUsedVars(const NodeProto &node)#
Returns all input variable names used by the given node.
Collects the variables listed as node.input, as well as implicit inputs referred to in any graph-valued attribute of the node. For variables referenced inside sub-graphs, only non-local variables (i.e. those not defined within the sub-graph) are included.
- Parameters:
node – The node to inspect.
- Returns:
A vector of variable name strings.
-
class FunctionIdSet#
- #include <inliner.h>
Public Functions
-
virtual bool Contains(const std::string &function_domain, const std::string &function_name) const = 0#
-
virtual ~FunctionIdSet() = default#
Public Static Functions
-
static std::unique_ptr<FunctionIdSet> Create(FunctionIdVector &&function_ids, bool invert = false)#
-
virtual bool Contains(const std::string &function_domain, const std::string &function_name) const = 0#
-
class Renamer#
- #include <inliner.h>
A utility class for renaming variables during graph inlining operations.
This class provides a simplified interface to the InliningRenamer functionality, allowing users to bind formal parameter names to actual parameter names and rename nodes with unique prefixes.
Public Functions
-
explicit Renamer(const std::string &prefix, const GraphProto &graph)#
Constructs a Renamer with the given prefix.
- Parameters:
prefix – The prefix to add to intermediate variable names to ensure uniqueness.
graph – The graph context for name generation.
-
explicit Renamer(const std::string &prefix, const FunctionProto &function)#
Constructs a Renamer with the given prefix.
- Parameters:
prefix – The prefix to add to intermediate variable names to ensure uniqueness.
function – The function context for name generation.
-
~Renamer()#
Destructor.
-
void BindName(const std::string &formal_name, const std::string &actual_name)#
Binds a formal parameter name to an actual parameter name.
- Parameters:
formal_name – The formal parameter name in the source graph.
actual_name – The actual parameter name to use in the target.
-
std::string BindToUniqueName(const std::string &original_name)#
Creates a unique name for the given name and binds it.
This method creates a unique name based on the prefix and binds the original name to the unique name for later reference renaming.
- Parameters:
original_name – The name to create a unique version of.
- Returns:
The unique name that was created and bound.
-
explicit Renamer(const std::string &prefix, const GraphProto &graph)#
-
using FunctionIdVector = std::vector<FunctionId>#
-
namespace inliner#