当前位置:网站首页>Ncnn mat matrix class
Ncnn mat matrix class
2022-07-19 03:08:00 【HySmiley】
ncnn-mat.h
class NCNN_EXPORT Mat
Constructors
// empty
Mat();
// vec
Mat(int w, size_t elemsize = 4u, Allocator* allocator = 0);
// image
Mat(int w, int h, size_t elemsize = 4u, Allocator* allocator = 0);
// dim
Mat(int w, int h, int c, size_t elemsize = 4u, Allocator* allocator = 0);
// cube
Mat(int w, int h, int d, int c, size_t elemsize = 4u, Allocator* allocator = 0);
// packed vec
Mat(int w, size_t elemsize, int elempack, Allocator* allocator = 0);
// packed image
Mat(int w, int h, size_t elemsize, int elempack, Allocator* allocator = 0);
// packed dim
Mat(int w, int h, int c, size_t elemsize, int elempack, Allocator* allocator = 0);
// packed cube
Mat(int w, int h, int d, int c, size_t elemsize, int elempack, Allocator* allocator = 0);
// copy
Mat(const Mat& m);
// external vec
Mat(int w, void* data, size_t elemsize = 4u, Allocator* allocator = 0);
// external image
Mat(int w, int h, void* data, size_t elemsize = 4u, Allocator* allocator = 0);
// external dim
Mat(int w, int h, int c, void* data, size_t elemsize = 4u, Allocator* allocator = 0);
// external cube
Mat(int w, int h, int d, int c, void* data, size_t elemsize = 4u, Allocator* allocator = 0);
// external packed vec
Mat(int w, void* data, size_t elemsize, int elempack, Allocator* allocator = 0);
// external packed image
Mat(int w, int h, void* data, size_t elemsize, int elempack, Allocator* allocator = 0);
// external packed dim
Mat(int w, int h, int c, void* data, size_t elemsize, int elempack, Allocator* allocator = 0);
// external packed cube
Mat(int w, int h, int d, int c, void* data, size_t elemsize, int elempack, Allocator* allocator = 0);
// release
~Mat();
// assign
Mat& operator=(const Mat& m);
...
...
...Parameters :
w: Image width
h: High image
c: The channel number
elemsize: Number of element bytes // 4 = float32/int32, // 2 = float16, // 1 = int8/uint8, // 0 = empty
elempack
Constructor implements internal calls create overloaded function
NCNN_FORCEINLINE Mat::Mat()
: data(0), refcount(0), elemsize(0), elempack(0), allocator(0), dims(0), w(0), h(0), d(0), c(0), cstep(0)
{
}
NCNN_FORCEINLINE Mat::Mat(int _w, size_t _elemsize, Allocator* _allocator)
: data(0), refcount(0), elemsize(0), elempack(0), allocator(0), dims(0), w(0), h(0), d(0), c(0), cstep(0)
{
create(_w, _elemsize, _allocator);
}
NCNN_FORCEINLINE Mat::Mat(int _w, int _h, size_t _elemsize, Allocator* _allocator)
: data(0), refcount(0), elemsize(0), elempack(0), allocator(0), dims(0), w(0), h(0), d(0), c(0), cstep(0)
{
create(_w, _h, _elemsize, _allocator);
}
NCNN_FORCEINLINE Mat::Mat(int _w, int _h, int _c, size_t _elemsize, Allocator* _allocator)
: data(0), refcount(0), elemsize(0), elempack(0), allocator(0), dims(0), w(0), h(0), d(0), c(0), cstep(0)
{
create(_w, _h, _c, _elemsize, _allocator);
}
NCNN_FORCEINLINE Mat::Mat(int _w, int _h, int _d, int _c, size_t _elemsize, Allocator* _allocator)
: data(0), refcount(0), elemsize(0), elempack(0), allocator(0), dims(0), w(0), h(0), d(0), c(0), cstep(0)
{
create(_w, _h, _d, _c, _elemsize, _allocator);
}
...
...
...
establish Mat After the object , Call according to the constructor overload create overloaded function , Realize data memory space application , Byte alignment and so on , No assignment , The default value is ?
void Mat::create(int _w, int _h, int _d, int _c, size_t _elemsize, int _elempack, Allocator* _allocator)
{
if (dims == 4 && w == _w && h == _h && d == _d && c == _c && elemsize == _elemsize && elempack == _elempack && allocator == _allocator)
return;
release();
elemsize = _elemsize;
elempack = _elempack;
allocator = _allocator;
dims = 4;
w = _w;
h = _h;
d = _d;
c = _c;
cstep = alignSize((size_t)w * h * d * elemsize, 16) / elemsize;
if (total() > 0)
{
size_t totalsize = alignSize(total() * elemsize, 4);
if (allocator)
data = allocator->fastMalloc(totalsize + (int)sizeof(*refcount));
else
data = fastMalloc(totalsize + (int)sizeof(*refcount));
refcount = (int*)(((unsigned char*)data) + totalsize);
*refcount = 1;
}
}A detailed reference :ncnn Preliminary discussion II : The illustration ncnn::Mat Memory layout - You know
边栏推荐
- ncnn paramdict&modelbin
- [regression prediction] lithium ion battery life prediction based on particle filter with matlab code
- MySQL storage engine details
- Rsync - remote synchronization
- 【单片机仿真】(九)指令系统 — 算术运算指令 之 ADD、ADDC、SUBB、INC、DEC、DA
- Mysql优化之索引
- 2002 - Can‘t connect to server on ‘127.0.0.1‘ (36)
- Detailed explanation of dynamic compression and static compression of gzip
- [MCU simulation] (XIII) instruction system logic operation instruction shift instruction
- Oracle gets the last and first data (gets the first and last data by time)
猜你喜欢

JPA初识(ORM思想、JPA的基本操作)

LETV has more than 400 employees? Living a fairy life without a boss, the official responded
![深入理解机器学习——类别不平衡学习(Imbalanced Learning):样本采样技术-[人工采样技术之SMOTE采样法及Borderline-SMOTE采样法]](/img/9f/a0d03b23e66849f12150f9a72f36c5.png)
深入理解机器学习——类别不平衡学习(Imbalanced Learning):样本采样技术-[人工采样技术之SMOTE采样法及Borderline-SMOTE采样法]

自动装配 & 集合注入

05-中央处理器

yolov5 ncnn 推理

MySQL面试题(2022)

【剑指Offer】31-35题(判断一个序列是否是栈的出栈序列之一,层序打印二叉树以及分行打印、每行逆着打印),判断序列是否是二叉搜索树的后序遍历路径,二叉树找一条权值为K的路径,复制复杂链表

Redis和其他数据库的比较

Pytorch best practices and code templates
随机推荐
你能用到的Mysql常用命令
04_ Service registration Eureka
Redis和其他数据库的比较
C语言基础Day4-数组
Detailed explanation of dynamic compression and static compression of gzip
Multi table query - case exercise
04_服务注册Eureka
功能测试真的没有出路了吗?10k封顶从来不是开玩笑的.....
【单片机仿真】(九)指令系统 — 算术运算指令 之 ADD、ADDC、SUBB、INC、DEC、DA
Full virtualization and semi virtualization
BiSeNetV1 面部分割
Summary of the most complete methods of string interception in Oracle
人脸关键点检测
RESNET learning notes
仿射变换实现
[single chip microcomputer simulation] (XII) instruction system logic operation instruction - logic XOR instruction XRL, accumulator clear 0 and reverse instruction
05_ Service call ribbon
Tools and methods - Excel plug-in xltools
ncnn param文件及bin模型可视化解析
CorelDRAW 安装不了解决方法