| 53 | } |
| 54 | |
| 55 | void UpdateAlpha(const float* weight, const int weightNum, const int kernelNum, float* alpha, int8_t* quantizedWeight) { |
| 56 | const int kernelDim = weightNum / kernelNum; |
| 57 | const float eps = 1e-9f; |
| 58 | |
| 59 | for (int i = 0; i < kernelNum; i++) { |
| 60 | const int offset = i * kernelDim; |
| 61 | float sum1 = 0; |
| 62 | float sum2 = 0; |
| 63 | |
| 64 | for (int j = 0; j < kernelDim; j++) { |
| 65 | sum1 += weight[offset + j] * quantizedWeight[offset + j]; |
| 66 | sum2 += quantizedWeight[offset + j] * quantizedWeight[offset + j]; |
| 67 | } |
| 68 | alpha[i] = sum1 / (sum2+eps); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | // weight format is [co, ci, kh, kw] |
| 73 | int QuantizeWeightADMM(const float* weight, const int weightNum, int8_t* quantizedWeight, float* alpha, |
no outgoing calls
no test coverage detected