Shortcuts

Struct Module

Inheritance Relationships

Base Type

  • public Object

Struct Documentation

struct Module : public Object

Public Functions

explicit Module(c10::QualifiedName class_name)
Module(std::shared_ptr<CompilationUnit> cu, const c10::ClassTypePtr &type)
Module() = default
Module(const Module&) = default
Module &operator=(const Module&) = default
Module(Module&&) noexcept = default
Module &operator=(Module&&) noexcept = default
Module(c10::QualifiedName, std::shared_ptr<CompilationUnit> cu, bool shouldMangle = false)
inline Module(ModulePtr module_value)
~Module() = default
inline void set_optimized(bool o)
inline bool is_optimized() const
inline IValue forward(std::vector<IValue> inputs, const Kwargs &kwargs = Kwargs())
inline void register_buffer(const std::string &name, at::Tensor v)
inline void register_parameter(const std::string &name, at::Tensor v, bool is_buffer)
inline void register_attribute(const std::string &name, const TypePtr &t, IValue v, bool is_param = false, bool is_buffer = false)
inline void register_module(const std::string &name, const Module &module)
void apply(const std::function<void(Module&)> &fn)
buffer_list buffers(bool recurse = true) const
named_buffer_list named_buffers(bool recurse = true) const
module_list children() const
named_module_list named_children() const
module_list modules() const
named_module_list named_modules() const
parameter_list parameters(bool recurse = true) const
named_parameter_list named_parameters(bool recurse = true) const
attribute_list attributes(bool recurse = true) const
named_attribute_list named_attributes(bool recurse = true) const
void dump(bool print_method_bodies, bool print_attr_values, bool print_param_values) const
std::string dump_to_str(bool print_method_bodies, bool print_attr_values, bool print_param_values) const
void train(bool on = true)

Enables “training” mode.

inline void eval()

Calls train(false) to enable “eval” mode.

Do not override this method, override train() instead.

inline bool is_training() const

True if the module is in training mode.

void to(at::Device device, at::ScalarType dtype, bool non_blocking = false)

Recursively casts all parameters to the given dtype and device.

If non_blocking is true and the source is in pinned memory and destination is on the GPU or vice versa, the copy is performed asynchronously with respect to the host. Otherwise, the argument has no effect.

void to(at::ScalarType dtype, bool non_blocking = false)

Recursively casts all parameters to the given dtype.

If non_blocking is true and the source is in pinned memory and destination is on the GPU or vice versa, the copy is performed asynchronously with respect to the host. Otherwise, the argument has no effect.

void to(at::Device device, bool non_blocking = false)

Recursively moves all parameters to the given device.

If non_blocking is true and the source is in pinned memory and destination is on the GPU or vice versa, the copy is performed asynchronously with respect to the host. Otherwise, the argument has no effect.

void save(std::ostream &out, const ExtraFilesMap &extra_files = ExtraFilesMap()) const
void save(const std::string &filename, const ExtraFilesMap &extra_files = ExtraFilesMap()) const
void _save_for_mobile(std::ostream &out, const ExtraFilesMap &extra_files = ExtraFilesMap(), bool save_mobile_debug_info = false, bool use_flatbuffer = false) const
void _save_for_mobile(const std::string &filename, const ExtraFilesMap &extra_files = ExtraFilesMap(), bool save_mobile_debug_info = false, bool use_flatbuffer = false) const
Module copy() const
Module deepcopy(std::optional<at::Device> device = std::nullopt) const
Module clone(bool inplace = false) const
Module clone(bool inplace, const std::unordered_set<std::string> &ignored_method, const std::unordered_set<std::string> &ignored_attributes) const
void clone_method(const Module &orig, const std::string &name)
IValue operator()(std::vector<IValue> inputs)
template<typename ...Types>
inline IValue create_class(const c10::QualifiedName &name, Types&&... args) const
IValue create_class(const c10::QualifiedName &name, Stack stack) const
inline bool operator==(const Module &y) const noexcept
inline void set_delete_memory(std::shared_ptr<char> delete_mem)
inline void store_traced_inputs(std::string func_name, std::vector<IValue> inputs)
inline c10::Dict<std::string, c10::impl::GenericList> retrieve_traced_inputs() const

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