| 90 | // fabsf(mRangePerChannel[0].first))); |
| 91 | } |
| 92 | void TensorStatistic::updateDistribution() { |
| 93 | if (mUpdatedDistributionFlag) { |
| 94 | return; |
| 95 | } |
| 96 | mUpdatedDistributionFlag = true; |
| 97 | auto tmpTensor = mOriginTensor; |
| 98 | bool res = mOriginTensor->copyToHostTensor(mHostTensor.get()); |
| 99 | if (res) { |
| 100 | tmpTensor = mHostTensor.get(); |
| 101 | } |
| 102 | // float midValue = (mRange.second + mRange.first) / 2.0f; |
| 103 | float midValue = 0.f; |
| 104 | auto ptr = tmpTensor->host<float>(); |
| 105 | for (int i = 0; i < tmpTensor->elementSize(); ++i) { |
| 106 | auto data = ptr[i] - midValue; |
| 107 | if (abs(data) <= 1e-6) { |
| 108 | continue; |
| 109 | } |
| 110 | int index = static_cast<int>(fabs(data) * mInterval); |
| 111 | index = std::min(index, mBinNumber - 1); |
| 112 | mDistribution[index] += 1.0f; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | void TensorStatistic::setThresholdMethod(GET_THRESHOLD_METHOD thresholdMethod) { |
| 117 | mThresholdMethod = thresholdMethod; |
no test coverage detected