Template Class Cloneable¶
Defined in File cloneable.h
Page Contents
Inheritance Relationships¶
Base Type¶
public torch::nn::Module
(Class Module)
Derived Types¶
public torch::nn::AdaptiveAvgPoolImpl< 1, ExpandingArray< 1 >, AdaptiveAvgPool1dImpl >
(Template Class AdaptiveAvgPoolImpl)public torch::nn::AdaptiveAvgPoolImpl< 3, ExpandingArrayWithOptionalElem< 3 >, AdaptiveAvgPool3dImpl >
(Template Class AdaptiveAvgPoolImpl)public torch::nn::AdaptiveAvgPoolImpl< 2, ExpandingArrayWithOptionalElem< 2 >, AdaptiveAvgPool2dImpl >
(Template Class AdaptiveAvgPoolImpl)public torch::nn::AdaptiveMaxPoolImpl< 1, ExpandingArray< 1 >, AdaptiveMaxPool1dImpl >
(Template Class AdaptiveMaxPoolImpl)public torch::nn::AdaptiveMaxPoolImpl< 2, ExpandingArrayWithOptionalElem< 2 >, AdaptiveMaxPool2dImpl >
(Template Class AdaptiveMaxPoolImpl)public torch::nn::AdaptiveMaxPoolImpl< 3, ExpandingArrayWithOptionalElem< 3 >, AdaptiveMaxPool3dImpl >
(Template Class AdaptiveMaxPoolImpl)public torch::nn::AvgPoolImpl< 2, AvgPool2dImpl >
(Template Class AvgPoolImpl)public torch::nn::AvgPoolImpl< 3, AvgPool3dImpl >
(Template Class AvgPoolImpl)public torch::nn::AvgPoolImpl< 1, AvgPool1dImpl >
(Template Class AvgPoolImpl)public torch::nn::ConstantPadImpl< 1, ConstantPad1dImpl >
(Template Class ConstantPadImpl)public torch::nn::ConstantPadImpl< 2, ConstantPad2dImpl >
(Template Class ConstantPadImpl)public torch::nn::ConstantPadImpl< 3, ConstantPad3dImpl >
(Template Class ConstantPadImpl)public torch::nn::ConvNdImpl< 1, Conv1dImpl >
(Template Class ConvNdImpl)public torch::nn::ConvNdImpl< 3, Conv3dImpl >
(Template Class ConvNdImpl)public torch::nn::ConvNdImpl< 2, Conv2dImpl >
(Template Class ConvNdImpl)public torch::nn::LPPoolImpl< 3, LPPool3dImpl >
(Template Class LPPoolImpl)public torch::nn::LPPoolImpl< 2, LPPool2dImpl >
(Template Class LPPoolImpl)public torch::nn::LPPoolImpl< 1, LPPool1dImpl >
(Template Class LPPoolImpl)public torch::nn::MaxPoolImpl< 1, MaxPool1dImpl >
(Template Class MaxPoolImpl)public torch::nn::MaxPoolImpl< 2, MaxPool2dImpl >
(Template Class MaxPoolImpl)public torch::nn::MaxPoolImpl< 3, MaxPool3dImpl >
(Template Class MaxPoolImpl)public torch::nn::MaxUnpoolImpl< 1, MaxUnpool1dImpl >
(Template Class MaxUnpoolImpl)public torch::nn::MaxUnpoolImpl< 2, MaxUnpool2dImpl >
(Template Class MaxUnpoolImpl)public torch::nn::MaxUnpoolImpl< 3, MaxUnpool3dImpl >
(Template Class MaxUnpoolImpl)public torch::nn::NormImplBase< D, Derived, BatchNormOptions >
(Template Class NormImplBase)public torch::nn::NormImplBase< D, Derived, InstanceNormOptions >
(Template Class NormImplBase)public torch::nn::ReflectionPadImpl< 3, ReflectionPad3dImpl >
(Template Class ReflectionPadImpl)public torch::nn::ReflectionPadImpl< 2, ReflectionPad2dImpl >
(Template Class ReflectionPadImpl)public torch::nn::ReflectionPadImpl< 1, ReflectionPad1dImpl >
(Template Class ReflectionPadImpl)public torch::nn::ReplicationPadImpl< 3, ReplicationPad3dImpl >
(Template Class ReplicationPadImpl)public torch::nn::ReplicationPadImpl< 2, ReplicationPad2dImpl >
(Template Class ReplicationPadImpl)public torch::nn::ReplicationPadImpl< 1, ReplicationPad1dImpl >
(Template Class ReplicationPadImpl)public torch::nn::ZeroPadImpl< 1, ZeroPad1dImpl >
(Template Class ZeroPadImpl)public torch::nn::ZeroPadImpl< 2, ZeroPad2dImpl >
(Template Class ZeroPadImpl)public torch::nn::ZeroPadImpl< 3, ZeroPad3dImpl >
(Template Class ZeroPadImpl)public torch::nn::detail::RNNCellImplBase< GRUCellImpl >
(Template Class RNNCellImplBase)public torch::nn::detail::RNNCellImplBase< LSTMCellImpl >
(Template Class RNNCellImplBase)public torch::nn::detail::RNNCellImplBase< RNNCellImpl >
(Template Class RNNCellImplBase)public torch::nn::detail::RNNImplBase< RNNImpl >
(Template Class RNNImplBase)public torch::nn::detail::RNNImplBase< LSTMImpl >
(Template Class RNNImplBase)public torch::nn::detail::RNNImplBase< GRUImpl >
(Template Class RNNImplBase)public torch::nn::detail::_DropoutNd< AlphaDropoutImpl >
(Template Class _DropoutNd)public torch::nn::detail::_DropoutNd< FeatureAlphaDropoutImpl >
(Template Class _DropoutNd)public torch::nn::detail::_DropoutNd< DropoutImpl >
(Template Class _DropoutNd)public torch::nn::detail::_DropoutNd< Dropout3dImpl >
(Template Class _DropoutNd)public torch::nn::detail::_DropoutNd< Dropout2dImpl >
(Template Class _DropoutNd)public torch::nn::AdaptiveAvgPoolImpl< D, output_size_t, Derived >
(Template Class AdaptiveAvgPoolImpl)public torch::nn::AdaptiveMaxPoolImpl< D, output_size_t, Derived >
(Template Class AdaptiveMaxPoolImpl)public torch::nn::AvgPoolImpl< D, Derived >
(Template Class AvgPoolImpl)public torch::nn::ConstantPadImpl< D, Derived >
(Template Class ConstantPadImpl)public torch::nn::ConvNdImpl< D, Derived >
(Template Class ConvNdImpl)public torch::nn::LPPoolImpl< D, Derived >
(Template Class LPPoolImpl)public torch::nn::MaxPoolImpl< D, Derived >
(Template Class MaxPoolImpl)public torch::nn::MaxUnpoolImpl< D, Derived >
(Template Class MaxUnpoolImpl)public torch::nn::NormImplBase< D, Derived, DerivedOptions >
(Template Class NormImplBase)public torch::nn::ReflectionPadImpl< D, Derived >
(Template Class ReflectionPadImpl)public torch::nn::ReplicationPadImpl< D, Derived >
(Template Class ReplicationPadImpl)public torch::nn::ZeroPadImpl< D, Derived >
(Template Class ZeroPadImpl)public torch::nn::detail::RNNCellImplBase< Derived >
(Template Class RNNCellImplBase)public torch::nn::detail::RNNImplBase< Derived >
(Template Class RNNImplBase)public torch::nn::detail::_DropoutNd< Derived >
(Template Class _DropoutNd)
Class Documentation¶
-
template<typename Derived>
class Cloneable : public torch::nn::Module¶ The
clone()
method in the baseModule
class does not have knowledge of the concrete runtime type of its subclasses.Therefore,
clone()
must either be called from within the subclass, or from a base class that has knowledge of the concrete type.Cloneable
uses the CRTP to gain knowledge of the subclass’ static type and provide an implementation of theclone()
method. We do not want to use this pattern in the base class, because then storing a module would always require templatizing it.Subclassed by torch::nn::AdaptiveAvgPoolImpl< 1, ExpandingArray< 1 >, AdaptiveAvgPool1dImpl >, torch::nn::AdaptiveAvgPoolImpl< 3, ExpandingArrayWithOptionalElem< 3 >, AdaptiveAvgPool3dImpl >, torch::nn::AdaptiveAvgPoolImpl< 2, ExpandingArrayWithOptionalElem< 2 >, AdaptiveAvgPool2dImpl >, torch::nn::AdaptiveMaxPoolImpl< 1, ExpandingArray< 1 >, AdaptiveMaxPool1dImpl >, torch::nn::AdaptiveMaxPoolImpl< 2, ExpandingArrayWithOptionalElem< 2 >, AdaptiveMaxPool2dImpl >, torch::nn::AdaptiveMaxPoolImpl< 3, ExpandingArrayWithOptionalElem< 3 >, AdaptiveMaxPool3dImpl >, torch::nn::AvgPoolImpl< 2, AvgPool2dImpl >, torch::nn::AvgPoolImpl< 3, AvgPool3dImpl >, torch::nn::AvgPoolImpl< 1, AvgPool1dImpl >, torch::nn::ConstantPadImpl< 1, ConstantPad1dImpl >, torch::nn::ConstantPadImpl< 2, ConstantPad2dImpl >, torch::nn::ConstantPadImpl< 3, ConstantPad3dImpl >, torch::nn::ConvNdImpl< 1, Conv1dImpl >, torch::nn::ConvNdImpl< 3, Conv3dImpl >, torch::nn::ConvNdImpl< 2, Conv2dImpl >, torch::nn::LPPoolImpl< 3, LPPool3dImpl >, torch::nn::LPPoolImpl< 2, LPPool2dImpl >, torch::nn::LPPoolImpl< 1, LPPool1dImpl >, torch::nn::MaxPoolImpl< 1, MaxPool1dImpl >, torch::nn::MaxPoolImpl< 2, MaxPool2dImpl >, torch::nn::MaxPoolImpl< 3, MaxPool3dImpl >, torch::nn::MaxUnpoolImpl< 1, MaxUnpool1dImpl >, torch::nn::MaxUnpoolImpl< 2, MaxUnpool2dImpl >, torch::nn::MaxUnpoolImpl< 3, MaxUnpool3dImpl >, torch::nn::NormImplBase< D, Derived, BatchNormOptions >, torch::nn::NormImplBase< D, Derived, InstanceNormOptions >, torch::nn::ReflectionPadImpl< 3, ReflectionPad3dImpl >, torch::nn::ReflectionPadImpl< 2, ReflectionPad2dImpl >, torch::nn::ReflectionPadImpl< 1, ReflectionPad1dImpl >, torch::nn::ReplicationPadImpl< 3, ReplicationPad3dImpl >, torch::nn::ReplicationPadImpl< 2, ReplicationPad2dImpl >, torch::nn::ReplicationPadImpl< 1, ReplicationPad1dImpl >, torch::nn::ZeroPadImpl< 1, ZeroPad1dImpl >, torch::nn::ZeroPadImpl< 2, ZeroPad2dImpl >, torch::nn::ZeroPadImpl< 3, ZeroPad3dImpl >, torch::nn::detail::RNNCellImplBase< GRUCellImpl >, torch::nn::detail::RNNCellImplBase< LSTMCellImpl >, torch::nn::detail::RNNCellImplBase< RNNCellImpl >, torch::nn::detail::RNNImplBase< RNNImpl >, torch::nn::detail::RNNImplBase< LSTMImpl >, torch::nn::detail::RNNImplBase< GRUImpl >, torch::nn::detail::_DropoutNd< AlphaDropoutImpl >, torch::nn::detail::_DropoutNd< FeatureAlphaDropoutImpl >, torch::nn::detail::_DropoutNd< DropoutImpl >, torch::nn::detail::_DropoutNd< Dropout3dImpl >, torch::nn::detail::_DropoutNd< Dropout2dImpl >, torch::nn::AdaptiveAvgPoolImpl< D, output_size_t, Derived >, torch::nn::AdaptiveMaxPoolImpl< D, output_size_t, Derived >, torch::nn::AvgPoolImpl< D, Derived >, torch::nn::ConstantPadImpl< D, Derived >, torch::nn::ConvNdImpl< D, Derived >, torch::nn::LPPoolImpl< D, Derived >, torch::nn::MaxPoolImpl< D, Derived >, torch::nn::MaxUnpoolImpl< D, Derived >, torch::nn::NormImplBase< D, Derived, DerivedOptions >, torch::nn::ReflectionPadImpl< D, Derived >, torch::nn::ReplicationPadImpl< D, Derived >, torch::nn::ZeroPadImpl< D, Derived >, torch::nn::detail::RNNCellImplBase< Derived >, torch::nn::detail::RNNImplBase< Derived >, torch::nn::detail::_DropoutNd< Derived >
Public Functions
-
virtual void reset() = 0¶
reset()
must perform initialization of all members with reference semantics, most importantly parameters, buffers and submodules.
-
inline virtual std::shared_ptr<Module> clone(const std::optional<Device> &device = std::nullopt) const override¶
Performs a recursive “deep copy” of the
Module
, such that all parameters and submodules in the cloned module are different from those in the original module.
-
virtual void reset() = 0¶