map 64bit int anf bfloat16

This commit is contained in:
vrooomy
2026-08-03 12:26:19 +05:30
parent 4ed880f045
commit 25ed5d4c0d
11 changed files with 129 additions and 88 deletions

View File

@@ -34,6 +34,14 @@ UMatData* NumpyAllocator::allocate(int dims0, const int* sizes, int type, void*
int depth = CV_MAT_DEPTH(type);
int cn = CV_MAT_CN(type);
// cvDepthToNumpyType() widens CV_16BF to NPY_FLOAT for export, which is only
// valid when the values are converted (see pyopencv_from). Backing a CV_16BF
// Mat with a float32 buffer here would instead pair a 2-byte element step with
// 4-byte NumPy strides and silently corrupt the data, so refuse it outright.
if( depth == CV_16BF )
CV_Error(Error::StsNotImplemented,
"CV_16BF (bfloat16) arrays cannot be allocated through the NumPy allocator: "
"NumPy has no bfloat16 dtype");
int typenum = cvDepthToNumpyType(depth);
int i, dims = dims0;
cv::AutoBuffer<npy_intp> _sizes(dims + 1);