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/GpuAdd.h>
13 #include <arm_compute/dynamic_fusion/sketch/gpu/operators/GpuAdd.h>
14 #include <arm_compute/dynamic_fusion/sketch/gpu/operators/GpuMul.h>
15 #include <arm_compute/dynamic_fusion/sketch/gpu/operators/GpuSub.h>
16 #include <arm_compute/dynamic_fusion/sketch/gpu/operators/GpuOutput.h>
18 using namespace arm_compute::experimental::dynamic_fusion;
19 using namespace armnn::armcomputetensorutils;
29 auto compileCtx = arm_compute::CLKernelLibrary::get().get_compile_context();
30 auto workloadContext = GpuWorkloadContext(&compileCtx);
31 GpuWorkloadSketch sketch{ &workloadContext };
33 arm_compute::TensorInfo aclInput0Info = BuildArmComputeTensorInfo(input0, input0.
GetNumDimensions());
34 arm_compute::TensorInfo aclInput1Info = BuildArmComputeTensorInfo(input1, input1.
GetNumDimensions());
36 aclInput0Info.set_are_values_constant(input0.
IsConstant());
37 aclInput1Info.set_are_values_constant(input1.
IsConstant());
39 arm_compute::ITensorInfo* inputInfo0 = workloadContext.create_tensor_info(aclInput0Info);
40 arm_compute::ITensorInfo* inputInfo1 = workloadContext.create_tensor_info(aclInput1Info);
44 case BinaryOperation::Add:
46 return GpuAdd::validate_op(sketch, inputInfo0, inputInfo1);
48 case BinaryOperation::Mul:
50 return GpuMul::validate_op(sketch, inputInfo0, inputInfo1);
52 case BinaryOperation::Sub:
54 return GpuSub::validate_op(sketch, inputInfo0, inputInfo1);
58 std::string(
"Elementwise Binary operation not supported in GpuFsa: ")
68 GpuWorkloadSketch* sketch = blob->
sketch.get();
70 std::vector<arm_compute::ITensorInfo*> inputTensorInfos = {};
71 std::vector<arm_compute::ITensorInfo*> outputTensorInfos = {};
73 arm_compute::TensorInfo aclInput0Info = BuildArmComputeTensorInfo(input0, input0.
GetNumDimensions());
74 arm_compute::TensorInfo aclInput1Info = BuildArmComputeTensorInfo(input1, input1.
GetNumDimensions());
76 aclInput0Info.set_are_values_constant(input0.
IsConstant());
77 aclInput1Info.set_are_values_constant(input1.
IsConstant());
79 inputTensorInfos.emplace_back(workloadContext->create_tensor_info(aclInput0Info));
80 inputTensorInfos.emplace_back(workloadContext->create_tensor_info(aclInput1Info));
87 case BinaryOperation::Add:
89 aclStatus = GpuAdd::validate_op(*sketch, inputTensorInfos[0], inputTensorInfos[1]);
92 case BinaryOperation::Mul:
94 aclStatus = GpuMul::validate_op(*sketch, inputTensorInfos[0], inputTensorInfos[1]);
97 case BinaryOperation::Sub:
99 aclStatus = GpuSub::validate_op(*sketch, inputTensorInfos[0], inputTensorInfos[1]);
107 const bool supported = aclStatus.error_code() == arm_compute::ErrorCode::OK;
113 arm_compute::ITensorInfo* elementwiseBinaryOutputInfo{};
116 case BinaryOperation::Add:
118 elementwiseBinaryOutputInfo = GpuAdd::create_op(*sketch, inputTensorInfos[0], inputTensorInfos[1]);
121 case BinaryOperation::Mul:
123 elementwiseBinaryOutputInfo = GpuMul::create_op(*sketch, inputTensorInfos[0], inputTensorInfos[1]);
126 case BinaryOperation::Sub:
128 elementwiseBinaryOutputInfo = GpuSub::create_op(*sketch, inputTensorInfos[0], inputTensorInfos[1]);
137 outputTensorInfos.emplace_back(workloadContext->create_tensor_info());
138 GpuOutput::create_op(*sketch, elementwiseBinaryOutputInfo, outputTensorInfos[0]);
141 blob->
inputTensorInfos = std::make_unique<std::vector<arm_compute::ITensorInfo*>>(inputTensorInfos);
142 blob->
outputTensorInfos = std::make_unique<std::vector<arm_compute::ITensorInfo*>>(outputTensorInfos);