mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
core: Rename cv::float16_t to cv::hfloat (#25217)
* rename cv::float16_t to cv::fp16_t * add typedef fp16_t float16_t * remove zero(), bits() from fp16_t class * fp16_t -> hfloat * remove cv::float16_t::fromBits; add hfloatFromBits * undo changes in conv_winograd_f63.simd.hpp and conv_block.simd.hpp * undo some changes in dnn
This commit is contained in:
@@ -11,13 +11,13 @@
|
||||
namespace cv {
|
||||
|
||||
namespace hal {
|
||||
void cvt16f32f(const float16_t* src, float* dst, int len)
|
||||
void cvt16f32f(const hfloat* src, float* dst, int len)
|
||||
{
|
||||
CV_INSTRUMENT_REGION();
|
||||
CV_CPU_DISPATCH(cvt16f32f, (src, dst, len),
|
||||
CV_CPU_DISPATCH_MODES_ALL);
|
||||
}
|
||||
void cvt32f16f(const float* src, float16_t* dst, int len)
|
||||
void cvt32f16f(const float* src, hfloat* dst, int len)
|
||||
{
|
||||
CV_INSTRUMENT_REGION();
|
||||
CV_CPU_DISPATCH(cvt32f16f, (src, dst, len),
|
||||
|
||||
@@ -31,7 +31,7 @@ static inline void vx_load_as(const int* ptr, v_float32& a)
|
||||
static inline void vx_load_as(const float* ptr, v_float32& a)
|
||||
{ a = vx_load(ptr); }
|
||||
|
||||
static inline void vx_load_as(const float16_t* ptr, v_float32& a)
|
||||
static inline void vx_load_as(const hfloat* ptr, v_float32& a)
|
||||
{ a = vx_load_expand(ptr); }
|
||||
|
||||
static inline void v_store_as(ushort* ptr, const v_float32& a)
|
||||
@@ -46,7 +46,7 @@ static inline void v_store_as(int* ptr, const v_float32& a)
|
||||
static inline void v_store_as(float* ptr, const v_float32& a)
|
||||
{ v_store(ptr, a); }
|
||||
|
||||
static inline void v_store_as(float16_t* ptr, const v_float32& a)
|
||||
static inline void v_store_as(hfloat* ptr, const v_float32& a)
|
||||
{ v_pack_store(ptr, a); }
|
||||
|
||||
static inline void vx_load_pair_as(const uchar* ptr, v_uint16& a, v_uint16& b)
|
||||
@@ -150,7 +150,7 @@ static inline void vx_load_pair_as(const int* ptr, v_float32& a, v_float32& b)
|
||||
static inline void vx_load_pair_as(const float* ptr, v_float32& a, v_float32& b)
|
||||
{ a = vx_load(ptr); b = vx_load(ptr + VTraits<v_float32>::vlanes()); }
|
||||
|
||||
static inline void vx_load_pair_as(const float16_t* ptr, v_float32& a, v_float32& b)
|
||||
static inline void vx_load_pair_as(const hfloat* ptr, v_float32& a, v_float32& b)
|
||||
{
|
||||
a = vx_load_expand(ptr);
|
||||
b = vx_load_expand(ptr + VTraits<v_float32>::vlanes());
|
||||
@@ -294,7 +294,7 @@ static inline void vx_load_pair_as(const double* ptr, v_float64& a, v_float64& b
|
||||
b = vx_load(ptr + VTraits<v_float64>::vlanes());
|
||||
}
|
||||
|
||||
static inline void vx_load_pair_as(const float16_t* ptr, v_float64& a, v_float64& b)
|
||||
static inline void vx_load_pair_as(const hfloat* ptr, v_float64& a, v_float64& b)
|
||||
{
|
||||
v_float32 v0 = vx_load_expand(ptr);
|
||||
a = v_cvt_f64(v0);
|
||||
@@ -348,7 +348,7 @@ static inline void v_store_pair_as(float* ptr, const v_float64& a, const v_float
|
||||
v_store(ptr, v);
|
||||
}
|
||||
|
||||
static inline void v_store_pair_as(float16_t* ptr, const v_float64& a, const v_float64& b)
|
||||
static inline void v_store_pair_as(hfloat* ptr, const v_float64& a, const v_float64& b)
|
||||
{
|
||||
v_float32 v = v_cvt_f32(a, b);
|
||||
v_pack_store(ptr, v);
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace cv {
|
||||
namespace hal {
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||
|
||||
void cvt16f32f(const float16_t* src, float* dst, int len);
|
||||
void cvt32f16f(const float* src, float16_t* dst, int len);
|
||||
void cvt16f32f(const hfloat* src, float* dst, int len);
|
||||
void cvt32f16f(const float* src, hfloat* dst, int len);
|
||||
void addRNGBias32f(float* arr, const float* scaleBiasPairs, int len);
|
||||
void addRNGBias64f(double* arr, const double* scaleBiasPairs, int len);
|
||||
|
||||
@@ -35,7 +35,7 @@ CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||
|
||||
BinaryFunc getConvertFunc(int sdepth, int ddepth);
|
||||
|
||||
void cvt16f32f( const float16_t* src, float* dst, int len )
|
||||
void cvt16f32f( const hfloat* src, float* dst, int len )
|
||||
{
|
||||
CV_INSTRUMENT_REGION();
|
||||
int j = 0;
|
||||
@@ -56,7 +56,7 @@ void cvt16f32f( const float16_t* src, float* dst, int len )
|
||||
dst[j] = (float)src[j];
|
||||
}
|
||||
|
||||
void cvt32f16f( const float* src, float16_t* dst, int len )
|
||||
void cvt32f16f( const float* src, hfloat* dst, int len )
|
||||
{
|
||||
CV_INSTRUMENT_REGION();
|
||||
int j = 0;
|
||||
@@ -74,7 +74,7 @@ void cvt32f16f( const float* src, float16_t* dst, int len )
|
||||
}
|
||||
#endif
|
||||
for( ; j < len; j++ )
|
||||
dst[j] = float16_t(src[j]);
|
||||
dst[j] = hfloat(src[j]);
|
||||
}
|
||||
|
||||
void addRNGBias32f( float* arr, const float* scaleBiasPairs, int len )
|
||||
@@ -188,7 +188,7 @@ DEF_CVT_FUNC(8u16s, cvt_, uchar, short, v_int16)
|
||||
DEF_CVT_FUNC(8u32s, cvt_, uchar, int, v_int32)
|
||||
DEF_CVT_FUNC(8u32f, cvt_, uchar, float, v_float32)
|
||||
DEF_CVT_FUNC(8u64f, cvt_, uchar, double, v_int32)
|
||||
DEF_CVT_FUNC(8u16f, cvt1_, uchar, float16_t, v_float32)
|
||||
DEF_CVT_FUNC(8u16f, cvt1_, uchar, hfloat, v_float32)
|
||||
|
||||
////////////////////// 8s -> ... ////////////////////////
|
||||
|
||||
@@ -198,7 +198,7 @@ DEF_CVT_FUNC(8s16s, cvt_, schar, short, v_int16)
|
||||
DEF_CVT_FUNC(8s32s, cvt_, schar, int, v_int32)
|
||||
DEF_CVT_FUNC(8s32f, cvt_, schar, float, v_float32)
|
||||
DEF_CVT_FUNC(8s64f, cvt_, schar, double, v_int32)
|
||||
DEF_CVT_FUNC(8s16f, cvt1_, schar, float16_t, v_float32)
|
||||
DEF_CVT_FUNC(8s16f, cvt1_, schar, hfloat, v_float32)
|
||||
|
||||
////////////////////// 16u -> ... ////////////////////////
|
||||
|
||||
@@ -208,7 +208,7 @@ DEF_CVT_FUNC(16u16s, cvt_, ushort, short, v_int32)
|
||||
DEF_CVT_FUNC(16u32s, cvt_, ushort, int, v_int32)
|
||||
DEF_CVT_FUNC(16u32f, cvt_, ushort, float, v_float32)
|
||||
DEF_CVT_FUNC(16u64f, cvt_, ushort, double, v_int32)
|
||||
DEF_CVT_FUNC(16u16f, cvt1_,ushort, float16_t, v_float32)
|
||||
DEF_CVT_FUNC(16u16f, cvt1_,ushort, hfloat, v_float32)
|
||||
|
||||
////////////////////// 16s -> ... ////////////////////////
|
||||
|
||||
@@ -218,7 +218,7 @@ DEF_CVT_FUNC(16s16u, cvt_, short, ushort, v_int32)
|
||||
DEF_CVT_FUNC(16s32s, cvt_, short, int, v_int32)
|
||||
DEF_CVT_FUNC(16s32f, cvt_, short, float, v_float32)
|
||||
DEF_CVT_FUNC(16s64f, cvt_, short, double, v_int32)
|
||||
DEF_CVT_FUNC(16s16f, cvt1_,short, float16_t, v_float32)
|
||||
DEF_CVT_FUNC(16s16f, cvt1_,short, hfloat, v_float32)
|
||||
|
||||
////////////////////// 32s -> ... ////////////////////////
|
||||
|
||||
@@ -228,7 +228,7 @@ DEF_CVT_FUNC(32s16u, cvt_, int, ushort, v_int32)
|
||||
DEF_CVT_FUNC(32s16s, cvt_, int, short, v_int32)
|
||||
DEF_CVT_FUNC(32s32f, cvt_, int, float, v_float32)
|
||||
DEF_CVT_FUNC(32s64f, cvt_, int, double, v_int32)
|
||||
DEF_CVT_FUNC(32s16f, cvt1_,int, float16_t, v_float32)
|
||||
DEF_CVT_FUNC(32s16f, cvt1_,int, hfloat, v_float32)
|
||||
|
||||
////////////////////// 32f -> ... ////////////////////////
|
||||
|
||||
@@ -238,7 +238,7 @@ DEF_CVT_FUNC(32f16u, cvt_, float, ushort, v_float32)
|
||||
DEF_CVT_FUNC(32f16s, cvt_, float, short, v_float32)
|
||||
DEF_CVT_FUNC(32f32s, cvt_, float, int, v_float32)
|
||||
DEF_CVT_FUNC(32f64f, cvt_, float, double, v_float32)
|
||||
DEF_CVT_FUNC(32f16f, cvt1_,float, float16_t, v_float32)
|
||||
DEF_CVT_FUNC(32f16f, cvt1_,float, hfloat, v_float32)
|
||||
|
||||
////////////////////// 64f -> ... ////////////////////////
|
||||
|
||||
@@ -248,17 +248,17 @@ DEF_CVT_FUNC(64f16u, cvt_, double, ushort, v_int32)
|
||||
DEF_CVT_FUNC(64f16s, cvt_, double, short, v_int32)
|
||||
DEF_CVT_FUNC(64f32s, cvt_, double, int, v_int32)
|
||||
DEF_CVT_FUNC(64f32f, cvt_, double, float, v_float32)
|
||||
DEF_CVT_FUNC(64f16f, cvt1_,double, float16_t, v_float32)
|
||||
DEF_CVT_FUNC(64f16f, cvt1_,double, hfloat, v_float32)
|
||||
|
||||
////////////////////// 16f -> ... ////////////////////////
|
||||
|
||||
DEF_CVT_FUNC(16f8u, cvt_, float16_t, uchar, v_float32)
|
||||
DEF_CVT_FUNC(16f8s, cvt_, float16_t, schar, v_float32)
|
||||
DEF_CVT_FUNC(16f16u, cvt1_, float16_t, ushort, v_float32)
|
||||
DEF_CVT_FUNC(16f16s, cvt1_, float16_t, short, v_float32)
|
||||
DEF_CVT_FUNC(16f32s, cvt1_, float16_t, int, v_float32)
|
||||
DEF_CVT_FUNC(16f32f, cvt1_, float16_t, float, v_float32)
|
||||
DEF_CVT_FUNC(16f64f, cvt1_, float16_t, double, v_float32)
|
||||
DEF_CVT_FUNC(16f8u, cvt_, hfloat, uchar, v_float32)
|
||||
DEF_CVT_FUNC(16f8s, cvt_, hfloat, schar, v_float32)
|
||||
DEF_CVT_FUNC(16f16u, cvt1_, hfloat, ushort, v_float32)
|
||||
DEF_CVT_FUNC(16f16s, cvt1_, hfloat, short, v_float32)
|
||||
DEF_CVT_FUNC(16f32s, cvt1_, hfloat, int, v_float32)
|
||||
DEF_CVT_FUNC(16f32f, cvt1_, hfloat, float, v_float32)
|
||||
DEF_CVT_FUNC(16f64f, cvt1_, hfloat, double, v_float32)
|
||||
|
||||
///////////// "conversion" w/o conversion ///////////////
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ DEF_CVT_SCALE_FUNC(16s8u, cvt_32f, short, uchar, float)
|
||||
DEF_CVT_SCALE_FUNC(32s8u, cvt_32f, int, uchar, float)
|
||||
DEF_CVT_SCALE_FUNC(32f8u, cvt_32f, float, uchar, float)
|
||||
DEF_CVT_SCALE_FUNC(64f8u, cvt_32f, double, uchar, float)
|
||||
DEF_CVT_SCALE_FUNC(16f8u, cvt_32f, float16_t, uchar, float)
|
||||
DEF_CVT_SCALE_FUNC(16f8u, cvt_32f, hfloat, uchar, float)
|
||||
|
||||
DEF_CVT_SCALE_FUNC(8u8s, cvt_32f, uchar, schar, float)
|
||||
DEF_CVT_SCALE_FUNC(8s, cvt_32f, schar, schar, float)
|
||||
@@ -241,7 +241,7 @@ DEF_CVT_SCALE_FUNC(16s8s, cvt_32f, short, schar, float)
|
||||
DEF_CVT_SCALE_FUNC(32s8s, cvt_32f, int, schar, float)
|
||||
DEF_CVT_SCALE_FUNC(32f8s, cvt_32f, float, schar, float)
|
||||
DEF_CVT_SCALE_FUNC(64f8s, cvt_32f, double, schar, float)
|
||||
DEF_CVT_SCALE_FUNC(16f8s, cvt_32f, float16_t, schar, float)
|
||||
DEF_CVT_SCALE_FUNC(16f8s, cvt_32f, hfloat, schar, float)
|
||||
|
||||
DEF_CVT_SCALE_FUNC(8u16u, cvt_32f, uchar, ushort, float)
|
||||
DEF_CVT_SCALE_FUNC(8s16u, cvt_32f, schar, ushort, float)
|
||||
@@ -250,7 +250,7 @@ DEF_CVT_SCALE_FUNC(16s16u, cvt_32f, short, ushort, float)
|
||||
DEF_CVT_SCALE_FUNC(32s16u, cvt_32f, int, ushort, float)
|
||||
DEF_CVT_SCALE_FUNC(32f16u, cvt_32f, float, ushort, float)
|
||||
DEF_CVT_SCALE_FUNC(64f16u, cvt_32f, double, ushort, float)
|
||||
DEF_CVT_SCALE_FUNC(16f16u, cvt1_32f, float16_t, ushort, float)
|
||||
DEF_CVT_SCALE_FUNC(16f16u, cvt1_32f, hfloat, ushort, float)
|
||||
|
||||
DEF_CVT_SCALE_FUNC(8u16s, cvt_32f, uchar, short, float)
|
||||
DEF_CVT_SCALE_FUNC(8s16s, cvt_32f, schar, short, float)
|
||||
@@ -259,7 +259,7 @@ DEF_CVT_SCALE_FUNC(16s, cvt_32f, short, short, float)
|
||||
DEF_CVT_SCALE_FUNC(32s16s, cvt_32f, int, short, float)
|
||||
DEF_CVT_SCALE_FUNC(32f16s, cvt_32f, float, short, float)
|
||||
DEF_CVT_SCALE_FUNC(64f16s, cvt_32f, double, short, float)
|
||||
DEF_CVT_SCALE_FUNC(16f16s, cvt1_32f, float16_t, short, float)
|
||||
DEF_CVT_SCALE_FUNC(16f16s, cvt1_32f, hfloat, short, float)
|
||||
|
||||
DEF_CVT_SCALE_FUNC(8u32s, cvt_32f, uchar, int, float)
|
||||
DEF_CVT_SCALE_FUNC(8s32s, cvt_32f, schar, int, float)
|
||||
@@ -268,7 +268,7 @@ DEF_CVT_SCALE_FUNC(16s32s, cvt_32f, short, int, float)
|
||||
DEF_CVT_SCALE_FUNC(32s, cvt_64f, int, int, double)
|
||||
DEF_CVT_SCALE_FUNC(32f32s, cvt_32f, float, int, float)
|
||||
DEF_CVT_SCALE_FUNC(64f32s, cvt_64f, double, int, double)
|
||||
DEF_CVT_SCALE_FUNC(16f32s, cvt1_32f, float16_t, int, float)
|
||||
DEF_CVT_SCALE_FUNC(16f32s, cvt1_32f, hfloat, int, float)
|
||||
|
||||
DEF_CVT_SCALE_FUNC(8u32f, cvt_32f, uchar, float, float)
|
||||
DEF_CVT_SCALE_FUNC(8s32f, cvt_32f, schar, float, float)
|
||||
@@ -277,7 +277,7 @@ DEF_CVT_SCALE_FUNC(16s32f, cvt_32f, short, float, float)
|
||||
DEF_CVT_SCALE_FUNC(32s32f, cvt_32f, int, float, float)
|
||||
DEF_CVT_SCALE_FUNC(32f, cvt_32f, float, float, float)
|
||||
DEF_CVT_SCALE_FUNC(64f32f, cvt_64f, double, float, double)
|
||||
DEF_CVT_SCALE_FUNC(16f32f, cvt1_32f, float16_t, float, float)
|
||||
DEF_CVT_SCALE_FUNC(16f32f, cvt1_32f, hfloat, float, float)
|
||||
|
||||
DEF_CVT_SCALE_FUNC(8u64f, cvt_64f, uchar, double, double)
|
||||
DEF_CVT_SCALE_FUNC(8s64f, cvt_64f, schar, double, double)
|
||||
@@ -286,16 +286,16 @@ DEF_CVT_SCALE_FUNC(16s64f, cvt_64f, short, double, double)
|
||||
DEF_CVT_SCALE_FUNC(32s64f, cvt_64f, int, double, double)
|
||||
DEF_CVT_SCALE_FUNC(32f64f, cvt_64f, float, double, double)
|
||||
DEF_CVT_SCALE_FUNC(64f, cvt_64f, double, double, double)
|
||||
DEF_CVT_SCALE_FUNC(16f64f, cvt_64f, float16_t, double, double)
|
||||
DEF_CVT_SCALE_FUNC(16f64f, cvt_64f, hfloat, double, double)
|
||||
|
||||
DEF_CVT_SCALE_FUNC(8u16f, cvt1_32f, uchar, float16_t, float)
|
||||
DEF_CVT_SCALE_FUNC(8s16f, cvt1_32f, schar, float16_t, float)
|
||||
DEF_CVT_SCALE_FUNC(16u16f, cvt1_32f, ushort, float16_t, float)
|
||||
DEF_CVT_SCALE_FUNC(16s16f, cvt1_32f, short, float16_t, float)
|
||||
DEF_CVT_SCALE_FUNC(32s16f, cvt1_32f, int, float16_t, float)
|
||||
DEF_CVT_SCALE_FUNC(32f16f, cvt1_32f, float, float16_t, float)
|
||||
DEF_CVT_SCALE_FUNC(64f16f, cvt_64f, double, float16_t, double)
|
||||
DEF_CVT_SCALE_FUNC(16f, cvt1_32f, float16_t, float16_t, float)
|
||||
DEF_CVT_SCALE_FUNC(8u16f, cvt1_32f, uchar, hfloat, float)
|
||||
DEF_CVT_SCALE_FUNC(8s16f, cvt1_32f, schar, hfloat, float)
|
||||
DEF_CVT_SCALE_FUNC(16u16f, cvt1_32f, ushort, hfloat, float)
|
||||
DEF_CVT_SCALE_FUNC(16s16f, cvt1_32f, short, hfloat, float)
|
||||
DEF_CVT_SCALE_FUNC(32s16f, cvt1_32f, int, hfloat, float)
|
||||
DEF_CVT_SCALE_FUNC(32f16f, cvt1_32f, float, hfloat, float)
|
||||
DEF_CVT_SCALE_FUNC(64f16f, cvt_64f, double, hfloat, double)
|
||||
DEF_CVT_SCALE_FUNC(16f, cvt1_32f, hfloat, hfloat, float)
|
||||
|
||||
BinaryFunc getCvtScaleAbsFunc(int depth)
|
||||
{
|
||||
|
||||
@@ -93,7 +93,7 @@ void scalarToRawData(const Scalar& s, void* _buf, int type, int unroll_to)
|
||||
scalarToRawData_<double>(s, (double*)_buf, cn, unroll_to);
|
||||
break;
|
||||
case CV_16F:
|
||||
scalarToRawData_<float16_t>(s, (float16_t*)_buf, cn, unroll_to);
|
||||
scalarToRawData_<hfloat>(s, (hfloat*)_buf, cn, unroll_to);
|
||||
break;
|
||||
default:
|
||||
CV_Error(cv::Error::StsUnsupportedFormat,"");
|
||||
|
||||
@@ -752,7 +752,7 @@ double norm( InputArray _src, int normType, InputArray _mask )
|
||||
for (int j = 0; j < total; j += blockSize)
|
||||
{
|
||||
int bsz = std::min(total - j, blockSize);
|
||||
hal::cvt16f32f((const float16_t*)ptrs[0], data0, bsz * cn);
|
||||
hal::cvt16f32f((const hfloat*)ptrs[0], data0, bsz * cn);
|
||||
func((uchar*)data0, ptrs[1], (uchar*)&result.f, bsz, cn);
|
||||
ptrs[0] += bsz*esz;
|
||||
if (ptrs[1])
|
||||
@@ -1222,8 +1222,8 @@ double norm( InputArray _src1, InputArray _src2, int normType, InputArray _mask
|
||||
for (int j = 0; j < total; j += blockSize)
|
||||
{
|
||||
int bsz = std::min(total - j, blockSize);
|
||||
hal::cvt16f32f((const float16_t*)ptrs[0], data0, bsz * cn);
|
||||
hal::cvt16f32f((const float16_t*)ptrs[1], data1, bsz * cn);
|
||||
hal::cvt16f32f((const hfloat*)ptrs[0], data0, bsz * cn);
|
||||
hal::cvt16f32f((const hfloat*)ptrs[1], data1, bsz * cn);
|
||||
func((uchar*)data0, (uchar*)data1, ptrs[2], (uchar*)&result.f, bsz, cn);
|
||||
ptrs[0] += bsz*esz;
|
||||
ptrs[1] += bsz*esz;
|
||||
|
||||
@@ -7210,7 +7210,7 @@ String kernelToStr(InputArray _kernel, int ddepth, const char * name)
|
||||
|
||||
typedef std::string (* func_t)(const Mat &);
|
||||
static const func_t funcs[] = { kerToStr<uchar>, kerToStr<char>, kerToStr<ushort>, kerToStr<short>,
|
||||
kerToStr<int>, kerToStr<float>, kerToStr<double>, kerToStr<float16_t> };
|
||||
kerToStr<int>, kerToStr<float>, kerToStr<double>, kerToStr<hfloat> };
|
||||
const func_t func = funcs[ddepth];
|
||||
CV_Assert(func != 0);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace cv
|
||||
void valueToStr32s() { snprintf(buf, sizeof(buf), "%d", mtx.ptr<int>(row, col)[cn]); }
|
||||
void valueToStr32f() { snprintf(buf, sizeof(buf), floatFormat, mtx.ptr<float>(row, col)[cn]); }
|
||||
void valueToStr64f() { snprintf(buf, sizeof(buf), floatFormat, mtx.ptr<double>(row, col)[cn]); }
|
||||
void valueToStr16f() { snprintf(buf, sizeof(buf), floatFormat, (float)mtx.ptr<float16_t>(row, col)[cn]); }
|
||||
void valueToStr16f() { snprintf(buf, sizeof(buf), floatFormat, (float)mtx.ptr<hfloat>(row, col)[cn]); }
|
||||
void valueToStrOther() { buf[0] = 0; }
|
||||
|
||||
public:
|
||||
|
||||
@@ -270,7 +270,7 @@ int calcStructSize( const char* dt, int initial_size )
|
||||
case 'i': { elem_max_size = std::max( elem_max_size, sizeof(int ) ); break; }
|
||||
case 'f': { elem_max_size = std::max( elem_max_size, sizeof(float ) ); break; }
|
||||
case 'd': { elem_max_size = std::max( elem_max_size, sizeof(double) ); break; }
|
||||
case 'h': { elem_max_size = std::max(elem_max_size, sizeof(float16_t)); break; }
|
||||
case 'h': { elem_max_size = std::max(elem_max_size, sizeof(hfloat)); break; }
|
||||
default:
|
||||
CV_Error_(Error::StsNotImplemented, ("Unknown type identifier: '%c' in '%s'", (char)(*type), dt));
|
||||
}
|
||||
@@ -1129,8 +1129,8 @@ void FileStorage::Impl::writeRawData(const std::string &dt, const void *_data, s
|
||||
data += sizeof(double);
|
||||
break;
|
||||
case CV_16F: /* reference */
|
||||
ptr = fs::floatToString(buf, sizeof(buf), (float) *(float16_t *) data, true, explicitZero);
|
||||
data += sizeof(float16_t);
|
||||
ptr = fs::floatToString(buf, sizeof(buf), (float) *(hfloat *) data, true, explicitZero);
|
||||
data += sizeof(hfloat);
|
||||
break;
|
||||
default:
|
||||
CV_Error(cv::Error::StsUnsupportedFormat, "Unsupported type");
|
||||
@@ -1809,7 +1809,7 @@ char *FileStorage::Impl::parseBase64(char *ptr, int indent, FileNode &collection
|
||||
node_type = FileNode::REAL;
|
||||
break;
|
||||
case CV_16F:
|
||||
fval = (float) float16_t::fromBits(base64decoder.getUInt16());
|
||||
fval = float(hfloatFromBits(base64decoder.getUInt16()));
|
||||
node_type = FileNode::REAL;
|
||||
break;
|
||||
default:
|
||||
@@ -2600,8 +2600,8 @@ FileNodeIterator& FileNodeIterator::readRaw( const String& fmt, void* _data0, si
|
||||
data += sizeof(double);
|
||||
break;
|
||||
case CV_16F:
|
||||
*(float16_t*)data = float16_t((float)ival);
|
||||
data += sizeof(float16_t);
|
||||
*(hfloat*)data = hfloat((float)ival);
|
||||
data += sizeof(hfloat);
|
||||
break;
|
||||
default:
|
||||
CV_Error( Error::StsUnsupportedFormat, "Unsupported type" );
|
||||
@@ -2642,8 +2642,8 @@ FileNodeIterator& FileNodeIterator::readRaw( const String& fmt, void* _data0, si
|
||||
data += sizeof(double);
|
||||
break;
|
||||
case CV_16F:
|
||||
*(float16_t*)data = float16_t((float)fval);
|
||||
data += sizeof(float16_t);
|
||||
*(hfloat*)data = hfloat((float)fval);
|
||||
data += sizeof(hfloat);
|
||||
break;
|
||||
default:
|
||||
CV_Error( Error::StsUnsupportedFormat, "Unsupported type" );
|
||||
|
||||
@@ -195,7 +195,7 @@ randf_64f( double* arr, int len, uint64* state, const Vec2d* p, void*, bool )
|
||||
hal::addRNGBias64f(arr, &p[0][0], len);
|
||||
}
|
||||
|
||||
static void randf_16f( float16_t* arr, int len, uint64* state, const Vec2f* p, float* fbuf, bool )
|
||||
static void randf_16f( hfloat* arr, int len, uint64* state, const Vec2f* p, float* fbuf, bool )
|
||||
{
|
||||
uint64 temp = *state;
|
||||
for( int i = 0; i < len; i++ )
|
||||
|
||||
Reference in New Issue
Block a user