pattern_registry.h#

namespace onnx_light

Alias that makes onnx-light headers compatible with code that references ONNX_LIGHT_NAMESPACE (the macro used in the standard onnx package).

Set to ONNX_LIGHT_NAMESPACE so both names resolve to the same namespace.

Symbol-visibility attribute for the public onnx-light C++ API.

Maps the upstream compatibility macro to onnx-light’s explicit proto ABI annotation. This keeps declarations from vendored ONNX headers visible when lib_onnx_proto uses hidden visibility by default.

Namespace alias so that ONNX C++ code (and consumers such as onnxruntime) that refers to the literal onnx namespace — rather than the ONNX_NAMESPACE macro — resolves to the onnx-light namespace. The standard onnx package lives in namespace onnx; onnx-light uses onnx_light (via ONNX_LIGHT_NAMESPACE), so this alias keeps onnx-light a true drop-in. It is only introduced when the onnx-light namespace differs from onnx.

namespace core
namespace builder

Typedefs

using PatternFactory = std::function<std::unique_ptr<PatternOptimization>()>#

Factory creating one stateless graph-rewriting pattern.

Functions

void RegisterPattern(const std::string &name, PatternFactory factory, bool enabled_by_default = true)#

Registers a pattern factory under a stable diagnostic name.

Registration order determines the order returned by :cpp:func:CreateRegisteredPatterns. Names must be non-empty and unique. enabled_by_default=false makes the pattern available only by explicit lookup.

std::vector<std::string> RegisteredPatternNames(bool include_opt_in = true)#

Returns names in registration order, optionally excluding explicit-only patterns.

void RegisterPatternSet(const std::string &name, const std::vector<std::string> &pattern_names)#

Registers a named set of pattern names.

Pattern names need not be registered yet, which allows Python-defined patterns to participate in sets. Set names must be non-empty and unique.

void ExtendPatternSet(const std::string &name, const std::vector<std::string> &pattern_names)#

Adds pattern names to an existing set or to the computed all set.

bool UnregisterPatternSet(const std::string &name)#

Removes a custom set. Built-in sets and the computed all set are retained.

std::vector<std::string> RegisteredPatternSetNames()#

Returns names of all registered sets, including the computed all set.

std::map<std::string, std::vector<std::string>> RegisteredPatternSets()#

Returns all pattern sets, including all as the union of registered names and set members.

std::vector<std::unique_ptr<PatternOptimization>> CreateRegisteredPatterns(std::optional<symbolic::Device> device = std::nullopt)#

Creates registered patterns, optionally filtering by target device.

Includes only patterns enabled by default. With a filter, includes device-independent patterns and those targeting that exact device. kUndefined selects only independent ones. Opt-in patterns remain available through CreateRegisteredPattern.

std::unique_ptr<PatternOptimization> CreateRegisteredPattern(const std::string &name, std::optional<int> priority = std::nullopt)#

Creates one registered pattern by name.

When priority is specified, it overrides the pattern default.

class PatternRegistrationError : public std::runtime_error#
#include <pattern_registry.h>

Reports an invalid or duplicate pattern registration.

Public Functions

inline explicit PatternRegistrationError(const std::string &message)#

Constructs an error with the given diagnostic message.