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

[FIX] fixing some issues detected with msvc.

parent 7f164bb6
No related branches found
No related tags found
2 merge requests!41Support for any backend storage,!13Refactoring Tensor
Pipeline #32956 failed
...@@ -233,13 +233,18 @@ constexpr std::size_t sizeOf(DataType const i_dataType) ...@@ -233,13 +233,18 @@ constexpr std::size_t sizeOf(DataType const i_dataType)
} }
} }
} // namespace detail
} // namespace Aidge
/// @todo possibly move all EnumStrings to Aidge::detail, see aidge#24
namespace
{
template<> template<>
const char* const EnumStrings<Aidge::DataType>::data[] const char* const EnumStrings<Aidge::DataType>::data[]
= {"Float64", "Float32", "Float16", "BFloat16", "Binary", "Ternary", "Int2", = {"Float64", "Float32", "Float16", "BFloat16", "Binary", "Ternary", "Int2",
"Int3", "Int4", "Int5", "Int6", "Int7", "Int8", "Int16", "Int3", "Int4", "Int5", "Int6", "Int7", "Int8", "Int16",
"Int32", "Int64", "UInt2", "UInt3", "UInt4", "UInt5", "UInt6", "Int32", "Int64", "UInt2", "UInt3", "UInt4", "UInt5", "UInt6",
"UInt7", "UInt8", "UInt16", "UInt32", "UInt64"}; "UInt7", "UInt8", "UInt16", "UInt32", "UInt64"};
} // namespace detail
} // namespace Aidge
}
#endif /* AIDGE_DATA_H_ */ #endif /* AIDGE_DATA_H_ */
\ No newline at end of file
...@@ -370,7 +370,10 @@ public: ...@@ -370,7 +370,10 @@ public:
*/ */
inline DimIdx_t nbDims() const inline DimIdx_t nbDims() const
{ {
return mDims.size(); assert(
mDims.size() <= std::numeric_limits<DimIdx_t>::max()
&& "Too many tensor dimensions");
return static_cast<DimIdx_t>(mDims.size());
} }
/** /**
......
...@@ -46,7 +46,7 @@ bool approxEq(Aidge::Tensor t1, Aidge::Tensor t2, float relative, float absolute ...@@ -46,7 +46,7 @@ bool approxEq(Aidge::Tensor t1, Aidge::Tensor t2, float relative, float absolute
{ {
return false; return false;
} }
for (size_t i; i < t1.size(); ++i) for (size_t i = 0; i < t1.size(); ++i)
{ {
if (static_cast<float>(std::abs(t1.get<T>(i) - t2.get<T>(i))) if (static_cast<float>(std::abs(t1.get<T>(i) - t2.get<T>(i)))
> (absolute + (relative * static_cast<float>(std::abs(t2.get<T>(i)))))) > (absolute + (relative * static_cast<float>(std::abs(t2.get<T>(i))))))
......
...@@ -18,17 +18,18 @@ ...@@ -18,17 +18,18 @@
namespace py = pybind11; namespace py = pybind11;
namespace Aidge { namespace Aidge
{
template<typename T> template<typename T> void addTensorUtilsFunction(py::module &m)
void addTensorUtilsFunction(py::module &m){ {
m.def("approx_eq", m.def(
& approxEq<T>, "approx_eq",
py::arg("t1"), &approxEq<T>,
py::arg("t2"), py::arg("t1"),
py::arg("relative"), py::arg("t2"),
py::arg("absolute"), py::arg("relative"),
R"mydelimiter( py::arg("absolute"),
R"mydelimiter(
Compare two :cpp:class:`Aidge::Tensor` value wise. The comparison function is: Compare two :cpp:class:`Aidge::Tensor` value wise. The comparison function is:
|t1-t2| <= absolute + relative * |t2| |t1-t2| <= absolute + relative * |t2|
...@@ -48,10 +49,11 @@ void addTensorUtilsFunction(py::module &m){ ...@@ -48,10 +49,11 @@ void addTensorUtilsFunction(py::module &m){
)mydelimiter"); )mydelimiter");
} }
void init_TensorUtils(py::module &m) { void init_TensorUtils(py::module &m)
{
addTensorUtilsFunction<float>(m); addTensorUtilsFunction<float>(m);
addTensorUtilsFunction<double>(m); addTensorUtilsFunction<double>(m);
addTensorUtilsFunction<int>(m); addTensorUtilsFunction<detail::CppType_t<DataType::Int32>>(m);
addTensorUtilsFunction<long>(m); addTensorUtilsFunction<detail::CppType_t<DataType::Int64>>(m);
} }
} // namespace Aidge } // namespace Aidge
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