|
Mila 0.13.48
Deep Neural Network Library
|
Abstract base class for all Mila models. More...
#include <memory>#include <string>#include <stdexcept>#include <format>import Compute.DeviceId;import Dnn.TensorDataTypeTraits;import Compute.DeviceType;import Dnn.TensorDataType;import Dnn.RuntimeMode;import Dnn.TensorTypes;import Dnn.Component;import Dnn.Network;Classes | |
| class | Mila::Dnn::Model< TDeviceType, TPrecision > |
Namespaces | |
| namespace | Mila |
| Mila main API namespace. | |
| namespace | Mila::Dnn |
Abstract base class for all Mila models.
Model defines the universal contract across all model families — language models, image classifiers, regression models, and any future model type.
Model sits at the top of the Mila DNN pipeline:
Component — leaf node, shape-driven buffer allocation CompositeComponent — structural aggregation, cascades BuildConfig Network — graph topology, forward/backward Model — RuntimeMode, lifecycle, universal API boundary LanguageModel — generate(), sampling, EOS, vocabulary GptModel — GPT-specific factory and config LlamaModel — LLaMA-specific factory and config ImageClassifier— classify(), top-k predictions
A Model is constructed for either Inference or Training — immutable after construction. The mode governs which public API methods are valid:
| Mode | Valid |
|---|---|
| Inference | model-family inference API |
| Training | train() → onTraining() hook |
train() enforces the RuntimeMode::Training precondition then delegates entirely to the pure virtual onTraining() hook. The derived class owns the training loop — data loading, optimizer, loss, backward pass, checkpointing, and sampling are all derived class concerns.
Not thread-safe. External synchronization required if shared.