11 #include <arm_compute/dynamic_fusion/sketch/gpu/GpuWorkloadContext.h>
12 #include <arm_compute/dynamic_fusion/sketch/gpu/GpuWorkloadSketch.h>
13 #include <arm_compute/dynamic_fusion/sketch/gpu/operators/GpuSoftmax.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;
27 auto compileCtx = arm_compute::CLKernelLibrary::get().get_compile_context();
28 auto workloadContext = GpuWorkloadContext(&compileCtx);
29 GpuWorkloadSketch sketch{ &workloadContext };
32 arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, input.
GetNumDimensions());
33 arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, output.
GetNumDimensions());
34 aclInputInfo.set_are_values_constant(input.
IsConstant());
35 aclOutputInfo.set_are_values_constant(output.
IsConstant());
36 arm_compute::ITensorInfo* inputInfo = workloadContext.create_tensor_info(aclInputInfo);
37 arm_compute::ITensorInfo* outputInfo = workloadContext.create_tensor_info(aclOutputInfo);
40 SoftmaxAttributes softmaxAttributes{};
41 softmaxAttributes.beta(descriptor.
m_Beta);
42 softmaxAttributes.is_log_softmax(
false);
44 softmaxAttributes.axis(aclAxis);
53 const bool validated = aclStatus.error_code() == arm_compute::ErrorCode::OK;
56 std::cout <<
"GpuFsaSoftmaxValidate failed: " << aclStatus.error_description() << std::endl;
68 GpuWorkloadSketch* sketch = blob->
sketch.get();
70 std::vector<arm_compute::ITensorInfo*> inputTensorInfos = {};
71 std::vector<arm_compute::ITensorInfo*> outputTensorInfos = {};
73 arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, input.
GetNumDimensions());
74 arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, output.
GetNumDimensions());
75 aclInputInfo.set_are_values_constant(input.
IsConstant());
76 aclOutputInfo.set_are_values_constant(output.
IsConstant());
78 inputTensorInfos.emplace_back(workloadContext->create_tensor_info(aclInputInfo));
79 outputTensorInfos.emplace_back(workloadContext->create_tensor_info(aclOutputInfo));
82 SoftmaxAttributes softmaxAttributes{};
83 softmaxAttributes.beta(descriptor.
m_Beta);
84 softmaxAttributes.is_log_softmax(
false);
86 softmaxAttributes.axis(aclAxis);
93 const bool supported = aclStatus.error_code() == arm_compute::ErrorCode::OK;
99 GpuSoftmax::create_op(*sketch, inputTensorInfos[0], outputTensorInfos[0], softmaxAttributes);
102 blob->
inputTensorInfos = std::make_unique<std::vector<arm_compute::ITensorInfo*>>(inputTensorInfos);
103 blob->
outputTensorInfos = std::make_unique<std::vector<arm_compute::ITensorInfo*>>(outputTensorInfos);