[fix] `half_float::half` bad formating
Context
Displaying a half_float::half
value throws an error.
#include <fmt/core.h>
#include "aidge/backend/cpu/data/TensorImpl.hpp"
#include "aidge/data/Tensor.hpp"
#include "aige/data/half.hpp"
#include "aidge/utils/Log.hpp"
int main() {
Aidge::Log::setPrecision(3);
Aidge::Tensor myTensor{half_float::half{3.5}};
fmt::print("Value: {}\n", myTensor);
return 0;
}
throws
terminate called after throwing an instance of 'fmt::v11::format_error'
what(): invalid format
Aborted (core dumped)
Furthermore, Pybind did not support Numpy fp16, this MR extends Pybind support for NumPy FP16.
Changes
- dev: delegate half_float::half formating to float formatting (which was already partially done)
- fix: Tensor::toString to convert half_float::half element to float before formating
- imp: specialize Tensor constructor from arithmetic value to support half_float::half input
- imp: add support for conversion of numpy.float16, the follwig code now succeed:
a = np.array([5.2616541964], dtype=np.float16)
t = aidge_core.Tensor(a)
- dev: improve unit test on python tensors by testing more numpy dtype.
Edited by Maxence Naud