14 using namespace armcomputetensorutils;
20 arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.
m_DataLayout);
21 arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.
m_DataLayout);
27 arm_compute::TensorInfo aclReshapeInputInfo = aclInputInfo;
28 arm_compute::TensorInfo aclReshapeOutputInfo = aclOutputInfo;
34 const arm_compute::TensorShape inputShape = aclInputInfo.tensor_shape();
35 const arm_compute::TensorShape outputShape = aclOutputInfo.tensor_shape();
40 aclInputInfo.set_tensor_shape({inputShape.x(), 1, inputShape.y(), inputShape.z()});
41 aclOutputInfo.set_tensor_shape({outputShape.x(), 1, outputShape.y(), outputShape.z()});
46 aclInputInfo.set_tensor_shape({1, inputShape.x(), inputShape.y(), inputShape.z()});
47 aclOutputInfo.set_tensor_shape({1, outputShape.x(), outputShape.y(), outputShape.z()});
54 statusReshapeInput = arm_compute::CLReshapeLayer::validate(&aclInputInfo, &aclReshapeInputInfo);
55 statusReshapeOutput = arm_compute::CLReshapeLayer::validate(&aclReshapeOutputInfo, &aclOutputInfo);
59 int32_t blockHeight = armnn::numeric_cast<int32_t>(descriptor.
m_BlockShape[0]);
60 int32_t blockWidth = (rank == 3) ? 1 : armnn::numeric_cast<int32_t>(descriptor.
m_BlockShape[1]);
62 unsigned int padLeft = (rank == 3) ? 0 : descriptor.
m_PadList[1].first;
63 unsigned int padRight = (rank == 3) ? 0 : descriptor.
m_PadList[1].second;
64 arm_compute::Size2D paddingLeftTop = BuildArmComputeSize2D(padLeft,
66 arm_compute::Size2D paddingRightBottom = BuildArmComputeSize2D(padRight,
69 const arm_compute::Status aclStatus = arm_compute::CLSpaceToBatchLayer::validate(&aclInputInfo,
76 if (statusReshapeInput.error_code() == arm_compute::ErrorCode::OK &&
77 statusReshapeOutput.error_code() == arm_compute::ErrorCode::OK &&
78 statusSpaceToBatch.error_code() == arm_compute::ErrorCode::OK)
81 "All SpaceToBatch layers validate status OK.");
86 "SpaceToBatch layer validate status failed."
87 + statusSpaceToBatch.error_description()
88 + statusReshapeInput.error_description()
89 + statusReshapeOutput.error_description());
95 const arm_compute::CLCompileContext& clCompileContext)
106 arm_compute::ICLTensor& input = PolymorphicPointerDowncast<IClTensorHandle>(
m_Data.
m_Inputs[0])->GetTensor();
107 arm_compute::ICLTensor& output = PolymorphicPointerDowncast<IClTensorHandle>(
m_Data.
m_Outputs[0])->GetTensor();
110 input.info()->set_data_layout(aclDataLayout);
111 output.info()->set_data_layout(aclDataLayout);
113 arm_compute::TensorInfo aclReshapeInputInfo = BuildArmComputeTensorInfo(
info.m_InputTensorInfos[0],
115 arm_compute::TensorInfo aclReshapeOutputInfo = BuildArmComputeTensorInfo(
info.m_OutputTensorInfos[0],
118 const unsigned int rank =
info.m_InputTensorInfos[0].GetNumDimensions();
121 const arm_compute::TensorShape inputShape = input.info()->tensor_shape();
122 const arm_compute::TensorShape outputShape = output.info()->tensor_shape();
128 aclReshapeInputInfo.set_tensor_shape({inputShape.x(), 1, inputShape.y(), inputShape.z()});
129 aclReshapeOutputInfo.set_tensor_shape({outputShape.x(), 1, outputShape.y(), outputShape.z()});
134 aclReshapeInputInfo.set_tensor_shape({1, inputShape.x(), inputShape.y(), inputShape.z()});
135 aclReshapeOutputInfo.set_tensor_shape({1, outputShape.x(), outputShape.y(), outputShape.z()});
142 m_ReshapeInputTensor.allocator()->init(aclReshapeInputInfo);
143 m_ReshapeOutputTensor.allocator()->init(aclReshapeOutputInfo);
145 InitialiseArmComputeTensorEmpty(m_ReshapeInputTensor);
146 InitialiseArmComputeTensorEmpty(m_ReshapeOutputTensor);
148 m_LayerReshapeInput.reset(
new arm_compute::CLReshapeLayer());
149 m_LayerReshapeOutput.reset(
new arm_compute::CLReshapeLayer());
151 m_LayerReshapeInput->configure(clCompileContext, &input, &m_ReshapeInputTensor);
152 m_LayerReshapeOutput->configure(clCompileContext, &m_ReshapeOutputTensor, &output);
161 arm_compute::Size2D paddingLeftTop = BuildArmComputeSize2D(padLeft,
163 arm_compute::Size2D paddingRightBottom = BuildArmComputeSize2D(padRight,
168 m_Layer.configure(clCompileContext,
169 rank == 3 ? &m_ReshapeInputTensor : &input,
174 rank == 3 ? &m_ReshapeOutputTensor : &output);
181 if (m_LayerReshapeInput)
183 m_LayerReshapeInput->run();
186 if (m_LayerReshapeOutput)
188 m_LayerReshapeOutput->run();