MCPcopy Create free account
hub / github.com/alibaba/MNN / SplitBufToArray

Function SplitBufToArray

source/core/ConvolutionCommon.cpp:61–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61static void SplitBufToArray(uint8_t *buf, size_t bufLen, uint8_t *arr, size_t arrLen, size_t iNeedBits) {
62 unsigned char cMask = (1 << (iNeedBits)) - 1;
63 unsigned char *tmp = (unsigned char *)buf;
64 int iOffset = 0;
65 for (unsigned int i = 0; i < arrLen; i++) {
66 unsigned char idx = 0;
67 long uShift = 8 - iNeedBits - iOffset % 8;
68 if (uShift < 0) {
69 idx = (tmp[iOffset / 8] << (0 - uShift)) & cMask;
70 idx |= (tmp[(iOffset / 8) + 1] >> (8 + uShift)) & cMask;
71 } else {
72 idx = (tmp[iOffset / 8] >> uShift) & cMask;
73 }
74 iOffset += iNeedBits;
75 if (iOffset % 8 == 0) {
76 tmp += iOffset / 8;
77 iOffset = 0;
78 }
79 arr[i] = idx;
80 }
81}
82
83// fixme!!! not efficiency
84typedef struct _SIMPLE_SET {

Callers 2

ReadQuanData_cFunction · 0.85
ReadSparseQuanData_cFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected