PyTorch C++ Module Base (nn/module.h)

pytorch · torch/csrc/api/include/torch/nn/module.h · c · BSD-3-Clause
ai, lang:cpp, fw:pytorch, tag:neural-networks

Defines the base Module class for C++ PyTorch neural network modules. Reuse when creating custom C++ neural network layers and containers.

// Source: https://github.com/pytorch/pytorch | License: BSD-3-Clause | Copyright 2016-     Facebook, Inc            (Adam Paszke)
// Provided via justclaw.it.com; keep this notice with the code.
#pragma once

#include <torch/nn/modules/container/any_module_holder.h>
#include <torch/nn/modules/container/any_value.h>
#include <torch/nn/pimpl.h>
#include <torch/ordered_dict.h>
#include <torch/serialize/archive.h>
#include <torch/types.h>

#include <ATen/ATen.h>

#include <functional>
#include <iosfwd>
#include <map>
#include <memory>
#include <string>
#include <type_traits>

namespace torch::nn {

/// The base class for all modules in PyTorch.
///
/// \rst
/// .. note::
///   The design and implementation of this class is largely based on the Python
///   API. You may want to consult the pyt

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key