Shortcuts

Struct Module

Inheritance Relationships

Base Type

  • public Object

Struct Documentation

struct torch::jit::Module : public Object

Public Functions

Module(c10::QualifiedName class_name)
Module(std::shared_ptr<CompilationUnit> cu, const c10::ClassTypePtr &type)
Module() = default
Module(c10::QualifiedName, std::shared_ptr<CompilationUnit> cu, bool shouldMangle = false)
Module(ModulePtr module_value)
~Module() = default
void set_optimized(bool o)
bool is_optimized() const
IValue forward(std::vector<IValue> inputs, const Kwargs &kwargs = Kwargs())
void register_buffer(const std::string &name, at::Tensor v)
void register_parameter(const std::string &name, at::Tensor v, bool is_buffer)
void register_attribute(const std::string &name, const TypePtr &t, IValue v, bool is_param = false, bool is_buffer = false)
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.

void eval()

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

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

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) const
void _save_for_mobile(const std::string &filename, const ExtraFilesMap &extra_files = ExtraFilesMap(), bool save_mobile_debug_info = false) const
Module copy() const
Module deepcopy() 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>
IValue create_class(const c10::QualifiedName &name, Types&&... args) const
IValue create_class(const c10::QualifiedName &name, Stack stack) const
bool operator==(const Module &y) const noexcept

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