Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / api / CPP / deconvolution.hpp
index f1de10d..21607b1 100644 (file)
@@ -63,16 +63,88 @@ struct deconvolution : public primitive_base<deconvolution, CLDNN_PRIMITIVE_DESC
         , with_activation(with_activation)
         , activation_negative_slope(activation_slp)
         , with_output_size(false)
+        , groups(1)
         , _weights(weights)
         , _bias(bias)
         , _gradient(false)
     {
     }
+    /// @brief Constructs deconvolution primitive.
+    /// @param id This primitive id.
+    /// @param input Input primitive id.
+    /// @param groups Number of filter groups.
+    /// @param weights List of primitive ids containing weights data.
+    /// @param bias List of primitive ids containing bias data. Provide empty vector if using next parameters without bias.
+    /// @param input_offset Defines a shift, relative to (0,0) position of the input buffer, where (0,0) point of the deconvolution window should start calculations.
+    /// @param stride Defines shift in input buffer between adjacent calculations of output values.
+    /// @param with_activation Enables Relu activation.
+    /// @param activation_slp Relu activation slope.
+    deconvolution(
+        const primitive_id& id,
+        const primitive_id& input,
+        const std::vector<primitive_id>& weights,
+        const std::vector<primitive_id>& bias,
+        uint32_t groups,
+        tensor stride = { 1, 1, 1, 1 },
+        tensor input_offset = { 0,0,0,0 },
+        bool with_activation = false,
+        float activation_slp = 0.0f,
+        const padding& output_padding = padding()
+    )
+        :primitive_base(id, { input }, output_padding)
+        , weights(_weights.cpp_ids)
+        , bias(_bias.cpp_ids)
+        , input_offset(input_offset)
+        , stride(stride)
+        , with_activation(with_activation)
+        , activation_negative_slope(activation_slp)
+        , with_output_size(false)
+        , groups(groups)
+        , _weights(weights)
+        , _bias(bias)
+        , _gradient(false)
+    {
+    }
+
+    /// @brief Constructs deconvolution primitive (w/o bias).
+    /// @param id This primitive id.
+    /// @param input Input primitive id.
+    /// @param weights List of primitive ids containing weights data.
+    /// @param input_offset Defines a shift, relative to (0,0) position of the input buffer, where (0,0) point of the deconvolution window should start calculations.
+    /// @param stride Defines shift in input buffer between adjacent calculations of output values.
+    /// @param with_activation Enables Relu activation.
+    /// @param activation_slp Relu activation slope.
+    deconvolution(
+        const primitive_id& id,
+        const primitive_id& input,
+        const std::vector<primitive_id>& weights,
+        tensor stride = { 1, 1, 1, 1 },
+        tensor input_offset = { 0,0,0,0 },
+        bool with_activation = false,
+        float activation_slp = 0.0f,
+        const padding& output_padding = padding(),
+        bool gradient = false
+    )
+        :primitive_base(id, { input }, output_padding)
+        , weights(_weights.cpp_ids)
+        , bias(_bias.cpp_ids)
+        , input_offset(input_offset)
+        , stride(stride)
+        , with_activation(with_activation)
+        , activation_negative_slope(activation_slp)
+        , with_output_size(false)
+        , groups(1)
+        , _weights(weights)
+        , _bias(std::vector<primitive_id>(0))
+        , _gradient(gradient)
+    {
+    }
 
     /// @brief Constructs deconvolution primitive (w/o bias).
     /// @param id This primitive id.
     /// @param input Input primitive id.
     /// @param weights List of primitive ids containing weights data.
+    /// @param groups Number of filter groups.
     /// @param input_offset Defines a shift, relative to (0,0) position of the input buffer, where (0,0) point of the deconvolution window should start calculations.
     /// @param stride Defines shift in input buffer between adjacent calculations of output values.
     /// @param with_activation Enables Relu activation.
@@ -81,6 +153,7 @@ struct deconvolution : public primitive_base<deconvolution, CLDNN_PRIMITIVE_DESC
         const primitive_id& id,
         const primitive_id& input,
         const std::vector<primitive_id>& weights,
+        uint32_t groups,
         tensor stride = { 1, 1, 1, 1 },
         tensor input_offset = { 0,0,0,0 },
         bool with_activation = false,
@@ -96,6 +169,7 @@ struct deconvolution : public primitive_base<deconvolution, CLDNN_PRIMITIVE_DESC
         , with_activation(with_activation)
         , activation_negative_slope(activation_slp)
         , with_output_size(false)
+        , groups(groups)
         , _weights(weights)
         , _bias(std::vector<primitive_id>(0))
         , _gradient(gradient)
@@ -133,12 +207,54 @@ struct deconvolution : public primitive_base<deconvolution, CLDNN_PRIMITIVE_DESC
         , activation_negative_slope(activation_slp)
         , with_output_size(true)
         , output_size(output_size)
+        , groups(1)
+        , _weights(weights)
+        , _bias(bias)
+        , _gradient(false)
+    {
+    }
+
+    /// @brief Constructs deconvolution primitive (computes input paddings to match output size).
+    /// @param id This primitive id.
+    /// @param input Input primitive id.
+    /// @param weights List of primitive ids containing weights data.
+    /// @param bias List of primitive ids containing bias data. Provide empty vector if using next parameters without bias.
+    /// @param groups Number of filter groups.
+    /// @param input_offset Defines a shift, relative to (0,0) position of the input buffer, where (0,0) point of the deconvolution window should start calculations.
+    /// @param stride Defines shift in input buffer between adjacent calculations of output values.
+    /// @param with_activation Enables Relu activation.
+    /// @param activation_slp Relu activation slope.
+    /// @param output_size User-defined output data size of the primitive (w/o padding).
+    deconvolution(
+        const primitive_id& id,
+        const primitive_id& input,
+        const std::vector<primitive_id>& weights,
+        const std::vector<primitive_id>& bias,
+        uint32_t groups,
+        tensor stride,
+        tensor input_offset,
+        bool with_activation,
+        float activation_slp,
+        tensor output_size,
+        const padding& output_padding = padding()
+    )
+        :primitive_base(id, { input }, output_padding)
+        , weights(_weights.cpp_ids)
+        , bias(_bias.cpp_ids)
+        , input_offset(input_offset)
+        , stride(stride)
+        , with_activation(with_activation)
+        , activation_negative_slope(activation_slp)
+        , with_output_size(true)
+        , output_size(output_size)
+        , groups(groups)
         , _weights(weights)
         , _bias(bias)
         , _gradient(false)
     {
     }
 
+
     /// @brief Constructs deconvolution primitive (w/o bias, computes input paddings to match output size).
     /// @param id This primitive id.
     /// @param input Input primitive id.
@@ -169,6 +285,7 @@ struct deconvolution : public primitive_base<deconvolution, CLDNN_PRIMITIVE_DESC
         , activation_negative_slope(activation_slp)
         , with_output_size(true)
         , output_size(output_size)
+        , groups(1)
         , _weights(weights)
         , _bias(std::vector<primitive_id>(0))
         , _gradient(gradient)
@@ -186,6 +303,7 @@ struct deconvolution : public primitive_base<deconvolution, CLDNN_PRIMITIVE_DESC
         , activation_negative_slope(dto->activation_negative_slope)
         , with_output_size(dto->with_output_size != 0)
         , output_size(dto->output_size)
+        , groups(dto->groups)
         , _weights(dto->weights)
         , _bias(dto->bias)
         , _gradient(dto->gradient != 0)
@@ -264,6 +382,8 @@ struct deconvolution : public primitive_base<deconvolution, CLDNN_PRIMITIVE_DESC
     bool with_output_size;
     /// @brief User-defined output data size of the primitive (w/o padding).
     tensor output_size;
+    /// @brief Number of feature groups (grouped convolution). If more than 1 then weights/bias count needs to be 1.
+    uint32_t groups;
 
     /// @brief On how many cards split the computation to.
     int32_t split() const { return static_cast<int32_t>(weights.size()); }
@@ -299,9 +419,10 @@ protected:
         dto.with_output_size = with_output_size;
         dto.output_size = output_size;
         dto.gradient = _gradient;
+        dto.groups = groups;
     }
 };
 /// @}
 /// @}
 /// @}
-}
\ No newline at end of file
+}