Template Struct AnyModuleHolder

Inheritance Relationships

Base Type

Struct Documentation

template<typename ModuleType, typename ...ArgumentTypes>
struct torch::nn::AnyModuleHolder : public torch::nn::AnyModulePlaceholder

The dynamic type of the object stored in the AnyModule.

It contains the concrete instance to which all calls are forwarded. It is parameterized over the concrete type of the module, and the types of the arguments the module takes in its forward() method.

Public Functions

AnyModuleHolder(std::shared_ptr<ModuleType> &&module_)

Constructs the AnyModuleHolder from a concrete module.

AnyValue forward(std::vector<AnyValue> &&arguments) override

Calls forward() on the underlying module, casting each AnyValue in the argument vector to a concrete value.

std::shared_ptr<Module> ptr() override

Returns std::shared_ptr<Module> pointing to the erased module.

std::unique_ptr<AnyModulePlaceholder> copy() const override

Returns a AnyModulePlaceholder with a shallow copy of this AnyModule.

std::unique_ptr<AnyModulePlaceholder> clone_module(optional<Device> device) const override

Returns a AnyModulePlaceholder with a deep copy of this AnyModule.

Public Members

std::shared_ptr<ModuleType> module

The actual concrete module instance.

struct CheckedGetter

Public Functions

template<typename T>
decay_t<T> &&operator()(size_t index)

Public Members

std::vector<AnyValue> &arguments_
struct InvokeForward

Public Functions

template<typename ...Ts>
AnyValue operator()(Ts&&... ts)

Public Members

std::shared_ptr<ModuleType> &module_


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources