diff options
author | Gian Marco <gianmarco.iodice@arm.com> | 2017-11-17 09:27:57 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | 6b77e917801b4e979796ea75c538eef740482089 (patch) | |
tree | 0e693ecb1eb0b05018901a992b56781a08b9c266 /tests/validation/fixtures/GEMMLowpFixture.h | |
parent | b3c81cb4100b3a449db5232364e18e649b26df58 (diff) | |
download | ComputeLibrary-6b77e917801b4e979796ea75c538eef740482089.tar.gz |
COMPMID-665 - NEON: Add QASYMM8 in place Activation layer
- Added min and max arguments for QuantizeDownInt32ToUint8Scale in order
to apply bounded relu
- Added support for int32_t biases
- Extended tests
Change-Id: I015dae17faa7284766b5435ca33bcf593c1b2b69
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/96512
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'tests/validation/fixtures/GEMMLowpFixture.h')
-rw-r--r-- | tests/validation/fixtures/GEMMLowpFixture.h | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/tests/validation/fixtures/GEMMLowpFixture.h b/tests/validation/fixtures/GEMMLowpFixture.h index f9b0dbd959..a99e9323c8 100644 --- a/tests/validation/fixtures/GEMMLowpFixture.h +++ b/tests/validation/fixtures/GEMMLowpFixture.h @@ -122,10 +122,10 @@ class GEMMLowpQuantizeDownInt32ToUint8ScaleValidationFixture : public framework: { public: template <typename...> - void setup(TensorShape shape, int32_t result_offset, int32_t result_mult_int, int32_t result_shift) + void setup(TensorShape shape, int32_t result_offset, int32_t result_mult_int, int32_t result_shift, int32_t min, int32_t max, bool add_bias) { - _target = compute_target(shape, result_offset, result_mult_int, result_shift); - _reference = compute_reference(shape, result_offset, result_mult_int, result_shift); + _target = compute_target(shape, result_offset, result_mult_int, result_shift, min, max, add_bias); + _reference = compute_reference(shape, result_offset, result_mult_int, result_shift, min, max, add_bias); } protected: @@ -136,43 +136,72 @@ protected: library->fill(tensor, distribution, i); } - TensorType compute_target(const TensorShape &shape, int32_t result_offset, int32_t result_mult_int, int32_t result_shift) + TensorType compute_target(const TensorShape &shape, int32_t result_offset, int32_t result_mult_int, int32_t result_shift, int32_t min, int32_t max, bool add_bias) { + TensorShape shape_bias(shape[0]); + // Create tensors TensorType a = create_tensor<TensorType>(shape, DataType::S32, 1); - TensorType b = create_tensor<TensorType>(shape, DataType::QASYMM8, 1); + TensorType b = create_tensor<TensorType>(shape_bias, DataType::S32, 1); + TensorType c = create_tensor<TensorType>(shape, DataType::QASYMM8, 1); // Create and configure function FunctionType output_stage; - output_stage.configure(&a, &b, result_offset, result_mult_int, result_shift); + output_stage.configure(&a, add_bias ? &b : nullptr, &c, result_offset, result_mult_int, result_shift, min, max); ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS); // Allocate tensors a.allocator()->allocate(); - b.allocator()->allocate(); + c.allocator()->allocate(); ARM_COMPUTE_EXPECT(!a.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!b.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!c.info()->is_resizable(), framework::LogLevel::ERRORS); - // Fill tensors + // Fill tensor fill(AccessorType(a), 0); + if(add_bias) + { + ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate bias tensor + b.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!b.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensor + fill(AccessorType(b), 1); + } + // Compute GEMM function output_stage.run(); - return b; + return c; } - SimpleTensor<uint8_t> compute_reference(const TensorShape &shape, int32_t result_offset, int32_t result_mult_int, int32_t result_shift) + SimpleTensor<uint8_t> compute_reference(const TensorShape &shape, int32_t result_offset, int32_t result_mult_int, int32_t result_shift, int32_t min, int32_t max, bool add_bias) { // Create reference + TensorShape shape_bias(shape[0]); + SimpleTensor<int32_t> a{ shape, DataType::S32, 1 }; + SimpleTensor<int32_t> b{ shape_bias, DataType::S32, 1 }; // Fill reference fill(a, 0); - return reference::gemmlowp_quantize_down_int32_to_uint8_scale<int32_t>(a, result_offset, result_mult_int, result_shift); + if(add_bias) + { + // Fill bias + fill(b, 1); + + return reference::gemmlowp_quantize_down_int32_to_uint8_scale<int32_t>(a, b, result_offset, result_mult_int, result_shift, min, max); + } + else + { + return reference::gemmlowp_quantize_down_int32_to_uint8_scale<int32_t>(a, result_offset, result_mult_int, result_shift, min, max); + } } TensorType _target{}; |