10 #include <arm_compute/dynamic_fusion/sketch/gpu/GpuWorkloadContext.h>
11 #include <arm_compute/dynamic_fusion/sketch/gpu/GpuWorkloadSketch.h>
12 #include <arm_compute/dynamic_fusion/sketch/gpu/operators/GpuTanh.h>
13 #include <arm_compute/dynamic_fusion/sketch/gpu/operators/GpuSigmoid.h>
14 #include <arm_compute/dynamic_fusion/sketch/gpu/operators/GpuOutput.h>
16 using namespace arm_compute::experimental::dynamic_fusion;
17 using namespace armnn::armcomputetensorutils;
26 auto compileCtx = arm_compute::CLKernelLibrary::get().get_compile_context();
27 auto workloadContext = GpuWorkloadContext(&compileCtx);
28 GpuWorkloadSketch sketch{ &workloadContext };
30 arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, input.
GetNumDimensions());
31 aclInputInfo.set_are_values_constant(input.
IsConstant());
33 arm_compute::ITensorInfo* inputInfo = workloadContext.create_tensor_info(aclInputInfo);
37 case ActivationFunction::TanH:
39 if ( descriptor.
m_A != 1 || descriptor.
m_B != 1)
42 "Activation function TanH only works with a=1 and b=1");
44 return GpuTanh::validate_op(sketch, inputInfo);
46 case ActivationFunction::Sigmoid:
48 return GpuSigmoid::validate_op(sketch, inputInfo);
52 std::string(
"Activation function currently not supported in GpuFsa: ")
62 GpuWorkloadSketch* sketch = blob->
sketch.get();
64 std::vector<arm_compute::ITensorInfo*> inputTensorInfos = {};
65 std::vector<arm_compute::ITensorInfo*> outputTensorInfos = {};
67 arm_compute::TensorInfo aclInput0Info = BuildArmComputeTensorInfo(input, input.
GetNumDimensions());
69 aclInput0Info.set_are_values_constant(input.
IsConstant());
71 inputTensorInfos.emplace_back(workloadContext->create_tensor_info(aclInput0Info));
77 case ActivationFunction::TanH:
79 aclStatus = GpuTanh::validate_op(*sketch, inputTensorInfos[0]);
82 case ActivationFunction::Sigmoid:
84 aclStatus = GpuSigmoid::validate_op(*sketch, inputTensorInfos[0]);
92 const bool supported = aclStatus.error_code() == arm_compute::ErrorCode::OK;
98 arm_compute::ITensorInfo* activationOutputInfo{};
101 case ActivationFunction::TanH:
103 activationOutputInfo = GpuTanh::create_op(*sketch, inputTensorInfos[0]);
106 case ActivationFunction::Sigmoid:
108 activationOutputInfo = GpuSigmoid::create_op(*sketch, inputTensorInfos[0]);
118 outputTensorInfos.emplace_back(workloadContext->create_tensor_info());
119 GpuOutput::create_op(*sketch, activationOutputInfo, outputTensorInfos[0]);
122 blob->
inputTensorInfos = std::make_unique<std::vector<arm_compute::ITensorInfo*>>(inputTensorInfos);
123 blob->
outputTensorInfos = std::make_unique<std::vector<arm_compute::ITensorInfo*>>(outputTensorInfos);