15 using namespace armcomputetensorutils;
21 arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.
m_DataLayout);
22 arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.
m_DataLayout);
28 arm_compute::TensorInfo aclReshapeInputInfo = aclInputInfo;
29 arm_compute::TensorInfo aclReshapeOutputInfo = aclOutputInfo;
35 const arm_compute::TensorShape inputShape = aclInputInfo.tensor_shape();
36 const arm_compute::TensorShape outputShape = aclOutputInfo.tensor_shape();
41 aclInputInfo.set_tensor_shape({inputShape.x(), 1, inputShape.y(), inputShape.z()});
42 aclOutputInfo.set_tensor_shape({outputShape.x(), 1, outputShape.y(), outputShape.z()});
47 aclInputInfo.set_tensor_shape({1, inputShape.x(), inputShape.y(), inputShape.z()});
48 aclOutputInfo.set_tensor_shape({1, outputShape.x(), outputShape.y(), outputShape.z()});
55 statusReshapeInput = arm_compute::CLReshapeLayer::validate(&aclInputInfo, &aclReshapeInputInfo);
56 statusReshapeOutput = arm_compute::CLReshapeLayer::validate(&aclReshapeOutputInfo, &aclOutputInfo);
60 int32_t blockHeight = armnn::numeric_cast<int32_t>(descriptor.
m_BlockShape[0]);
61 int32_t blockWidth = (rank == 3) ? 1 : armnn::numeric_cast<int32_t>(descriptor.
m_BlockShape[1]);
63 const arm_compute::CropInfo cropInfo = BuildArmComputeCropInfo(descriptor, rank);
65 statusBatchToSpace = arm_compute::CLBatchToSpaceLayer::validate(rank == 3 ? &aclReshapeInputInfo : &aclInputInfo,
68 rank == 3 ? &aclReshapeOutputInfo : &aclOutputInfo,
71 if (statusReshapeInput.error_code() == arm_compute::ErrorCode::OK &&
72 statusReshapeOutput.error_code() == arm_compute::ErrorCode::OK &&
73 statusBatchToSpace.error_code() == arm_compute::ErrorCode::OK)
76 "All BatchToSpace layers validate status OK.");
81 "BatchToSpace layer validate status failed."
82 + statusBatchToSpace.error_description()
83 + statusReshapeInput.error_description()
84 + statusReshapeOutput.error_description());
90 const arm_compute::CLCompileContext& clCompileContext)
105 input.info()->set_data_layout(aclDataLayout);
106 output.info()->set_data_layout(aclDataLayout);
108 arm_compute::TensorInfo aclReshapeInputInfo = BuildArmComputeTensorInfo(
info.m_InputTensorInfos[0],
110 arm_compute::TensorInfo aclReshapeOutputInfo = BuildArmComputeTensorInfo(
info.m_OutputTensorInfos[0],
113 const unsigned int rank =
info.m_InputTensorInfos[0].GetNumDimensions();
116 const arm_compute::TensorShape inputShape = input.info()->tensor_shape();
117 const arm_compute::TensorShape outputShape = output.info()->tensor_shape();
123 aclReshapeInputInfo.set_tensor_shape({inputShape.x(), 1, inputShape.y(), inputShape.z()});
124 aclReshapeOutputInfo.set_tensor_shape({outputShape.x(), 1, outputShape.y(), outputShape.z()});
129 aclReshapeInputInfo.set_tensor_shape({1, inputShape.x(), inputShape.y(), inputShape.z()});
130 aclReshapeOutputInfo.set_tensor_shape({1, outputShape.x(), outputShape.y(), outputShape.z()});
137 m_ReshapeInputTensor.allocator()->init(aclReshapeInputInfo);
138 m_ReshapeOutputTensor.allocator()->init(aclReshapeOutputInfo);
140 InitialiseArmComputeTensorEmpty(m_ReshapeInputTensor);
141 InitialiseArmComputeTensorEmpty(m_ReshapeOutputTensor);
143 m_LayerReshapeInput.reset(
new arm_compute::CLReshapeLayer());
144 m_LayerReshapeOutput.reset(
new arm_compute::CLReshapeLayer());
146 m_LayerReshapeInput->configure(clCompileContext, &input, &m_ReshapeInputTensor);
147 m_LayerReshapeOutput->configure(clCompileContext, &m_ReshapeOutputTensor, &output);
154 const arm_compute::CropInfo cropInfo = BuildArmComputeCropInfo(descriptor.
m_Parameters);
158 m_Layer.configure(clCompileContext,
159 (rank == 3) ? &m_ReshapeInputTensor : &input,
162 (rank == 3) ? &m_ReshapeOutputTensor : &output,
170 if (m_LayerReshapeInput)
172 m_LayerReshapeInput->run();
175 if (m_LayerReshapeOutput)
177 m_LayerReshapeOutput->run();