Skip to content
Snippets Groups Projects
Commit 41615d36 authored by laurent soulier's avatar laurent soulier
Browse files

[IMPR][FIX][UT] adding partial std::uint16_t support

fixing an data allocation missing in a unit test
parent 7e72f34a
No related branches found
No related tags found
No related merge requests found
......@@ -127,7 +127,7 @@ static Registrar<Tensor> registrarTensorImpl_cpu_Float32(
static Registrar<Tensor> registrarTensorImpl_cpu_Int32(
{"cpu", DataType::Int32}, Aidge::TensorImpl_cpu<int>::create);
static Registrar<Tensor> registrarTensorImpl_cpu_UInt16(
{"cpu", DataType::UInt16}, Aidge::TensorImpl_cpu<int>::create);
{"cpu", DataType::UInt16}, Aidge::TensorImpl_cpu<std::uint16_t>::create);
} // namespace
} // namespace Aidge
......
......@@ -20,13 +20,15 @@
using namespace Aidge;
bool MakeRainbow(Tensor &i_Tensor)
template<typename Data_T> bool MakeRainbow(Tensor &i_Tensor)
{
if (!i_Tensor.hasData())
NbElts_t N = i_Tensor.size();
Data_T *data = reinterpret_cast<Data_T *>(i_Tensor.getImpl().rawPtr());
Data_T *end = data + N;
for (std::size_t i = 0; i < N; ++i, ++data)
{
return false;
*data = i;
}
NbElts_t N = i_Tensor.size();
return true;
}
......@@ -102,6 +104,13 @@ TEST_CASE("Tensor creation")
Rainbow.resize({2, 4, 5});
Rainbow.setDatatype(DataType::UInt16);
Rainbow.setBackend("cpu");
REQUIRE(MakeRainbow<std::uint16_t>(Rainbow));
bool res = true;
for (NbElts_t i = 0; i != Rainbow.size(); ++i)
{
res &= (Rainbow.get<std::uint16_t>(i) == i);
}
REQUIRE(res);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment