DLPrimitives
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dlprim::TransposedConvolution2D Class Reference
Inheritance diagram for dlprim::TransposedConvolution2D:
dlprim::Operator dlprim::Convolution2DBase

Public Member Functions

 TransposedConvolution2D (Context &ctx, TransposedConvolution2DConfig const &cfg)
 
virtual char const * operator_type () const
 name of the operator type
 
void initialize_params (std::vector< Tensor > &parameters, ExecutionContext const &e)
 Set default parameters iniitalization.
 
virtual void setup (std::vector< TensorSpecs > const &in, std::vector< TensorSpecs > &out, std::vector< TensorSpecs > &parameters, size_t &workspace)
 Convigure operator. More...
 
virtual void reshape (std::vector< Shape > const &in, std::vector< Shape > &out, size_t &ws)
 Reshape layer according to new input size. More...
 
virtual void forward (std::vector< Tensor > &input, std::vector< Tensor > &output, std::vector< Tensor > &parameters, Tensor &workspace, ExecutionContext const &ctx)
 Enqueue forward propogation computations. More...
 
virtual void backward (std::vector< TensorAndGradient > &input, std::vector< TensorAndGradient > &output, std::vector< TensorAndGradient > &parameters, Tensor &workspace, ExecutionContext const &ctx)
 Enqueue backward propogation computations. More...
 
Shape get_output_shape (Shape const &in)
 
- Public Member Functions inherited from dlprim::Operator
 Operator (Context const &ctx)
 Create operator for specific context (device/platform)
 
SharedResourceshared_resource ()
 Getter for object that is shared between operators accross the net, for example random numbers generator.
 
void shared_resource (std::shared_ptr< SharedResource > r)
 Setter of the shared resource.
 
virtual void mode (CalculationsMode mode)
 Can be called with both train and predict before setup() is called. afterwards if original mode was train - it can be switched to predict and back but if original mode was predict it can't be switched to train. More...
 
virtual CalculationsMode mode ()
 get current mode
 
 Operator (Operator const &)=delete
 operator non-copyable/moveable More...
 
void operator= (Operator const &)=delete
 
 Operator (Operator &&)=delete
 
void operator= (Operator &&)=delete
 
virtual bool alias_generator ()
 returns true of the operator is alias - generation - it only changes the shape of tensor but not its content it actually does not perform any operation but only changes semantics, in this casse input and output are aliases of each other
 

Protected Member Functions

size_t calc_workspace (Shape const &in)
 
void setup_algo (Shape const &in)
 
int get_im2col_width ()
 
void forward_gpu (Tensor &in, Tensor &out, Tensor &M, Tensor *bias, ExecutionContext const &ctx)
 
void forward_cpu (Tensor &in, Tensor &out, Tensor &M, Tensor *bias, void *ws)
 
void backward_filter_cpu (Tensor &dy, Tensor &x, Tensor &dK, Tensor &ws, float factor)
 
void backward_data_cpu (Tensor &dy, Tensor &K, Tensor &dx, Tensor &ws, float factor)
 

Protected Attributes

TransposedConvolution2DConfig config_
 
Convolution2DConfig conv_config_
 
DataType dtype_
 
std::unique_ptr< core::Conv2DForwardconv_bwd_data_
 
std::unique_ptr< core::Conv2DBackwardDataconv_fwd_
 
std::unique_ptr< core::Conv2DBackwardFilterconv_bwd_filter_
 
std::unique_ptr< Operatoractivation_
 
std::unique_ptr< BWBiasbwd_bias_
 
size_t ws_size_
 
size_t out_h_
 
size_t out_w_
 
size_t in_h_
 
size_t in_w_
 
size_t bs_
 
- Protected Attributes inherited from dlprim::Operator
Context ctx_
 OpenCL/CPU Context to work with.
 
CalculationsMode mode_
 computaions mode
 
std::shared_ptr< SharedResourceshared_resource_
 

Additional Inherited Members

- Static Protected Member Functions inherited from dlprim::Convolution2DBase
template<typename Op , typename DType >
static void im2col (Shape const &in, Shape const &outs, DType *img_in, DType *mat_in, Convolution2DConfig const &config)
 
static void fwd_bwd_cpu (GemmOpMode mode, Tensor &in, Tensor &out, Tensor &W, Tensor *bias_tensor, void *ws, Convolution2DConfig const &config, float fwd_beta=0.0f)
 
static void scale_cpu (Tensor &t, float v)
 

Member Function Documentation

virtual void dlprim::TransposedConvolution2D::backward ( std::vector< TensorAndGradient > &  ,
std::vector< TensorAndGradient > &  ,
std::vector< TensorAndGradient > &  ,
Tensor ,
ExecutionContext const &   
)
virtual

Enqueue backward propogation computations.

Parameters
input- inputs and their gradients marked for computatins
output- outputs and their gradients
parameters- parameters parameters and their gradients
workspace- workspace as required
ctx- execution context

Note: actual inputs are

  • inputs[index].data
  • outputs[index].data
  • outputs[index].diff
  • parameters[index].data

And it computes in backpropogation

  • inputs[index].diff
  • parameters[index].diff

If computation is not needed TensorAndGradient::requires_gradient need to be set to false

Reimplemented from dlprim::Operator.

virtual void dlprim::TransposedConvolution2D::forward ( std::vector< Tensor > &  input,
std::vector< Tensor > &  output,
std::vector< Tensor > &  parameters,
Tensor workspace,
ExecutionContext const &  ctx 
)
virtual

Enqueue forward propogation computations.

Parameters
input- input tesnosrs (X)
output- output tesnors (Y)
parameters- parameters for computation
workspace- workspace as required
ctx- execution context

Implements dlprim::Operator.

virtual void dlprim::TransposedConvolution2D::reshape ( std::vector< Shape > const &  in,
std::vector< Shape > &  out,
size_t &  workspace 
)
virtual

Reshape layer according to new input size.

Parameters
in- new input tensor sizes
out- new output tesor sizes
workspace- new workspace size needed

Implements dlprim::Operator.

virtual void dlprim::TransposedConvolution2D::setup ( std::vector< TensorSpecs > const &  in,
std::vector< TensorSpecs > &  out,
std::vector< TensorSpecs > &  parameters,
size_t &  workspace 
)
virtual

Convigure operator.

Parameters
in- a list of expected input tensors
out- a list of output tensots - that opertor calculates in fwd propogation
parameters- a list of parameters need for computation. If parameter should not participate in gradient desend it should be marked as not trainable
workspacesize needed for computations in bytes - not preserved between different calls

Implements dlprim::Operator.


The documentation for this class was generated from the following file: