37 #include "tests/datasets/LargeConvolutionLayerDataset.h" 38 #include "tests/datasets/SmallConvolutionLayerDataset.h" 39 #include "tests/datasets/TinyConvolutionLayerDataset.h" 44 #include "tests/validation/fixtures/ConvolutionLayerFixture.h" 45 #include "tests/validation/fixtures/WinogradConvolutionLayerFixture.h" 64 func.configure(src, weights, bias, dst, conv_info);
74 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 79 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 85 #ifdef ARM_COMPUTE_ENABLE_SME 89 #else // ARM_COMPUTE_ENABLE_SME 91 #endif // ARM_COMPUTE_ENABLE_SME 96 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 153 &weights_info.clone()->set_is_resizable(
true),
162 template <
typename T>
163 using NEWinogradConvolutionLayerFixture = WinogradConvolutionLayerFastMathValidationFixture<Tensor, Accessor, NEWinogradConvolutionLayer, T>;
164 template <
typename T>
167 template <
typename T>
179 auto winograd = std::make_unique<cpu::CpuWinogradConv2d>();
186 winograd->configure(&src_info, &b_info, &w_info, &dst_info, pad_info);
189 auto a = create_tensor<Tensor>(
src_info);
190 auto b = create_tensor<Tensor>(b_info);
191 auto c = create_tensor<Tensor>(w_info);
192 a.allocator()->allocate();
193 b.allocator()->allocate();
194 c.allocator()->allocate();
200 auto ws = manage_workspace<Tensor>(winograd->workspace(), mg, run_pack, prep_pack);
201 auto run_conv = [&]() ->
Tensor 203 auto dst = create_tensor<Tensor>(dst_info);
204 dst.allocator()->allocate();
212 winograd->prepare(prep_pack);
213 winograd->run(run_pack);
217 auto result_0 = run_conv();
218 auto result_1 = run_conv();
220 for(
size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i)
235 auto gemm = std::make_unique<NEWinogradConvolutionLayer>();
242 auto run_conv = [&]()
245 auto w = create_tensor<Tensor>(w_info);
246 auto b = create_tensor<Tensor>(b_info);
247 auto dst = create_tensor<Tensor>(dst_info);
249 gemm->configure(&
src, &b, &w, &dst, pad_info);
251 src.allocator()->allocate();
252 b.allocator()->allocate();
253 w.allocator()->allocate();
254 dst.allocator()->allocate();
263 auto result_0 = run_conv();
264 auto result_1 = run_conv();
266 for(
size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i)
278 ActivationFunctionsDataset),
293 ActivationFunctionsDataset),
302 ActivationFunctionsDataset),
315 ActivationFunctionsDataset),
324 ActivationFunctionsDataset),
337 ActivationFunctionsDataset),
346 ActivationFunctionsDataset),
359 ActivationFunctionsDataset),
368 ActivationFunctionsDataset),
381 ActivationFunctionsDataset),
391 ActivationFunctionsDataset),
403 ActivationFunctionsDataset),
413 ActivationFunctionsDataset),
425 ActivationFunctionsDataset),
435 ActivationFunctionsDataset),
449 ActivationFunctionsDataset),
459 ActivationFunctionsDataset),
471 datasets::SmallWinogradConvolutionLayer5x5Dataset()),
473 ActivationFunctionsDataset),
483 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 507 &weights_info.clone()->set_is_resizable(
true),
516 ActivationFunctionsDataset),
527 ActivationFunctionsDataset),
539 #ifdef ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS 545 template <
typename ConvolutionClass>
546 using HasOptImplFixtureNoFastMath = HasOptImplFixture<ConvolutionClass,
false>;
548 template <
typename ConvolutionClass>
549 using HasOptImplFixtureFastMath = HasOptImplFixture<ConvolutionClass,
true>;
599 #if defined(ARM_COMPUTE_ENABLE_BF16) 617 #endif // ARM_COMPUTE_ENABLE_BF16 679 #if defined(ARM_COMPUTE_ENABLE_BF16) 701 #endif // ARM_COMPUTE_ENABLE_BF16 705 using TestCaseType = std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat>;
767 prepare_weights_shapes, shapes)
770 const TensorShape expected_shape = std::get<1>(shapes);
774 const auto TI =
TensorInfo(input_shape, 1 , DT, DL);
775 const TensorInfo computed_info = ::arm_compute::test::validation::prepare_weights(TI, wf);
781 TEST_SUITE(ExperimentalCpuAPIVariableWeightWithFixtures)
783 template <
typename ScalarType>
795 #if defined(ARM_COMPUTE_ENABLE_FP16) 802 validate(Accessor(_target), _reference, rel_tolerance_f16, 0.f,
half(abs_tolerance_f16));
804 #endif // ARM_COMPUTE_ENABLE_FP16 806 #if defined(ARM_COMPUTE_ENABLE_BF16) 807 template <
typename ScalarType>
808 using VarWidthFastMath = VariableWeightsFixture<cpu::CpuGemmConv2d, Tensor, Accessor, ScalarType,
true>;
818 #endif // ARM_COMPUTE_ENABLE_BF16 822 TEST_SUITE(ExperimentalNEAPIVariableWeightWithFixtures)
824 template <
typename ScalarType>
825 using NEGEMMVarWidth = VariableWeightsFixtureNEInterface<
NEGEMMConvolutionLayer, Tensor, Accessor, ScalarType,
false>;
836 #if defined(ARM_COMPUTE_ENABLE_FP16) 843 validate(Accessor(_target), _reference, rel_tolerance_f16, 0.f,
half(abs_tolerance_f16));
845 #endif // ARM_COMPUTE_ENABLE_FP16 847 #if defined(ARM_COMPUTE_ENABLE_BF16) 848 template <
typename ScalarType>
849 using NEGEMMVarWidthFastMath = VariableWeightsFixtureNEInterface<NEGEMMConvolutionLayer, Tensor, Accessor, ScalarType,
true>;
859 #endif // ARM_COMPUTE_ENABLE_BF16 864 #endif // ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS 867 template <
typename T>
868 using NEGEMMConvolutionLayerFixture = ConvolutionValidationFixture<Tensor, Accessor, NEConvolutionLayer, T>;
869 template <
typename T>
881 auto conv = std::make_unique<cpu::CpuGemmConv2d>();
888 conv->configure(&src_info, &weight_info, &bias_info, &dst_info, conv_info, weights_info);
892 auto weight = create_tensor<Tensor>(weight_info);
893 auto bias = create_tensor<Tensor>(bias_info);
894 src.allocator()->allocate();
895 weight.allocator()->allocate();
896 bias.allocator()->allocate();
902 auto ws = manage_workspace<Tensor>(conv->workspace(), mg, run_pack, prep_pack);
904 auto run_conv = [&]() -> Tensor
906 auto dst = create_tensor<Tensor>(dst_info);
907 dst.allocator()->allocate();
910 library->fill_tensor_value(Accessor(
src), 1.f);
911 library->fill_tensor_value(Accessor(weight), 2.f);
912 library->fill_tensor_value(Accessor(bias), 3.f);
914 conv->prepare(prep_pack);
918 auto result_0 = run_conv();
919 auto result_1 = run_conv();
920 for(
size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i)
935 auto conv = std::make_unique<NEGEMMConvolutionLayer>();
942 auto run_conv = [&]()
945 auto weight = create_tensor<Tensor>(weight_info);
946 auto bias = create_tensor<Tensor>(bias_info);
947 auto dst = create_tensor<Tensor>(dst_info);
948 conv->configure(&
src, &weight, &bias, &dst, conv_info, weights_info);
949 src.allocator()->allocate();
950 weight.allocator()->allocate();
951 bias.allocator()->allocate();
952 dst.allocator()->allocate();
953 library->fill_tensor_value(Accessor(
src), 1.f);
954 library->fill_tensor_value(Accessor(weight), 2.f);
955 library->fill_tensor_value(Accessor(bias), 3.f);
959 auto result_0 = run_conv();
960 auto result_1 = run_conv();
961 for(
size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i)
968 #if defined(ARM_COMPUTE_ENABLE_BF16) 972 ActivationFunctionsDataset))
980 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 994 ActivationFunctionsDataset))
1010 ActivationFunctionsDataset))
1018 template <
typename T>
1019 using NEGEMMConvolutionLayerQuantizedFixture = ConvolutionValidationQuantizedFixture<Tensor, Accessor, NEConvolutionLayer, T>;
1020 template <
typename T>
1023 template <
typename T>
1090 framework::dataset::
make("ReshapeWeights", {
true })),
1118 template <
typename T>
1119 using NEDirectGEMMConv2dLayerFixture = ConvolutionValidationFixture<Tensor, Accessor, NEGEMMConv2d, T>;
1130 auto conv = std::make_unique<cpu::CpuGemmDirectConv2d>();
1136 conv->configure(&src_info, &weight_info, &bias_info, &dst_info,
conv_info);
1140 auto weight = create_tensor<Tensor>(weight_info);
1141 auto bias = create_tensor<Tensor>(bias_info);
1142 src.allocator()->allocate();
1143 weight.allocator()->allocate();
1144 bias.allocator()->allocate();
1150 auto ws = manage_workspace<Tensor>(conv->workspace(), mg, run_pack, prep_pack);
1152 auto run_conv = [&]() ->
Tensor 1154 auto dst = create_tensor<Tensor>(dst_info);
1155 dst.allocator()->allocate();
1162 conv->prepare(prep_pack);
1163 conv->run(run_pack);
1166 auto result_0 = run_conv();
1167 auto result_1 = run_conv();
1168 for(
size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i)
1183 auto conv = std::make_unique<NEGEMMConv2d>();
1189 auto run_conv = [&]()
1192 auto weight = create_tensor<Tensor>(weight_info);
1193 auto bias = create_tensor<Tensor>(bias_info);
1194 auto dst = create_tensor<Tensor>(dst_info);
1195 conv->configure(&
src, &weight, &bias, &dst,
conv_info);
1196 src.allocator()->allocate();
1197 weight.allocator()->allocate();
1198 bias.allocator()->allocate();
1199 dst.allocator()->allocate();
1206 auto result_0 = run_conv();
1207 auto result_1 = run_conv();
1208 for(
size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i)
1226 template <
typename T>
1227 using NEDirectGEMMConv2dLayerQuantizedFixture = ConvolutionValidationQuantizedFixture<Tensor, Accessor, NEGEMMConv2d, T>;
1229 template <
typename T>
1230 using NEDirectGEMMConv2dLayerQuantizedPerChannelFixture = ConvolutionValidationQuantizedPerChannelFixture<Tensor, Accessor, NEGEMMConv2d, T, int8_t>;
1274 #endif // __aarch64__
Basic function to compute the convolution layer.
Class reprensenting an absolute tolerance value.
NEGEMMConvolutionLayerQuantizedFixture< int8_t >
constexpr float tolerance_num_f16
F16 Tolerance number.
TEST_SUITE(QASYMM8_to_F32) FIXTURE_DATA_TEST_CASE(RunSmall
ConvolutionValidationQuantizedFixture< Tensor, Accessor, NEConvolutionLayer, T, true > NEGEMMConvolutionLayerQuantizedMixedDataLayoutFixture
ConvolutionValidationFixture< Tensor, Accessor, NEConvolutionLayer, T, true > NEGEMMConvolutionLayerMixedDataLayoutFixture
half_float::half half
16-bit floating point type
1 channel, 1 F32 per channel
ARM_COMPUTE_EXPECT(has_error==expected, framework::LogLevel::ERRORS)
ConvolutionValidationQuantizedPerChannelFixture< Tensor, Accessor, NEConvolutionLayer, T, int8_t > NEGEMMConvolutionLayerQuantizedPerChannelFixture
std::enable_if< is_container< T >::value, ContainerDataset< T > >::type make(std::string name, T &&values)
Helper function to create a ContainerDataset.
WeightFormat
Memory layouts for the weights tensor.
ConvolutionMethod
Available ConvolutionMethod.
Activation Layer Information class.
WinogradConvolutionLayerFastMathValidationFixture< Tensor, Accessor, NEWinogradConvolutionLayer, T, T, false > NEWinogradConvolutionLayerNoBiasFixture
Basic function to compute the convolution layer.
SimpleTensor< float > src
Copyright (c) 2017-2023 Arm Limited.
1 channel, 1 F16 per channel
NEWinogradConvolutionLayerFixture< float >
Convolution Layer Weights Information class.
1 channel, 1 S32 per channel
16-bit brain floating-point number
Quantization information.
DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), }), framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(30U, 11U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), })), framework::dataset::make("ActivationInfo", { ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SQRT), })), framework::dataset::make("Expected", { false, true, true, true, false, false, true, true, false })), input_info, output_info, act_info, expected)
const auto input_shape
Validate test suite is to test ARM_COMPUTE_RETURN_ON_* macros we use to check the validity of given a...
Accessor implementation for Tensor objects.
DatasetMode
Possible dataset modes.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
std::unique_ptr< AssetsLibrary > library
TEST_SUITE_END() FIXTURE_DATA_TEST_CASE(RunSmall
[CLActivationLayer Test snippet]
quantized, asymmetric fixed-point 8-bit number unsigned
const unsigned int num_groups
const auto QuantizedActivationFunctionsDataset
Input data sets.
Basic implementation of the tensor interface.
Padding and stride information class.
validate(CLAccessor(output_state), expected_output)
UniqueGemmCommon< Top, Tret > gemm(const GemmArgs &args, const OutputStage &os)
Descriptor used by the 2d Convolution function.
Num samples, channels, height, width.
constexpr float tolerance_num
Tolerance number.
TensorInfo src_info(src_shape, 1, data_type)
quantized, symmetric per channel fixed-point 8-bit number
Convolution using Winograd.
Lower and Upper Bounded Rectifier ( )
FIXTURE_DATA_TEST_CASE(RunSmall, CLAbsLayerFixture< half >, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16)))
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Upper Bounded Rectifier ( )
bool is_fixed_format_fast_math(const WeightFormat &wf)
static ConvolutionMethod get_convolution_method(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *output, const PadStrideInfo &conv_info, const WeightsInfo &weights_info=WeightsInfo(), const Size2D &dilation=Size2D(1U, 1U), const ActivationLayerInfo &act_info=ActivationLayerInfo(), bool enable_fast_math=false)
Static function to check if given info will return the convolution called by NEConvolutionLayer.
WinogradConvolutionLayerFastMathValidationFixture< Tensor, Accessor, NEWinogradConvolutionLayer, T, T, true, true > NEWinogradConvolutionLayerMixedDataLayoutFixture
Class reprensenting a relative tolerance value.
Class for specifying the size of an image or rectangle.
Num samples, height, width, channels.
ARM_COMPUTE_EXPECT_EQUAL(expected, actual, framework::LogLevel::ERRORS)
Store the tensor's metadata.
JoinDataset< T, U > concat(T &&dataset1, U &&dataset2)
Helper function to create a JoinDataset.
TEST_CASE(FusedActivation, framework::DatasetMode::ALL)
Validate fused activation expecting the following behaviours:
quantized, asymmetric fixed-point 8-bit number signed
Basic function to compute the convolution layer.
zip(zip(framework::dataset::make("Weights", { TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 1U), 1, DataType::F32), }), framework::dataset::make("MVBGInfo",{ TensorInfo(TensorShape(2U), 1, DataType::F32), TensorInfo(TensorShape(2U), 1, DataType::F16), TensorInfo(TensorShape(5U), 1, DataType::F32), })), framework::dataset::make("Expected", { true, false, false}))
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
DataType
Available data types.
constexpr float abs_tolerance_f32(0.0001f)
F32 Absolute tolerance value for comparing reference's output against implementation's output for flo...
DataLayout
[DataLayout enum definition]
combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)))
const auto QuantizationData
void configure_conv_function< NEGEMMConv2d, Tensor >(NEGEMMConv2d &func, Tensor *src, const Tensor *weights, const Tensor *bias, Tensor *dst, const PadStrideInfo &info, const WeightsInfo &weights_info, const Size2D &dilation, const ActivationLayerInfo &act_info, unsigned int num_groups)
CLWinogradConvolutionLayerFastMathFixture16