From a3e1b50588b89a2c0c67da2679728a422fc16402 Mon Sep 17 00:00:00 2001 From: Gunes Bayir Date: Thu, 8 Feb 2024 12:20:06 +0000 Subject: Fix the bug in GpuTanh operator in dynamic fusion Tanh in dynamic fusion is a simple operator with no A and B coefficients, as its public interface implies. Tanh operator follows the TOSA specification. Customization of tanh calculation with a and b can be achieved via fusion as below: out = a * tanh(b *in) --> x = b * in y = tanh(x) out = a * y; Resolves: COMPMID-6873 Signed-off-by: Gunes Bayir Change-Id: I818765192f631ae82c2094b0fc376fb87bae4fa4 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/11109 Benchmark: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Gian Marco Iodice Comments-Addressed: Arm Jenkins --- .../sketch/gpu/ckw_driver/components/GpuCkwActivation.cpp | 7 +------ .../fixtures/dynamic_fusion/operators/ActivationFixture.h | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwActivation.cpp b/src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwActivation.cpp index 68f478a7ce..18fda5bd6b 100644 --- a/src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwActivation.cpp +++ b/src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwActivation.cpp @@ -242,12 +242,7 @@ void GpuCkwActivation::write_component_code(const ComponentGroup &comp_group, } case ActivationLayerInfo::ActivationFunction::TANH: { - // dst = B_VAL * src - writer->op_binary(tile_dst, ckw::BinaryOp::Mul, tile_src, const_B_fp); - // dst = tanh(B_VAL * src) - writer->op_unary(tile_dst, ckw::UnaryOp::Tanh, tile_dst); - // dst = A_VAL * tanh(B_VAL * src) - writer->op_binary(tile_dst, ckw::BinaryOp::Mul, tile_dst, const_A_fp); + writer->op_unary(tile_dst, ckw::UnaryOp::Tanh, tile_src); break; } case ActivationLayerInfo::ActivationFunction::RELU: diff --git a/tests/validation/fixtures/dynamic_fusion/operators/ActivationFixture.h b/tests/validation/fixtures/dynamic_fusion/operators/ActivationFixture.h index 2f0b13329d..c9ffbccbc7 100644 --- a/tests/validation/fixtures/dynamic_fusion/operators/ActivationFixture.h +++ b/tests/validation/fixtures/dynamic_fusion/operators/ActivationFixture.h @@ -194,7 +194,7 @@ class DynamicFusionTanhValidationFixture public: void setup(TensorShape shape, bool fuse, DataType data_type) { - ActivationLayerInfo act_info{ActivationLayerInfo::ActivationFunction::TANH}; + ActivationLayerInfo act_info{ActivationLayerInfo::ActivationFunction::TANH, 1.0f, 1.0f}; DynamicFusionActivationValidationFixture::setup(shape, fuse, data_type, act_info); } -- cgit v1.2.1