Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
ComponentType.ixx File Reference

Enumeration of built-in component types supported by the deserializer. More...

#include <string>
#include <string_view>
#include <cctype>

Namespaces

namespace  Mila
 Mila main API namespace.

Enumerations

enum class  Mila::Dnn::ComponentType : int {
  Unknown = 0 , Linear , Gelu , Activation ,
  Swiglu , LayerNorm , RmsNorm , Softmax ,
  Dropout , MultiHeadAttention , GroupedQueryAttention , Residual ,
  TokenEmbedding , Lpe , Rope , SoftmaxCrossEntropy ,
  Mlp , GatedMlp , Transformer , Network ,
  CustomComponentStart = 1000 , MockComponent = CustomComponentStart
}
 Canonical list of framework-known component types. More...

Functions

ComponentType Mila::Dnn::fromString (std::string_view s) noexcept
 Parse a case-insensitive component name into a ComponentType.
ComponentType Mila::Dnn::fromTypeId (std::string_view s) noexcept
 Map a short type identifier back to a ComponentType enum.
std::string Mila::Dnn::toString (ComponentType t) noexcept
 Convert a ComponentType enum value to its canonical name.
std::string Mila::Dnn::toTypeId (ComponentType t) noexcept
 Get the short 2..4 character type identifier for a ComponentType.

Detailed Description

Enumeration of built-in component types supported by the deserializer.

Provides an enum and helper conversion utilities used by serialization, factories and concise diagnostics.

Enumeration Type Documentation

◆ ComponentType

enum class Mila::Dnn::ComponentType : int
exportstrong

Canonical list of framework-known component types.

These values are used by the deserializer and factory code to identify component implementations. Values 1..999 are reserved for built-in components; values >= CustomComponentStart are available for user defined components or extensions.

Enumerator
SoftmaxCrossEntropy 

WIP: Fused softmax + cross-entropy loss – targeted for Llama training.

MockComponent 

Example custom component for testing.

Examples
/home/runner/work/Mila/Mila/Mila/Src/Dnn/Core/ComponentFactory.ixx.

Function Documentation

◆ fromString()

ComponentType Mila::Dnn::fromString ( std::string_view s)
inlineexportnoexcept

Parse a case-insensitive component name into a ComponentType.

Accepts canonical names (case-insensitive) produced by toString and returns the corresponding enum value. Returns ComponentType::Unknown if the input does not match any known type.

Parameters
sInput string (case-insensitive)
Returns
ComponentType Matching enum value or Unknown
Examples
/home/runner/work/Mila/Mila/Mila/Src/Dnn/Core/ComponentFactory.ixx.

◆ fromTypeId()

ComponentType Mila::Dnn::fromTypeId ( std::string_view s)
inlineexportnoexcept

Map a short type identifier back to a ComponentType enum.

Accepts the compact lowercase identifiers produced by toTypeId and returns the corresponding enum value. Returns ComponentType::Unknown for unrecognized identifiers.

Parameters
sShort lowercase type id (for example "fc", "mlp", "tf")
Returns
ComponentType Matching enum value or Unknown

◆ toString()

std::string Mila::Dnn::toString ( ComponentType t)
inlineexportnoexcept

Convert a ComponentType enum value to its canonical name.

Returns a human-readable name suitable for logs and metadata fields (for example "Linear", "Transformer"). Always returns "Unknown" for unrecognized enum values.

Parameters
tComponentType enum value
Returns
std::string Canonical name for the component type
Examples
/home/runner/work/Mila/Mila/Mila/Src/Dnn/Core/ComponentFactory.ixx.

◆ toTypeId()

std::string Mila::Dnn::toTypeId ( ComponentType t)
inlineexportnoexcept

Get the short 2..4 character type identifier for a ComponentType.

The short type id is intended for compact labels in serialized metadata and concise diagnostics (examples: "fc" for Linear, "mlp" for MLP, "tf" for Transformer). Returns "Unknown" for unrecognized types.

Parameters
tComponentType enum value
Returns
std::string Short lowercase identifier (2..4 chars) or "Unknown"