, with_activation(with_activation)
, activation_negative_slope(activation_slp)
, with_output_size(false)
+ , groups(1)
+ , padding_above(tensor(0, 0, 0, 0))
+ , padding_below(tensor(0, 0, 0, 0))
, _weights(weights)
, _bias(bias)
, _weights_quantization_factors(std::vector<primitive_id>(0))
throw std::runtime_error("convolution's weights/bias count does not match");
}
+ /// @brief Constructs convolution primitive.
+ /// @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.
+ /// @param stride Defines shift in input buffer between adjacent calculations of output values.
+ /// @param dilation Defines gaps in the input - dilation rate k=1 is normal convolution, k=2 means skipping one pixel per input, k=4 means skipping 3 pixels.
+ /// As an example in one dimension, a filter w of size 3 would compute over input x the following: w[0]*x[0] + w[1]*x[1] + w[2]*x[2] for dilation of 1.
+ /// For dilation 2 the filter would instead compute w[0]*x[0] + w[1]*x[2] + w[2]*x[4].
+ /// @param padding_above Defines a padding added to input image on left (x axis) and top (y axis).
+ /// @param padding_below Defines a padding added to input image on right (x axis) and bottom (y axis).
+ /// @param with_activation Enable Relu activation.
+ /// @param activation_slp Relu activation slope.
+ convolution(
+ const primitive_id& id,
+ const primitive_id& input,
+ const std::vector<primitive_id>& weights,
+ const std::vector<primitive_id>& bias,
+ tensor stride,
+ tensor input_offset,
+ tensor dilation,
+ tensor padding_above,
+ tensor padding_below,
+ 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)
+ , weights_quantization_factors(_weights_quantization_factors.cpp_ids)
+ , output_calibration_factors(_output_calibration_factors.cpp_ids)
+ , input_quantization_factor(1.0f)
+ , output_quantization_factor(1.0f)
+ , input_offset(input_offset)
+ , stride(stride)
+ , dilation(dilation)
+ , with_activation(with_activation)
+ , activation_negative_slope(activation_slp)
+ , with_output_size(false)
+ , groups(1)
+ , padding_above(padding_above)
+ , padding_below(padding_below)
+ , _weights(weights)
+ , _bias(bias)
+ , _weights_quantization_factors(std::vector<primitive_id>(0))
+ , _output_calibration_factors(std::vector<primitive_id>(0))
+ {
+ if ((bias.size() != 0) && (weights.size() != bias.size()))
+ throw std::runtime_error("convolution's weights/bias count does not match");
+ }
+
+ /// @brief Constructs convolution primitive.
+ /// @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 bias List of primitive ids containing bias data.
+ /// @param stride Defines shift in input buffer between adjacent calculations of output values.
+ /// @param dilation Defines gaps in the input - dilation rate k=1 is normal convolution, k=2 means skipping one pixel per input, k=4 means skipping 3 pixels.
+ /// As an example in one dimension, a filter w of size 3 would compute over input x the following: w[0]*x[0] + w[1]*x[1] + w[2]*x[2] for dilation of 1.
+ /// For dilation 2 the filter would instead compute w[0]*x[0] + w[1]*x[2] + w[2]*x[4].
+ /// @param padding_above Defines a padding added to input image on left (x axis) and top (y axis).
+ /// @param padding_below Defines a padding added to input image on right (x axis) and bottom (y axis).
+ /// @param with_activation Enable Relu activation.
+ /// @param activation_slp Relu activation slope.
+ convolution(
+ 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,
+ tensor dilation,
+ tensor padding_above,
+ tensor padding_below,
+ 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)
+ , weights_quantization_factors(_weights_quantization_factors.cpp_ids)
+ , output_calibration_factors(_output_calibration_factors.cpp_ids)
+ , input_quantization_factor(1.0f)
+ , output_quantization_factor(1.0f)
+ , input_offset(input_offset)
+ , stride(stride)
+ , dilation(dilation)
+ , with_activation(with_activation)
+ , activation_negative_slope(activation_slp)
+ , with_output_size(false)
+ , groups(groups)
+ , padding_above(padding_above)
+ , padding_below(padding_below)
+ , _weights(weights)
+ , _bias(bias)
+ , _weights_quantization_factors(std::vector<primitive_id>(0))
+ , _output_calibration_factors(std::vector<primitive_id>(0))
+ {
+ if ((bias.size() != 0) && (weights.size() != bias.size()))
+ throw std::runtime_error("convolution's weights/bias count does not match");
+ }
+
+ /// @brief Constructs convolution primitive.
+ /// @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 bias List of primitive ids containing bias data.
+ /// @param stride Defines shift in input buffer between adjacent calculations of output values.
+ /// @param dilation Defines gaps in the input - dilation rate k=1 is normal convolution, k=2 means skipping one pixel per input, k=4 means skipping 3 pixels.
+ /// As an example in one dimension, a filter w of size 3 would compute over input x the following: w[0]*x[0] + w[1]*x[1] + w[2]*x[2] for dilation of 1.
+ /// For dilation 2 the filter would instead compute w[0]*x[0] + w[1]*x[2] + w[2]*x[4].
+ /// @param with_activation Enable Relu activation.
+ /// @param activation_slp Relu activation slope.
+ /// @param output_size User-defined output data size of the primitive (w/o padding).
+ convolution(
+ 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,
+ tensor dilation,
+ 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)
+ , weights_quantization_factors(_weights_quantization_factors.cpp_ids)
+ , output_calibration_factors(_output_calibration_factors.cpp_ids)
+ , input_quantization_factor(1.0f)
+ , output_quantization_factor(1.0f)
+ , input_offset(input_offset)
+ , stride(stride)
+ , dilation(dilation)
+ , with_activation(with_activation)
+ , activation_negative_slope(activation_slp)
+ , with_output_size(true)
+ , output_size(output_size)
+ , groups(groups)
+ , padding_above(tensor(0, 0, 0, 0))
+ , padding_below(tensor(0, 0, 0, 0))
+ , _weights(weights)
+ , _bias(bias)
+ , _weights_quantization_factors(std::vector<primitive_id>(0))
+ , _output_calibration_factors(std::vector<primitive_id>(0))
+ {
+ if ((bias.size() != 0) && (weights.size() != bias.size()))
+ throw std::runtime_error("convolution's weights/bias count does not match");
+ }
+
+ /// @brief Constructs convolution primitive.
+ /// @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 bias List of primitive ids containing bias data.
+ /// @param input_offset Defines a shift, relative to (0,0) position of the input buffer, where (0,0) point of the convolution window should start calculations.
+ /// @param stride Defines shift in input buffer between adjacent calculations of output values.
+ /// @param dilation Defines gaps in the input - dilation rate k=1 is normal convolution, k=2 means skipping one pixel per input, k=4 means skipping 3 pixels.
+ /// As an example in one dimension, a filter w of size 3 would compute over input x the following: w[0]*x[0] + w[1]*x[1] + w[2]*x[2] for dilation of 1.
+ /// For dilation 2 the filter would instead compute w[0]*x[0] + w[1]*x[2] + w[2]*x[4].
+ /// @param with_activation Enable Relu activation.
+ /// @param activation_slp Relu activation slope.
+ convolution(
+ 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 },
+ tensor dilation = { 1, 1, 1, 1 },
+ 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)
+ , weights_quantization_factors(_weights_quantization_factors.cpp_ids)
+ , output_calibration_factors(_output_calibration_factors.cpp_ids)
+ , input_quantization_factor(1.0f)
+ , output_quantization_factor(1.0f)
+ , input_offset(input_offset)
+ , stride(stride)
+ , dilation(dilation)
+ , with_activation(with_activation)
+ , activation_negative_slope(activation_slp)
+ , with_output_size(false)
+ , groups(groups)
+ , padding_above(tensor(0, 0, 0, 0))
+ , padding_below(tensor(0, 0, 0, 0))
+ , _weights(weights)
+ , _bias(bias)
+ , _weights_quantization_factors(std::vector<primitive_id>(0))
+ , _output_calibration_factors(std::vector<primitive_id>(0))
+ {
+ if ((bias.size() != 0) && (weights.size() != bias.size()))
+ throw std::runtime_error("convolution's weights/bias count does not match");
+ if ((groups > 1) && ((weights.size() != 1) || ((bias.size() != 0) && (bias.size() != 1))))
+ throw std::runtime_error("grouped convolution's weights/bias count must be 1");
+ }
/// @brief Constructs convolution primitive.
/// @param id This primitive id.
, with_activation(with_activation)
, activation_negative_slope(activation_slp)
, with_output_size(false)
+ , groups(1)
+ , padding_above(tensor(0, 0, 0, 0))
+ , padding_below(tensor(0, 0, 0, 0))
, _weights(weights)
, _bias(bias)
, _weights_quantization_factors(w_quantization_factor)
, with_activation(with_activation)
, activation_negative_slope(activation_slp)
, with_output_size(false)
+ , groups(1)
+ , padding_above(tensor(0, 0, 0, 0))
+ , padding_below(tensor(0, 0, 0, 0))
, _weights(weights)
, _bias(bias)
, _weights_quantization_factors(w_quantization_factor)
, with_activation(with_activation)
, activation_negative_slope(activation_slp)
, with_output_size(false)
+ , groups(1)
+ , padding_above(tensor(0, 0, 0, 0))
+ , padding_below(tensor(0, 0, 0, 0))
+ , _weights(weights)
+ , _bias(std::vector<primitive_id>(0))
+ , _weights_quantization_factors(std::vector<primitive_id>(0))
+ , _output_calibration_factors(std::vector<primitive_id>(0))
+ {
+ }
+
+ /// @brief Constructs convolution 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 convolution window should start calculations.
+ /// @param stride Defines shift in input buffer between adjacent calculations of output values.
+ /// @param dilation Defines gaps in the input - dilation rate k=1 is normal convolution, k=2 means skipping one pixel per input, k=4 means skipping 3 pixels.
+ /// As an example in one dimension, a filter w of size 3 would compute over input x the following: w[0]*x[0] + w[1]*x[1] + w[2]*x[2] for dilation of 1.
+ /// For dilation 2 the filter would instead compute w[0]*x[0] + w[1]*x[2] + w[2]*x[4].
+ /// @param padding_above Defines a padding added to input image on left (x axis) and top (y axis).
+ /// @param padding_below Defines a padding added to input image on right (x axis) and bottom (y axis).
+ /// @param with_activation Enable Relu activation.
+ /// @param activation_slp Relu activation slope.
+ convolution(
+ const primitive_id& id,
+ const primitive_id& input,
+ const std::vector<primitive_id>& weights,
+ tensor stride,
+ tensor input_offset,
+ tensor dilation,
+ tensor padding_above,
+ tensor padding_below,
+ 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)
+ , weights_quantization_factors(_weights_quantization_factors.cpp_ids)
+ , output_calibration_factors(_output_calibration_factors.cpp_ids)
+ , input_quantization_factor(1.0f)
+ , output_quantization_factor(1.0f)
+ , input_offset(input_offset)
+ , stride(stride)
+ , dilation(dilation)
+ , with_activation(with_activation)
+ , activation_negative_slope(activation_slp)
+ , with_output_size(false)
+ , groups(1)
+ , padding_above(padding_above)
+ , padding_below(padding_below)
+ , _weights(weights)
+ , _bias(std::vector<primitive_id>(0))
+ , _weights_quantization_factors(std::vector<primitive_id>(0))
+ , _output_calibration_factors(std::vector<primitive_id>(0))
+ {
+ }
+
+ /// @brief Constructs convolution 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 convolution window should start calculations.
+ /// @param stride Defines shift in input buffer between adjacent calculations of output values.
+ /// @param dilation Defines gaps in the input - dilation rate k=1 is normal convolution, k=2 means skipping one pixel per input, k=4 means skipping 3 pixels.
+ /// As an example in one dimension, a filter w of size 3 would compute over input x the following: w[0]*x[0] + w[1]*x[1] + w[2]*x[2] for dilation of 1.
+ /// For dilation 2 the filter would instead compute w[0]*x[0] + w[1]*x[2] + w[2]*x[4].
+ /// @param padding_above Defines a padding added to input image on left (x axis) and top (y axis).
+ /// @param padding_below Defines a padding added to input image on right (x axis) and bottom (y axis).
+ /// @param with_activation Enable Relu activation.
+ /// @param activation_slp Relu activation slope.
+ convolution(
+ const primitive_id& id,
+ const primitive_id& input,
+ const std::vector<primitive_id>& weights,
+ uint32_t groups,
+ tensor stride,
+ tensor input_offset,
+ tensor dilation,
+ tensor padding_above,
+ tensor padding_below,
+ 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)
+ , weights_quantization_factors(_weights_quantization_factors.cpp_ids)
+ , output_calibration_factors(_output_calibration_factors.cpp_ids)
+ , input_quantization_factor(1.0f)
+ , output_quantization_factor(1.0f)
+ , input_offset(input_offset)
+ , stride(stride)
+ , dilation(dilation)
+ , with_activation(with_activation)
+ , activation_negative_slope(activation_slp)
+ , with_output_size(false)
+ , groups(groups)
+ , padding_above(padding_above)
+ , padding_below(padding_below)
+ , _weights(weights)
+ , _bias(std::vector<primitive_id>(0))
+ , _weights_quantization_factors(std::vector<primitive_id>(0))
+ , _output_calibration_factors(std::vector<primitive_id>(0))
+ {
+ }
+
+ /// @brief Constructs convolution 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 convolution window should start calculations.
+ /// @param stride Defines shift in input buffer between adjacent calculations of output values.
+ /// @param dilation Defines gaps in the input - dilation rate k=1 is normal convolution, k=2 means skipping one pixel per input, k=4 means skipping 3 pixels.
+ /// As an example in one dimension, a filter w of size 3 would compute over input x the following: w[0]*x[0] + w[1]*x[1] + w[2]*x[2] for dilation of 1.
+ /// For dilation 2 the filter would instead compute w[0]*x[0] + w[1]*x[2] + w[2]*x[4].
+ /// @param with_activation Enable Relu activation.
+ /// @param activation_slp Relu activation slope.
+ convolution(
+ 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 },
+ tensor dilation = { 1, 1, 1, 1 },
+ 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)
+ , weights_quantization_factors(_weights_quantization_factors.cpp_ids)
+ , output_calibration_factors(_output_calibration_factors.cpp_ids)
+ , input_quantization_factor(1.0f)
+ , output_quantization_factor(1.0f)
+ , input_offset(input_offset)
+ , stride(stride)
+ , dilation(dilation)
+ , with_activation(with_activation)
+ , activation_negative_slope(activation_slp)
+ , with_output_size(false)
+ , groups(groups)
+ , padding_above(tensor(0, 0, 0, 0))
+ , padding_below(tensor(0, 0, 0, 0))
, _weights(weights)
, _bias(std::vector<primitive_id>(0))
, _weights_quantization_factors(std::vector<primitive_id>(0))
, activation_negative_slope(activation_slp)
, with_output_size(true)
, output_size(output_size)
+ , groups(1)
+ , padding_above(tensor(0, 0, 0, 0))
+ , padding_below(tensor(0, 0, 0, 0))
, _weights(weights)
, _bias(bias)
, _weights_quantization_factors(std::vector<primitive_id>(0))
, activation_negative_slope(activation_slp)
, with_output_size(true)
, output_size(output_size)
+ , groups(1)
+ , padding_above(tensor(0, 0, 0, 0))
+ , padding_below(tensor(0, 0, 0, 0))
, _weights(weights)
, _bias(std::vector<primitive_id>(0))
, _weights_quantization_factors(std::vector<primitive_id>(0))
, activation_negative_slope(dto->activation_negative_slope)
, with_output_size(dto->with_output_size != 0)
, output_size(dto->output_size)
+ , groups(dto->groups)
+ , padding_above(dto->padding_above)
+ , padding_below(dto->padding_below)
, _weights(dto->weights)
, _bias(dto->bias)
, _weights_quantization_factors(dto->weights_quantization_factors)
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;
+ /// @param padding_above Defines a padding added to input image on left (x axis) and top (y axis).
+ tensor padding_above;
+ /// @param padding_below Defines a padding added to input image on right (x axis) and bottom (y axis).
+ tensor padding_below;
/// @brief On how many cards split the computation to.
int32_t split() const { return static_cast<int32_t>(weights.size()); }
dto.dilation = dilation;
dto.with_output_size = with_output_size;
dto.output_size = output_size;
-
+ dto.groups = groups;
+ dto.padding_above = padding_above;
+ dto.padding_below = padding_below;
}
};
/// @}