hewumars
4/26/2019 - 6:06 AM

Hi3559A特征图遍历

HI_S32 getInputBlobs(HI_RUNTIME_BLOB_S *pstBlobs,HI_FLOAT* pf32InputBlobs){
    HI_U32 u32BatchOffset = pstBlobs->unShape.stWhc.u32Chn * pstBlobs->u32Stride * pstBlobs->unShape.stWhc.u32Height / sizeof(HI_S32);
    HI_U32 u32ChnOffset = pstBlobs->u32Stride * pstBlobs->unShape.stWhc.u32Height / sizeof(HI_S32);
    HI_U32 u32HeightOffset = pstBlobs->u32Stride / sizeof(HI_S32);
    HI_S32 *ps32InputBlobTMP = (HI_S32*)pstBlobs->u64VirAddr;
    HI_U32 u32Offset = 0;
    HZ_PRINTF("b:%d,c:%d,h:%d\n",u32BatchOffset,u32ChnOffset,u32HeightOffset);

    HZ_PRINTF("%d,%d,%d\n",pstBlobs->unShape.stWhc.u32Chn,pstBlobs->unShape.stWhc.u32Height,pstBlobs->unShape.stWhc.u32Width);
    for (int b = 0; b < pstBlobs->u32Num; ++b) {
        for (int c = 0; c < pstBlobs->unShape.stWhc.u32Chn; c++)
        {
            for (int h = 0; h < pstBlobs->unShape.stWhc.u32Height; h++)
            {
                for (int w = 0; w < pstBlobs->unShape.stWhc.u32Width; w++)
                {

                    pf32InputBlobs[u32Offset++] = (HI_FLOAT)(ps32InputBlobTMP[b*u32BatchOffset + c*u32ChnOffset + h*u32HeightOffset+w]) / 4096;
                    //printf("%.3f\n",((HI_FLOAT)(ps32InputBlobTMP[b*u32BatchOffset + c*u32ChnOffset + h*u32HeightOffset+w]) / 4096));
                }
            }

        }
    }

}