13 using namespace armcomputetensorutils;
19 arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.
m_DataLayout);
20 arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.
m_DataLayout);
26 arm_compute::TensorInfo aclReshapeInputInfo = aclInputInfo;
27 arm_compute::TensorInfo aclReshapeOutputInfo = aclOutputInfo;
33 const arm_compute::TensorShape inputShape = aclInputInfo.tensor_shape();
34 const arm_compute::TensorShape outputShape = aclOutputInfo.tensor_shape();
39 aclReshapeInputInfo.set_tensor_shape({inputShape.x(), 1, inputShape.y(), inputShape.z()});
40 aclReshapeOutputInfo.set_tensor_shape({outputShape.x(), 1, outputShape.y(), outputShape.z()});
45 aclReshapeInputInfo.set_tensor_shape({1, inputShape.x(), inputShape.y(), inputShape.z()});
46 aclReshapeOutputInfo.set_tensor_shape({1, outputShape.x(), outputShape.y(), outputShape.z()});
53 statusReshapeInput = arm_compute::NEReshapeLayer::validate(&aclInputInfo, &aclReshapeInputInfo);
54 statusReshapeOutput = arm_compute::NEReshapeLayer::validate(&aclReshapeOutputInfo, &aclOutputInfo);
58 int32_t blockHeight = armnn::numeric_cast<int32_t>(descriptor.
m_BlockShape[0]);
59 int32_t blockWidth = (rank == 3) ? 1 : armnn::numeric_cast<int32_t>(descriptor.
m_BlockShape[1]);
61 unsigned int padLeft = (rank == 3) ? 0 : descriptor.
m_PadList[1].first;
62 unsigned int padRight = (rank == 3) ? 0 : descriptor.
m_PadList[1].second;
63 arm_compute::Size2D paddingLeftTop = BuildArmComputeSize2D(padLeft,
65 arm_compute::Size2D paddingRightBottom = BuildArmComputeSize2D(padRight,
68 statusSpaceToBatch = arm_compute::NESpaceToBatchLayer::validate(rank == 3 ? &aclReshapeInputInfo : &aclInputInfo,
73 rank == 3 ? &aclReshapeOutputInfo : &aclOutputInfo);
75 if (statusReshapeInput.error_code() == arm_compute::ErrorCode::OK &&
76 statusReshapeOutput.error_code() == arm_compute::ErrorCode::OK &&
77 statusSpaceToBatch.error_code() == arm_compute::ErrorCode::OK)
80 "All SpaceToBatch layers validate status OK.");
85 "SpaceToBatch layer validate status failed."
86 + statusSpaceToBatch.error_description()
87 + statusReshapeInput.error_description()
88 + statusReshapeOutput.error_description());
104 arm_compute::ITensor& input = PolymorphicPointerDowncast<IAclTensorHandle>(
m_Data.
m_Inputs[0])->GetTensor();
105 arm_compute::ITensor& output = PolymorphicPointerDowncast<IAclTensorHandle>(
m_Data.
m_Outputs[0])->GetTensor();
108 input.info()->set_data_layout(aclDataLayout);
109 output.info()->set_data_layout(aclDataLayout);
111 arm_compute::TensorInfo aclReshapeInputInfo = BuildArmComputeTensorInfo(
info.m_InputTensorInfos[0],
113 arm_compute::TensorInfo aclReshapeOutputInfo = BuildArmComputeTensorInfo(
info.m_OutputTensorInfos[0],
116 const unsigned int rank =
info.m_InputTensorInfos[0].GetNumDimensions();
119 const arm_compute::TensorShape inputShape = input.info()->tensor_shape();
120 const arm_compute::TensorShape outputShape = output.info()->tensor_shape();
126 aclReshapeInputInfo.set_tensor_shape({inputShape.x(), 1, inputShape.y(), inputShape.z()});
127 aclReshapeOutputInfo.set_tensor_shape({outputShape.x(), 1, outputShape.y(), outputShape.z()});
132 aclReshapeInputInfo.set_tensor_shape({1, inputShape.x(), inputShape.y(), inputShape.z()});
133 aclReshapeOutputInfo.set_tensor_shape({1, outputShape.x(), outputShape.y(), outputShape.z()});
140 m_ReshapeInputTensor.allocator()->init(aclReshapeInputInfo);
141 m_ReshapeOutputTensor.allocator()->init(aclReshapeOutputInfo);
143 InitialiseArmComputeTensorEmpty(m_ReshapeInputTensor);
144 InitialiseArmComputeTensorEmpty(m_ReshapeOutputTensor);
146 m_LayerReshapeInput.reset(
new arm_compute::NEReshapeLayer());
147 m_LayerReshapeOutput.reset(
new arm_compute::NEReshapeLayer());
149 m_LayerReshapeInput->configure(&input, &m_ReshapeInputTensor);
150 m_LayerReshapeOutput->configure(&m_ReshapeOutputTensor, &output);
159 arm_compute::Size2D paddingLeftTop = BuildArmComputeSize2D(padLeft,
161 arm_compute::Size2D paddingRightBottom = BuildArmComputeSize2D(padRight,
164 m_Layer.reset(
new arm_compute::NESpaceToBatchLayer());
165 m_Layer->configure((rank == 3) ? &m_ReshapeInputTensor : &input,
170 (rank == 3) ? &m_ReshapeOutputTensor : &output);
177 if (m_LayerReshapeInput)
179 m_LayerReshapeInput->run();
185 if (m_LayerReshapeOutput)
187 m_LayerReshapeOutput->run();