使用华为HiAi框架进行模型推理
成功转换模型并构造输入输出tensor
目前需要对output feature map进行解析需要获取tensor指定坐标的值
类似使用array[0,0,0,0]
访问返回flat[0]
输出tensor提供了header地址float*和shape数据类型float32
已根据bhwc格式进行flat操作
// get value from bhwc(1,126,28,23) tensor via its header
// WARNING: No memory range check, use with caution!!!
float get_value(const float* feature_ptr,const int& height,const int& width,const int& channel)
{
// every value takes 4 bytes in ram!!!
return *(feature_ptr + ( height + 28 * (width + channel * 23) ) * 4);
}
??注意这里有个地方比较坑:
对于flat数组内存偏移量,还要乘每个元素的字节长度sizeof(float32) = 4
原文:https://www.cnblogs.com/azureology/p/14787081.html