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 const arm_compute::CropInfo cropInfo = BuildArmComputeCropInfo(descriptor, rank);
63 statusBatchToSpace = arm_compute::NEBatchToSpaceLayer::validate(rank == 3 ? &aclReshapeInputInfo : &aclInputInfo,
66 rank == 3 ? &aclReshapeOutputInfo : &aclOutputInfo,
69 if (statusReshapeInput.error_code() == arm_compute::ErrorCode::OK &&
70 statusReshapeOutput.error_code() == arm_compute::ErrorCode::OK &&
71 statusBatchToSpace.error_code() == arm_compute::ErrorCode::OK)
74 "All BatchToSpace layers validate status OK.");
79 "BatchToSpace layer validate status failed."
80 + statusBatchToSpace.error_description()
81 + statusReshapeInput.error_description()
82 + statusReshapeOutput.error_description());
98 arm_compute::ITensor& input = PolymorphicPointerDowncast<IAclTensorHandle>(
m_Data.
m_Inputs[0])->GetTensor();
99 arm_compute::ITensor& output = PolymorphicPointerDowncast<IAclTensorHandle>(
m_Data.
m_Outputs[0])->GetTensor();
102 input.info()->set_data_layout(aclDataLayout);
103 output.info()->set_data_layout(aclDataLayout);
105 arm_compute::TensorInfo aclReshapeInputInfo = BuildArmComputeTensorInfo(
info.m_InputTensorInfos[0],
107 arm_compute::TensorInfo aclReshapeOutputInfo = BuildArmComputeTensorInfo(
info.m_OutputTensorInfos[0],
110 const unsigned int rank =
info.m_InputTensorInfos[0].GetNumDimensions();
113 const arm_compute::TensorShape inputShape = input.info()->tensor_shape();
114 const arm_compute::TensorShape outputShape = output.info()->tensor_shape();
120 aclReshapeInputInfo.set_tensor_shape({inputShape.x(), 1, inputShape.y(), inputShape.z()});
121 aclReshapeOutputInfo.set_tensor_shape({outputShape.x(), 1, outputShape.y(), outputShape.z()});
126 aclReshapeInputInfo.set_tensor_shape({1, inputShape.x(), inputShape.y(), inputShape.z()});
127 aclReshapeOutputInfo.set_tensor_shape({1, outputShape.x(), outputShape.y(), outputShape.z()});
134 m_ReshapeInputTensor.allocator()->init(aclReshapeInputInfo);
135 m_ReshapeOutputTensor.allocator()->init(aclReshapeOutputInfo);
137 InitialiseArmComputeTensorEmpty(m_ReshapeInputTensor);
138 InitialiseArmComputeTensorEmpty(m_ReshapeOutputTensor);
140 m_LayerReshapeInput.reset(
new arm_compute::NEReshapeLayer());
141 m_LayerReshapeOutput.reset(
new arm_compute::NEReshapeLayer());
143 m_LayerReshapeInput->configure(&input, &m_ReshapeInputTensor);
144 m_LayerReshapeOutput->configure(&m_ReshapeOutputTensor, &output);
151 const arm_compute::CropInfo cropInfo = BuildArmComputeCropInfo(descriptor.
m_Parameters, rank);
153 m_Layer.reset(
new arm_compute::NEBatchToSpaceLayer());
154 m_Layer->configure(rank == 3 ? &m_ReshapeInputTensor : &input,
157 rank == 3 ? &m_ReshapeOutputTensor : &output,
165 if (m_LayerReshapeInput)
167 m_LayerReshapeInput->run();
173 if (m_LayerReshapeOutput)
175 m_LayerReshapeOutput->run();