From 51847d5dd9cad6bc81673642a01fd531def44311 Mon Sep 17 00:00:00 2001 From: Giorgio Arena Date: Tue, 19 Oct 2021 15:45:57 +0100 Subject: Implement CLDirectConv3DKernel - uint8/int8 Resolve COMPMID-4663 Signed-off-by: Giorgio Arena Change-Id: I5c3c1cffed5385c06b789543318f7f4d6096987e Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6468 Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins Reviewed-by: Sheri Zhang --- .../fixtures/DirectConvolution3DFixture.h | 51 +++++++++++++++------- 1 file changed, 36 insertions(+), 15 deletions(-) (limited to 'tests/validation/fixtures/DirectConvolution3DFixture.h') diff --git a/tests/validation/fixtures/DirectConvolution3DFixture.h b/tests/validation/fixtures/DirectConvolution3DFixture.h index 3a675ac6d3..2250dcaeb0 100644 --- a/tests/validation/fixtures/DirectConvolution3DFixture.h +++ b/tests/validation/fixtures/DirectConvolution3DFixture.h @@ -40,19 +40,23 @@ template ::value || std::is_same::value, int32_t, T >::type; + template void setup(const TensorShape &input_shape, int stride_x, int stride_y, int stride_z, int pad_x, int pad_y, int pad_z, unsigned int kernel_width, int kernel_height, int kernel_depth, - unsigned int num_kernels, bool has_bias, const ActivationLayerInfo &act_info, const DataType &data_type, const DataLayout &data_layout) + unsigned int num_kernels, bool has_bias, const ActivationLayerInfo &act_info, const DataType &data_type, const DataLayout &data_layout, + const QuantizationInfo &src_qinfo = QuantizationInfo(), const QuantizationInfo &weights_qinfo = QuantizationInfo(), const QuantizationInfo &dst_qinfo = QuantizationInfo()) { ARM_COMPUTE_ERROR_ON(data_layout != DataLayout::NDHWC); const TensorShape weights_shape(num_kernels, input_shape[0], kernel_width, kernel_height, kernel_depth); const TensorShape bias_shape(num_kernels); + const DataType bias_data_type = is_data_type_quantized(data_type) ? DataType::S32 : data_type; const Conv3dInfo conv3d_info(Size3D(stride_x, stride_y, stride_z), Padding3D(pad_x, pad_y, pad_z), act_info, Size3D(1U, 1U, 1U), DimensionRoundingType::FLOOR, false); const TensorShape output_shape = compute_conv3d_shape(input_shape, weights_shape, conv3d_info); - _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, conv3d_info, has_bias, data_type, data_layout); - _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, conv3d_info, has_bias, data_type); + _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, conv3d_info, has_bias, data_type, bias_data_type, data_layout, src_qinfo, weights_qinfo, dst_qinfo); + _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, conv3d_info, has_bias, data_type, bias_data_type, src_qinfo, weights_qinfo, dst_qinfo); } protected: @@ -79,13 +83,14 @@ protected: } TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const Conv3dInfo &conv3d_info, - bool has_bias, const DataType &data_type, const DataLayout &data_layout) + bool has_bias, const DataType &data_type, const DataType &bias_data_type, const DataLayout &data_layout, const QuantizationInfo &src_qinfo, + const QuantizationInfo &weights_qinfo, const QuantizationInfo &dst_qinfo) { // Create tensors - TensorType src = create_tensor(input_shape, data_type, 1, QuantizationInfo(), data_layout); - TensorType weights = create_tensor(weights_shape, data_type, 1, QuantizationInfo(), data_layout); - TensorType bias = has_bias ? create_tensor(bias_shape, data_type, 1, QuantizationInfo()) : TensorType(); - TensorType dst = create_tensor(output_shape, data_type, 1, QuantizationInfo(), data_layout); + TensorType src = create_tensor(input_shape, data_type, 1, src_qinfo, data_layout); + TensorType weights = create_tensor(weights_shape, data_type, 1, weights_qinfo, data_layout); + TensorType bias = has_bias ? create_tensor(bias_shape, bias_data_type, 1, QuantizationInfo()) : TensorType(); + TensorType dst = create_tensor(output_shape, data_type, 1, dst_qinfo, data_layout); // Create and configure function FunctionType conv{}; @@ -122,14 +127,15 @@ protected: return dst; } - SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const Conv3dInfo &conv3d_info, - bool has_bias, const DataType &data_type) + SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, + const Conv3dInfo &conv3d_info, bool has_bias, const DataType &data_type, const DataType &bias_data_type, const QuantizationInfo &src_qinfo, + const QuantizationInfo &weights_qinfo, const QuantizationInfo &dst_qinfo) { // Create reference - SimpleTensor src{ input_shape, data_type }; - SimpleTensor weights{ weights_shape, data_type }; - SimpleTensor bias{ bias_shape, data_type }; - SimpleTensor dst{ output_shape, data_type }; + SimpleTensor src{ input_shape, data_type, 1, src_qinfo }; + SimpleTensor weights{ weights_shape, data_type, 1, weights_qinfo }; + SimpleTensor bias{ bias_shape, bias_data_type }; + SimpleTensor dst{ output_shape, data_type, 1, dst_qinfo }; // Fill reference fill(src, 0); @@ -140,7 +146,7 @@ protected: fill(bias, 2); } - return reference::activation_layer(reference::conv3d(src, weights, bias, dst, conv3d_info), conv3d_info.act_info); + return reference::activation_layer(reference::conv3d(src, weights, bias, dst, conv3d_info), conv3d_info.act_info); } TensorType _target{}; @@ -159,6 +165,21 @@ public: kernel_depth, num_kernels, has_bias, act_info, data_type, data_layout); } }; + +template +class DirectConvolution3DValidationQuantizedFixture : public DirectConvolution3DValidationGenericFixture +{ +public: + template + void setup(TensorShape input_shape, int stride_x, int stride_y, int stride_z, int pad_x, int pad_y, int pad_z, unsigned int kernel_width, int kernel_height, int kernel_depth, + unsigned int num_kernels, bool has_bias, ActivationLayerInfo act_info, DataType data_type, DataLayout data_layout, QuantizationInfo src_qinfo, QuantizationInfo weights_qinfo, + QuantizationInfo dst_qinfo) + { + DirectConvolution3DValidationGenericFixture::setup(input_shape, stride_x, stride_y, stride_z, pad_x, pad_y, pad_z, kernel_width, kernel_height, + kernel_depth, num_kernels, has_bias, act_info, data_type, data_layout, src_qinfo, + weights_qinfo, dst_qinfo); + } +}; } // namespace validation } // namespace test } // namespace arm_compute -- cgit v1.2.1