| 23 | } |
| 24 | |
| 25 | static int ReadBlobDim(BaseLoader* myfile, unsigned int* shape, int shapeBufCnt, bool useInt32) { |
| 26 | uint8_t uSize = 0; |
| 27 | myfile->read((char*)&uSize, 1); |
| 28 | if (uSize > 4) { |
| 29 | printf("Read shape error!\n"); |
| 30 | return 0; |
| 31 | } |
| 32 | int copyLength = uSize; |
| 33 | if (copyLength > shapeBufCnt) { |
| 34 | copyLength = shapeBufCnt; |
| 35 | } |
| 36 | if (useInt32) { |
| 37 | myfile->read((char*)shape, sizeof(unsigned int) * copyLength); |
| 38 | } else { |
| 39 | uint16_t shape_i16[32] = {0}; |
| 40 | myfile->read((char*)shape_i16, sizeof(uint16_t) * copyLength); |
| 41 | for (int i = 0; i < copyLength; ++i) { |
| 42 | shape[i] = shape_i16[i]; |
| 43 | } |
| 44 | } |
| 45 | return copyLength; |
| 46 | } |
| 47 | |
| 48 | static double _log2(double x) { |
| 49 | return log(x) / log(2); |
no test coverage detected