aboutsummaryrefslogtreecommitdiff
path: root/src/backends/gpuFsa/layers/GpuFsaConvolution2d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/backends/gpuFsa/layers/GpuFsaConvolution2d.cpp')
-rw-r--r--src/backends/gpuFsa/layers/GpuFsaConvolution2d.cpp72
1 files changed, 33 insertions, 39 deletions
diff --git a/src/backends/gpuFsa/layers/GpuFsaConvolution2d.cpp b/src/backends/gpuFsa/layers/GpuFsaConvolution2d.cpp
index c7137d7ac8..7aa643dcb1 100644
--- a/src/backends/gpuFsa/layers/GpuFsaConvolution2d.cpp
+++ b/src/backends/gpuFsa/layers/GpuFsaConvolution2d.cpp
@@ -17,7 +17,6 @@
#include <arm_compute/dynamic_fusion/runtime/gpu/cl/ClWorkloadRuntime.h>
#include <arm_compute/dynamic_fusion/sketch/gpu/GpuWorkloadContext.h>
-#include <src/dynamic_fusion/sketch/gpu/GpuWorkloadContextImpl.h>
#include <arm_compute/dynamic_fusion/sketch/gpu/operators/GpuConv2d.h>
#include <arm_compute/dynamic_fusion/sketch/gpu/operators/GpuOutput.h>
@@ -49,8 +48,7 @@ arm_compute::Status GpuFsaConvolution2dValidate(const TensorInfo& input,
// Only create the bias tensor info if enabled, otherwise pass nullptr to validate_op
arm_compute::TensorInfo aclBiasInfo;
- arm_compute::TensorInfo biasSketchInfo;
- arm_compute::TensorInfo* biasSketchInfoPtr = nullptr;
+ arm_compute::ITensorInfo* biasSketchInfoPtr = nullptr;
if (descriptor.m_BiasEnabled)
{
@@ -61,8 +59,7 @@ arm_compute::Status GpuFsaConvolution2dValidate(const TensorInfo& input,
aclBiasInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
aclBiasInfo.set_are_values_constant(biases.value().IsConstant());
- biasSketchInfo = workloadContext.create_tensor_info(aclBiasInfo);
- biasSketchInfoPtr = &biasSketchInfo;
+ biasSketchInfoPtr = workloadContext.create_tensor_info(aclBiasInfo);
}
// Set Conv2d attributes using descriptor
@@ -78,8 +75,8 @@ arm_compute::Status GpuFsaConvolution2dValidate(const TensorInfo& input,
// Validate operator, check status and update reasonIfUnsupported
arm_compute::Status aclStatus = GpuConv2d::validate_op(sketch,
- &inputInfo,
- &weightInfo,
+ inputInfo,
+ weightInfo,
biasSketchInfoPtr,
conv2DAttributes);
@@ -93,34 +90,32 @@ void GpuFsaConvolution2dCreateOp(GpuFsaPreCompiledBlob* blob,
const Optional<TensorInfo>& biases)
{
/*
- * Creating an Op for the GpuFds backend requires us to create and maintain quite a bit of data, which is then stored
+ * Creating an Op for the GpuFsa backend requires us to create and maintain quite a bit of data, which is then stored
* in a GpuFsaPreCompiledBlob for execution later. Specifically we need:
* GpuWorkloadContext, this contains the TensorInfos and is unique to the Graph being executed
* Sketch, this is similar to a subgraph and can contain one or more operations. Multiple ops can be "fused" together
* using a single sketch.
- * The TensorInfoIds, these are the ids of the TensorInfos used when creating the sketch. They refer to the TensorInfos
- * stored within the GpuWorkloadContext and are used to fetch them later when executing the sketch.
+ * The inputTensorinfos / outputTensorInfos, these are pointers to the TensorInfos used when creating the sketch.
+ * They refer to the TensorInfos stored within the GpuWorkloadContext and are needed when executing the sketch
+ * as the TensorInfos used when creating the Tensors must match those used to create the Sketch. Otherwise the runtime
+ * doesn't know which Tensors to use.
*/
using namespace arm_compute::experimental::dynamic_fusion;
GpuWorkloadSketch* sketch = blob->sketch.get();
GpuWorkloadContext* workloadContext = blob->workloadContext.get();
- std::vector<int32_t> inputIds = {};
- std::vector<int32_t> outputIds = {};
+ std::vector<arm_compute::ITensorInfo*> inputTensorInfos = {};
+ std::vector<arm_compute::ITensorInfo*> outputTensorInfos = {};
// Build and create tensor infos using the sketch
const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weights, descriptor.m_DataLayout);
aclWeightsInfo.set_are_values_constant(weights.IsConstant());
- auto inputInfo = workloadContext->create_tensor_info(aclInputInfo);
- aclWeightsInfo.set_are_values_constant(weights.IsConstant());
- inputIds.emplace_back(inputInfo.id());
- auto weightInfo = workloadContext->create_tensor_info(aclWeightsInfo);
- inputIds.emplace_back(weightInfo.id());
+ inputTensorInfos.emplace_back(workloadContext->create_tensor_info(aclInputInfo));
+ inputTensorInfos.emplace_back(workloadContext->create_tensor_info(aclWeightsInfo));
- // Only create the bias tensor info if enabled, otherwise pass nullptr to validate_op
+ // Only create the bias tensor info if enabled, otherwise pass nullptr to validate_op / create_op
arm_compute::TensorInfo aclBiasInfo;
- arm_compute::TensorInfo biasSketchInfo;
arm_compute::ITensorInfo* biasSketchInfoPtr = nullptr;
if (descriptor.m_BiasEnabled)
@@ -132,9 +127,8 @@ void GpuFsaConvolution2dCreateOp(GpuFsaPreCompiledBlob* blob,
aclBiasInfo = BuildArmComputeTensorInfo(biases.value(), descriptor.m_DataLayout);
aclBiasInfo.set_are_values_constant(biases.value().IsConstant());
- biasSketchInfo = workloadContext->create_tensor_info(aclBiasInfo);
- inputIds.emplace_back(biasSketchInfo.id());
- biasSketchInfoPtr = workloadContext->implementation().get_tensor_info(biasSketchInfo.id());
+ inputTensorInfos.emplace_back(workloadContext->create_tensor_info(aclBiasInfo));
+ biasSketchInfoPtr = inputTensorInfos[2];
}
// Set Conv2d attributes using descriptor
@@ -149,12 +143,11 @@ void GpuFsaConvolution2dCreateOp(GpuFsaPreCompiledBlob* blob,
conv2DAttributes.stride(aclStrideInfo);
// Validate operator, check status and update reasonIfUnsupported
- arm_compute::Status aclStatus =
- GpuConv2d::validate_op(*sketch,
- workloadContext->implementation().get_tensor_info(inputInfo.id()),
- workloadContext->implementation().get_tensor_info(weightInfo.id()),
- biasSketchInfoPtr,
- conv2DAttributes);
+ arm_compute::Status aclStatus = GpuConv2d::validate_op(*sketch,
+ inputTensorInfos[0],
+ inputTensorInfos[1],
+ biasSketchInfoPtr,
+ conv2DAttributes);
const bool supported = (aclStatus.error_code() == arm_compute::ErrorCode::OK);
if (!supported)
@@ -162,19 +155,20 @@ void GpuFsaConvolution2dCreateOp(GpuFsaPreCompiledBlob* blob,
throw BackendCapabilityException("\"GpuFsa\" backend failed during Convolution2D operation validation");
}
- arm_compute::ITensorInfo* convOutInfo =
- GpuConv2d::create_op(*sketch,
- workloadContext->implementation().get_tensor_info(inputInfo.id()),
- workloadContext->implementation().get_tensor_info(weightInfo.id()),
- biasSketchInfoPtr,
- conv2DAttributes);
+ // Create the Op within the Sketch using the TensorInfos we have stored
+ arm_compute::ITensorInfo* convOutInfo = GpuConv2d::create_op(*sketch,
+ inputTensorInfos[0],
+ inputTensorInfos[1],
+ biasSketchInfoPtr,
+ conv2DAttributes);
- arm_compute::TensorInfo outputDstInfo = workloadContext->create_tensor_info();
- outputIds.emplace_back(outputDstInfo.id());
+ // Create the Output
+ outputTensorInfos.emplace_back(workloadContext->create_tensor_info());
+ GpuOutput::create_op(*sketch, convOutInfo, outputTensorInfos[0]);
- GpuOutput::create_op(*sketch, convOutInfo, workloadContext->implementation().get_tensor_info(outputDstInfo.id()));
- blob->inputIds = std::make_unique<std::vector<int32_t>>(inputIds);
- blob->outputIds = std::make_unique<std::vector<int32_t>>(outputIds);
+ // Store the TensorInfos within the blob as unique_ptrs to be used later
+ blob->inputTensorInfos = std::make_unique<std::vector<arm_compute::ITensorInfo*>>(inputTensorInfos);
+ blob->outputTensorInfos = std::make_unique<std::vector<arm_compute::ITensorInfo*>>(outputTensorInfos);
}
} // namespace armnn