Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::Compute::OperationRegistry Class Referenceexport

Central registry for typed, device-aware compute operations. More...

Classes

struct  TypeID
 Composite key for registry lookup. More...
struct  TypeIDHash

Public Member Functions

template<DeviceType TDeviceType, TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TComputePrecision = TInputA>
std::shared_ptr< BinaryOperation< TDeviceType, TInputA, TInputB, TComputePrecision > > createBinaryOperation (const std::string &operation_name, IExecutionContext *context, const ComponentConfig &config) const
 Create a binary operation instance.
template<DeviceType TDeviceType, TensorDataType TPrecision, TensorDataType TInputA = TPrecision, TensorDataType TInputB = TInputA>
std::shared_ptr< PairedOperation< TDeviceType, TPrecision, TInputA, TInputB > > createPairedOperation (const std::string &operation_name, IExecutionContext *context, const ComponentConfig &config) const
 Create a paired operation instance.
template<DeviceType TDeviceType, TensorDataType TInputType, TensorDataType TComputePrecision = TInputType>
std::shared_ptr< UnaryOperation< TDeviceType, TInputType, TComputePrecision > > createUnaryOperation (const std::string &operation_name, IExecutionContext *context, const ComponentConfig &config) const
 Create a unary operation instance.
template<DeviceType TDeviceType, TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TComputePrecision = TInputA>
std::vector< std::string > getRegisteredOperations () const
 Return all registered operation names across all arities for a given type configuration.
template<DeviceType TDeviceType, TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TComputePrecision = TInputA>
bool isOperationRegistered (const std::string &operation_name) const
 Return true if an operation name is registered under any arity for a given type configuration.
template<DeviceType TDeviceType, TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TComputePrecision = TInputA>
void registerBinaryOperation (const std::string &operation_name, std::function< std::shared_ptr< BinaryOperation< TDeviceType, TInputA, TInputB, TComputePrecision > >(IExecutionContext *, const ComponentConfig &)> creator)
 Register a binary operation factory.
template<DeviceType TDeviceType, TensorDataType TPrecision, TensorDataType TInputA = TPrecision, TensorDataType TInputB = TInputA>
void registerPairedOperation (const std::string &operation_name, std::function< std::shared_ptr< PairedOperation< TDeviceType, TPrecision, TInputA, TInputB > >(IExecutionContext *, const ComponentConfig &)> creator)
 Register a paired operation factory.
template<DeviceType TDeviceType, TensorDataType TInputType, TensorDataType TComputePrecision = TInputType>
void registerUnaryOperation (std::string_view operation_name, std::function< std::shared_ptr< UnaryOperation< TDeviceType, TInputType, TComputePrecision > >(IExecutionContext *, const ComponentConfig &)> creator)
 Register a unary operation factory.

Static Public Member Functions

static OperationRegistryinstance ()

Private Types

using GenericCreator
using RegistryMap

Private Member Functions

 OperationRegistry ()=default
 OperationRegistry (const OperationRegistry &)=delete
OperationRegistryoperator= (const OperationRegistry &)=delete

Private Attributes

RegistryMap binary_registry_
RegistryMap paired_registry_
RegistryMap unary_registry_

Detailed Description

Central registry for typed, device-aware compute operations.

Maintains three independent stores keyed by (DeviceType, input types, compute precision) and operation name — one per operation arity. Separation prevents cross-arity static_pointer_cast UB when an op is retrieved under the wrong base type.

Member Typedef Documentation

◆ GenericCreator

Initial value:
std::function<std::shared_ptr<void>(
Abstract base for component configuration objects.
Definition ComponentConfig.ixx:36
Type-erased execution context interface.
Definition IExecutionContext.ixx:24

◆ RegistryMap

Initial value:
std::unordered_map<TypeID,
std::unordered_map<std::string, GenericCreator>,
Definition OperationRegistry.ixx:67
Composite key for registry lookup.
Definition OperationRegistry.ixx:51

Constructor & Destructor Documentation

◆ OperationRegistry() [1/2]

Mila::Dnn::Compute::OperationRegistry::OperationRegistry ( )
privatedefault
Here is the caller graph for this function:

◆ OperationRegistry() [2/2]

Mila::Dnn::Compute::OperationRegistry::OperationRegistry ( const OperationRegistry & )
privatedelete
Here is the call graph for this function:

Member Function Documentation

◆ createBinaryOperation()

template<DeviceType TDeviceType, TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TComputePrecision = TInputA>
std::shared_ptr< BinaryOperation< TDeviceType, TInputA, TInputB, TComputePrecision > > Mila::Dnn::Compute::OperationRegistry::createBinaryOperation ( const std::string & operation_name,
IExecutionContext * context,
const ComponentConfig & config ) const
inline

Create a binary operation instance.

Exceptions
std::runtime_errorif no matching registration exists.
std::invalid_argumentif context is null.
Here is the caller graph for this function:

◆ createPairedOperation()

template<DeviceType TDeviceType, TensorDataType TPrecision, TensorDataType TInputA = TPrecision, TensorDataType TInputB = TInputA>
std::shared_ptr< PairedOperation< TDeviceType, TPrecision, TInputA, TInputB > > Mila::Dnn::Compute::OperationRegistry::createPairedOperation ( const std::string & operation_name,
IExecutionContext * context,
const ComponentConfig & config ) const
inline

Create a paired operation instance.

Exceptions
std::runtime_errorif no matching registration exists.
std::invalid_argumentif context is null.

◆ createUnaryOperation()

template<DeviceType TDeviceType, TensorDataType TInputType, TensorDataType TComputePrecision = TInputType>
std::shared_ptr< UnaryOperation< TDeviceType, TInputType, TComputePrecision > > Mila::Dnn::Compute::OperationRegistry::createUnaryOperation ( const std::string & operation_name,
IExecutionContext * context,
const ComponentConfig & config ) const
inline

Create a unary operation instance.

Exceptions
std::runtime_errorif no matching registration exists.
std::invalid_argumentif context is null.
Here is the caller graph for this function:

◆ getRegisteredOperations()

template<DeviceType TDeviceType, TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TComputePrecision = TInputA>
std::vector< std::string > Mila::Dnn::Compute::OperationRegistry::getRegisteredOperations ( ) const
inline

Return all registered operation names across all arities for a given type configuration.

◆ instance()

OperationRegistry & Mila::Dnn::Compute::OperationRegistry::instance ( )
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isOperationRegistered()

template<DeviceType TDeviceType, TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TComputePrecision = TInputA>
bool Mila::Dnn::Compute::OperationRegistry::isOperationRegistered ( const std::string & operation_name) const
inline

Return true if an operation name is registered under any arity for a given type configuration.

◆ operator=()

OperationRegistry & Mila::Dnn::Compute::OperationRegistry::operator= ( const OperationRegistry & )
privatedelete
Here is the call graph for this function:

◆ registerBinaryOperation()

template<DeviceType TDeviceType, TensorDataType TInputA, TensorDataType TInputB = TInputA, TensorDataType TComputePrecision = TInputA>
void Mila::Dnn::Compute::OperationRegistry::registerBinaryOperation ( const std::string & operation_name,
std::function< std::shared_ptr< BinaryOperation< TDeviceType, TInputA, TInputB, TComputePrecision > >(IExecutionContext *, const ComponentConfig &)> creator )
inline

Register a binary operation factory.

Creator must return a std::shared_ptr<BinaryOperation<TDeviceType, TInputA, TInputB, TComputePrecision>>.

Here is the caller graph for this function:

◆ registerPairedOperation()

template<DeviceType TDeviceType, TensorDataType TPrecision, TensorDataType TInputA = TPrecision, TensorDataType TInputB = TInputA>
void Mila::Dnn::Compute::OperationRegistry::registerPairedOperation ( const std::string & operation_name,
std::function< std::shared_ptr< PairedOperation< TDeviceType, TPrecision, TInputA, TInputB > >(IExecutionContext *, const ComponentConfig &)> creator )
inline

Register a paired operation factory.

Creator must return a std::shared_ptr<PairedOperation<TDeviceType, TPrecision, TInputA, TInputB>>.

Here is the caller graph for this function:

◆ registerUnaryOperation()

template<DeviceType TDeviceType, TensorDataType TInputType, TensorDataType TComputePrecision = TInputType>
void Mila::Dnn::Compute::OperationRegistry::registerUnaryOperation ( std::string_view operation_name,
std::function< std::shared_ptr< UnaryOperation< TDeviceType, TInputType, TComputePrecision > >(IExecutionContext *, const ComponentConfig &)> creator )
inline

Register a unary operation factory.

Creator must return a std::shared_ptr<UnaryOperation<TDeviceType, TInputType, TComputePrecision>>.

Here is the caller graph for this function:

Member Data Documentation

◆ binary_registry_

RegistryMap Mila::Dnn::Compute::OperationRegistry::binary_registry_
private

◆ paired_registry_

RegistryMap Mila::Dnn::Compute::OperationRegistry::paired_registry_
private

◆ unary_registry_

RegistryMap Mila::Dnn::Compute::OperationRegistry::unary_registry_
private

The documentation for this class was generated from the following file: