diff options
author | Jakub Sujak <jakub.sujak@arm.com> | 2023-01-05 14:24:13 +0000 |
---|---|---|
committer | Jakub Sujak <jakub.sujak@arm.com> | 2023-01-31 15:16:25 +0000 |
commit | 7359a87040c7a901619de21701f540dd5a9a960c (patch) | |
tree | d0eb7bd77c4fec13562c7a97a207b19d5882d4e1 /src/dynamic_fusion/sketch/gpu/operators/GpuAdd.cpp | |
parent | e0c42ef651709fd284da3bedd2c98d420bd6fd1a (diff) | |
download | ComputeLibrary-7359a87040c7a901619de21701f540dd5a9a960c.tar.gz |
Add Multiplication operator (FP only) to Dynamic Fusion Interface
Note: we use a separate test fixture for Multiplication op instead of reusing ElementwiseBinaryFixture to avoid exposing the internal enum ElementwiseOp to the public utils/TypePrinters.h as required by the data test case macros to print the test data. We also do not consider modifying the enum ArithmeticOp in the standard interface to include MUL without an implementation. Future work should consider refactoring this test fixture into the ElementwiseBinaryFixture to reduce the total number of fixtures/code duplication.
Resolves: COMPMID-5779
Change-Id: I84207658ce0407095b028fca0ab7bfa2950255ec
Signed-off-by: Jakub Sujak <jakub.sujak@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9013
Reviewed-by: Viet-Hoa Do <viet-hoa.do@arm.com>
Reviewed-by: SiCong Li <sicong.li@arm.com>
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/dynamic_fusion/sketch/gpu/operators/GpuAdd.cpp')
-rw-r--r-- | src/dynamic_fusion/sketch/gpu/operators/GpuAdd.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/dynamic_fusion/sketch/gpu/operators/GpuAdd.cpp b/src/dynamic_fusion/sketch/gpu/operators/GpuAdd.cpp index a02160cba8..e7ee1c10df 100644 --- a/src/dynamic_fusion/sketch/gpu/operators/GpuAdd.cpp +++ b/src/dynamic_fusion/sketch/gpu/operators/GpuAdd.cpp @@ -22,8 +22,8 @@ * SOFTWARE. */ #include "arm_compute/dynamic_fusion/sketch/gpu/operators/GpuAdd.h" +#include "arm_compute/dynamic_fusion/sketch/gpu/GpuWorkloadSketch.h" -#include "src/dynamic_fusion/sketch/gpu/GpuWorkloadSketchImpl.h" #include "src/dynamic_fusion/sketch/gpu/operators/internal/GpuElementwiseBinaryCommon.h" namespace arm_compute @@ -36,9 +36,13 @@ Status GpuAdd::validate_op(const GpuWorkloadSketch &sketch, const ITensorInfo *lhs, const ITensorInfo *rhs) { - // Set the elementwise operation to ADD then call the elementwise common validate_op + ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(lhs, rhs); + ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(lhs, 1, DataType::F16, DataType::F32, DataType::U8, DataType::S16, DataType::S32); + ARM_COMPUTE_RETURN_ERROR_ON_MSG(lhs->data_type() != rhs->data_type(), "Input tensors must be the same data type"); + + // Set the elementwise operation to Add then call the elementwise common validate_op ElementwiseBinaryCommonAttributes common_attributes{}; - common_attributes.operation(ElementwiseBinaryCommonAttributes::ElementwiseOp::ADD); + common_attributes.operation(ElementwiseBinaryCommonAttributes::ElementwiseOp::Add); return GpuElementwiseBinaryCommon::validate_op(sketch, lhs, rhs, common_attributes); } @@ -46,9 +50,13 @@ Status GpuAdd::is_supported_op(const GpuWorkloadContext &context, const ITensorInfo *lhs, const ITensorInfo *rhs) { - // Set the elementwise operation to ADD then call the elementwise common is_supported_op + ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(lhs, rhs); + ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(lhs, 1, DataType::F16, DataType::F32, DataType::U8, DataType::S16, DataType::S32); + ARM_COMPUTE_RETURN_ERROR_ON_MSG(lhs->data_type() != rhs->data_type(), "Input tensors must be the same data type"); + + // Set the elementwise operation to Add then call the elementwise common is_supported_op ElementwiseBinaryCommonAttributes common_attributes{}; - common_attributes.operation(ElementwiseBinaryCommonAttributes::ElementwiseOp::ADD); + common_attributes.operation(ElementwiseBinaryCommonAttributes::ElementwiseOp::Add); return GpuElementwiseBinaryCommon::is_supported_op(context, lhs, rhs, common_attributes); } @@ -57,9 +65,9 @@ ITensorInfo *GpuAdd::create_op(GpuWorkloadSketch &sketch, ITensorInfo *rhs) { // No need to log or validate as they'll be handled inside GpuElementwiseBinaryCommon::create_op() - // Set the elementwise operation to ADD then call the elementwise common create_op + // Set the elementwise operation to Add then call the elementwise common create_op ElementwiseBinaryCommonAttributes common_attributes{}; - common_attributes.operation(ElementwiseBinaryCommonAttributes::ElementwiseOp::ADD); + common_attributes.operation(ElementwiseBinaryCommonAttributes::ElementwiseOp::Add); return GpuElementwiseBinaryCommon::create_op(sketch, lhs, rhs, common_attributes); } |