Class InferenceModel

Inheritance Relationships

Base Type

Class Documentation

class InferenceModel : public ams::ml::BaseModel

Callable model interface on top of BaseModel.

InferenceModel does NOT add state; it adds a clean forward() API via operator(), returning an IValue exactly like PyTorch.

It inherits move semantics from BaseModel and intentionally remains non-copyable.

Public Functions

InferenceModel(const InferenceModel&) = delete
InferenceModel &operator=(const InferenceModel&) = delete
InferenceModel(InferenceModel&&) = default
InferenceModel &operator=(InferenceModel&&) = default
AMSExpected<torch::jit::IValue> operator()(std::vector<torch::jit::IValue> Inputs)

Generic call: accepts a vector<IValue>.

This is the most TorchScript-native interface.

inline AMSExpected<torch::jit::IValue> operator()(const torch::Tensor &X)

Convenience: single-tensor forward call.

template<typename ...Ts>
inline AMSExpected<torch::jit::IValue> operator()(Ts&&... Args)

Variadic convenience interface.

Allows calls like: model(t1, t2, t3)

Each argument must be convertible to an IValue.

inline bool isTraining() const

Returns whether the model is in training mode (should always be false for InferenceModel).

BaseModel(const BaseModel&) = delete
BaseModel(BaseModel&&) = default
BaseModel(const AbstractModel &AModel)

Construct a BaseModel from an existing Torch module, device, and dtype.

This is primarily intended for use by factory functions (e.g. load()) and subclasses such as InferenceModel.

Public Static Functions

static AMSExpected<std::unique_ptr<InferenceModel>> load(const AbstractModel &Descriptor)

Load model from descriptor into an InferenceModel.

This wraps BaseModel::load() and then transfers ownership.