| 807 | } |
| 808 | |
| 809 | void Calibration::_computeFeatureMapsRange() { |
| 810 | // feed input data according to input images |
| 811 | int count = 0; |
| 812 | |
| 813 | auto netInfo = _module->getInfo(); |
| 814 | for (const auto& file: _calibrationFiles) { |
| 815 | std::vector<VARP> inputs; |
| 816 | for (auto& iter : _featureInfo) { |
| 817 | iter.second->setVisited(false); |
| 818 | } |
| 819 | for (auto& iter : _featureInfo) { |
| 820 | iter.second->resetUpdatedRangeFlags(); |
| 821 | } |
| 822 | |
| 823 | if (_inputType == Helper::SEQUENCE) { |
| 824 | mInputs = getModuleInputs(file, netInfo, mInputNames); |
| 825 | } else { |
| 826 | auto inputTensor = (MNN::Tensor*)mInputs[0]->getTensor(); |
| 827 | Helper::preprocessInput(_process.get(), _preprocessConfig, file, inputTensor, _inputType, mInputs[0]); |
| 828 | } |
| 829 | |
| 830 | MNN::TensorCallBackWithInfo before = [&](const std::vector<MNN::Tensor*>& nTensors, |
| 831 | const MNN::OperatorInfo* info) { |
| 832 | for (auto t : nTensors) { |
| 833 | if (TensorUtils::getDescribe(t)->index < 0) { |
| 834 | continue; |
| 835 | } |
| 836 | auto weakPtr = std::weak_ptr<Tensor::InsideDescribe::NativeInsideDescribe>(TensorUtils::getDescribeOrigin(t)->mContent); |
| 837 | if (_featureInfo.find(weakPtr) != _featureInfo.end()) { |
| 838 | if (_featureInfo[weakPtr]->visited() == false) { |
| 839 | _featureInfo[weakPtr]->updateRange(); |
| 840 | } |
| 841 | } |
| 842 | } |
| 843 | return true; |
| 844 | }; |
| 845 | MNN::TensorCallBackWithInfo after = [&](const std::vector<MNN::Tensor*>& nTensors, |
| 846 | const MNN::OperatorInfo* info) { |
| 847 | for (auto t : nTensors) { |
| 848 | if (TensorUtils::getDescribe(t)->index < 0) { |
| 849 | continue; |
| 850 | } |
| 851 | auto weakPtr = std::weak_ptr<Tensor::InsideDescribe::NativeInsideDescribe>(TensorUtils::getDescribeOrigin(t)->mContent); |
| 852 | if (_featureInfo.find(weakPtr) != _featureInfo.end()) { |
| 853 | if (_featureInfo[weakPtr]->visited() == false) { |
| 854 | _featureInfo[weakPtr]->updateRange(); |
| 855 | } |
| 856 | } |
| 857 | } |
| 858 | return true; |
| 859 | }; |
| 860 | Express::Executor::getGlobalExecutor()->setCallBack(std::move(before), std::move(after)); |
| 861 | auto outputs = _module->onForward(mInputs); |
| 862 | } |
| 863 | } |
| 864 | |
| 865 | void Calibration::_collectFeatureMapsDistribution() { |
| 866 | for (auto& iter : _featureInfo) { |
nothing calls this directly
no test coverage detected