四维索引:
Mat[((b*channels+c)*height+h)*width+w]
Mat[B*channels*height*width+C*height*width+H*width+W]
要变换维度时,只有调换for循环位置到不同的循环层,例如yolo里面访问网格对应通道,代码如下 例如CHW-->HWC
//permute
u32Offset = 0;
ps32InputBlob = pps32InputData[i];
void savebmp(char *name,HI_U8 *buffer,int w,int h) { | |
FILE *f=fopen(name,"wb"); | |
if(!f) { | |
printf("Error writing image to disk.\n"); | |
return; | |
} | |
unsigned int size=w*h*3+54; | |
HI_U8 header[54]={'B','M',size&255,(size>>8)&255,(size>>16)&255,size>>24,0, | |
0,0,0,54,0,0,0,40,0,0,0,w&255,w>>8,0,0,h&255,h>>8,0,0,1,0,24,0,0,0,0,0,0, | |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
import os, sys | |
import argparse | |
def read_jpg_path_list(file_dir): | |
L=[] | |
fp = open(os.path.join(file_dir,'YoloTestSettrain.txt'),'w') | |
for root,dirs,files in os.walk(file_dir): | |
for file in files: | |
if os.path.splitext(file)[1] == '.jpg': | |
L.append(os.path.join(root,file)) |
1.逐行扫描图像,把每一行连续的非零目标像素组成一个序列称为一个块(block),并加下它的起点start、它的终点end以及它所在的行号。 | |
void fillBlockVectors(const Mat& img,Lanes& lanes){ | |
for(int i=0; i < img.rows; ++i){ | |
const uchar* rowData = img.ptr<uchar>(i); | |
if(rowData[0] != 0){ | |
lanes.NumOfBlocks++; | |
lanes.stBlock.push_back(0); | |
lanes.rowBlock.push_back(i); | |
lanes.lane_type.push_back(rowData[0]); | |
} |
#define ALIGN_16 16 | |
#define ALIGN_32 32 | |
#define HW_ALIGN_16(u32Num) ((u32Num+ALIGN_16-1)/ALIGN_16*ALIGN_16) | |
#define HW_ALIGN_32(u32Num) ((u32Num+ALIGN_32-1)/ALIGN_32*ALIGN_32) |
四维索引:
Mat[((b*channels+c)*height+h)*width+w]
Mat[B*channels*height*width+C*height*width+H*width+W]
要变换维度时,只有调换for循环位置到不同的循环层,例如yolo里面访问网格对应通道,代码如下 例如CHW-->HWC
//permute
u32Offset = 0;
ps32InputBlob = pps32InputData[i];
GPU设备的单精度计算能力的理论峰值计算公式:
单精度计算能力的峰值 = 单核单周期计算次数 × 处理核个数 × 主频
以GTX680为例, 单核一个时钟周期单精度计算次数为两次,处理核个数 为1536, 主频为1006MHZ,那他的计算能力的峰值P 为
P = 2 × 1536 × 1006MHZ = 3.09TFLOPS
这里1MHZ = 1000000HZ, 1T为1兆,也就是说,GTX680每秒可以进行超过3兆次的单精度运算。
#include "dirent.h" | |
int readDir(char *basePath, vector<string> &filelist) | |
{ | |
DIR *dir; | |
struct dirent *ptr; | |
char base[1000]; | |
if ((dir = opendir(basePath)) == NULL) | |
{ | |
printf("readDir:Open dir error...\n"); |
classSelf_Attn(nn.Module): | |
""" Self attention Layer""" | |
def__init__(self,in_dim,activation): | |
super(Self_Attn,self).__init__() | |
self.chanel_in = in_dim |
#include "opencv2/opencv.hpp" | |
#include "hi_ive.h" | |
static HI_VOID readChn(cv::Mat& dstMat, const HI_U8* pu8Data, HI_U8 u8Chn, HI_U32 u32Width, HI_U32 u32Height, HI_U32 u32Stride) | |
{ | |
HI_U32 w, h; | |
for (w = 0; w < u32Width; w++) | |
{ | |
for (h = 0; h < u32Height; h++) | |
{ |