* Pad value for QASYMM8 is no longer stored in quantized form.
Signed-off-by: Mike Kelly <mike.kelly@arm.com>
Change-Id: I048e1d233353c0560ae03a7cc1ed5199295352bc
return arm_compute::Size2D(width, height);
}
+arm_compute::PixelValue GetPixelValue(arm_compute::ITensor& input, float pixelValue)
+{
+ switch (input.info()->data_type())
+ {
+ case arm_compute::DataType::QASYMM8:
+ return arm_compute::PixelValue(static_cast<uint8_t>(pixelValue));
+ case arm_compute::DataType::QSYMM16:
+ return arm_compute::PixelValue(static_cast<int16_t>(pixelValue));
+ case arm_compute::DataType::F16:
+ return arm_compute::PixelValue(static_cast<Half>(pixelValue));
+ case arm_compute::DataType::F32:
+ return arm_compute::PixelValue(pixelValue);
+ default:
+ throw InvalidArgumentException("Unsupported DataType: [" +
+ std::to_string(static_cast<int>(input.info()->data_type())) + "]");
+ }
+}
+
} // namespace armcomputetensorutils
} // namespace armnn
#include <arm_compute/core/Types.h>
#include <arm_compute/core/Size2D.h>
+#include <Half.hpp>
+
#include <boost/cast.hpp>
namespace armnn
/// Utility function used to setup an arm_compute::Size2D object from width and height values.
arm_compute::Size2D BuildArmComputeSize2D(const unsigned int width, const unsigned int height);
+/// Gets the appropriate PixelValue for the input DataType
+arm_compute::PixelValue GetPixelValue(arm_compute::ITensor& input, float pixelValue);
+
/// Utility function used to setup an arm_compute::PadStrideInfo object from an armnn layer descriptor.
template <typename Descriptor>
arm_compute::PadStrideInfo BuildArmComputePadStrideInfo(const Descriptor &descriptor)
arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList);
- arm_compute::PixelValue pixelValue = descriptor.m_Parameters.m_PadValue;
+ arm_compute::PixelValue pixelValue = GetPixelValue(input, descriptor.m_Parameters.m_PadValue);
m_Layer.configure(&input, &output, padList, pixelValue);
}
arm_compute::PaddingList padList = static_cast<arm_compute::PaddingList>(reversed_PadList);
- arm_compute::PixelValue pixelValue = descriptor.m_Parameters.m_PadValue;
+ arm_compute::PixelValue pixelValue = GetPixelValue(input, descriptor.m_Parameters.m_PadValue);
auto layer = std::make_unique<arm_compute::NEPadLayer>();
layer->configure(&input, &output, padList, pixelValue);
{
template <typename T>
-T ConvertToDataType(const float& value,
- const armnn::TensorInfo& tensorInfo)
-{
- std::vector<T> output(1);
- std::unique_ptr<armnn::Encoder<float>> pEncoder = armnn::MakeEncoder<float>(tensorInfo, output.data());
- armnn::Encoder<float>& rEncoder = *pEncoder;
- rEncoder.Set(value);
- return output[0];
-}
-
-template <typename T>
void Pad(const TensorInfo& inputInfo,
const TensorInfo& outputInfo,
std::vector<std::pair<unsigned int, unsigned int>> m_padList,
unsigned int outputHeight = 0;
unsigned int outputWidth = 0;
- T convertedPadValue = ConvertToDataType<T>(padValue, inputInfo);
+ T convertedPadValue = static_cast<T>(padValue);
for (unsigned int i = 0; i < numOutputElements; ++i)
{