Shortcuts

Template Struct AnyModuleHolder

Inheritance Relationships

Base Type

Struct Documentation

template<typename ModuleType, typename ...ArgumentTypes>
struct 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

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

Constructs the AnyModuleHolder from a concrete module.

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

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

inline virtual std::shared_ptr<Module> ptr() override

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

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

Returns a AnyModulePlaceholder with a shallow copy of this AnyModule.

inline virtual std::unique_ptr<AnyModulePlaceholder> clone_module(std::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>
inline std::decay_t<T> &&operator()(size_t index)

Public Members

std::vector<AnyValue> &arguments_
struct InvokeForward

Public Functions

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

Public Members

std::shared_ptr<ModuleType> &module_

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources