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

Function _treateExternalOps

tools/quantization/calibration.cpp:359–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

357 return 0;
358}
359static void _treateExternalOps(std::vector<std::unique_ptr<MNN::OpT>>& lists, const std::string& path) {
360 for (int i=0; i<lists.size(); ++i) {
361 auto op = lists[i].get();
362 bool hasExternal = false;
363 switch (op->main.type) {
364 case OpParameter_Convolution2D:
365 hasExternal = op->main.AsConvolution2D()->external.size() > 0;
366 break;
367 case OpParameter_Scale:
368 hasExternal = op->main.AsScale()->external.size() > 0;
369 break;
370 case OpParameter_LayerNorm:
371 hasExternal = op->main.AsLayerNorm()->external.size() > 0;
372 break;
373 default:
374 break;
375 }
376 if (hasExternal) {
377 flatbuffers::FlatBufferBuilder originBuilder;
378 originBuilder.Finish(Op::Pack(originBuilder, op));
379 FileLoader external(path.c_str());
380 flatbuffers::FlatBufferBuilder newOp;
381 _RebuildExternalOp(&external, flatbuffers::GetRoot<Op>(originBuilder.GetBufferPointer()), newOp);
382 auto originInputs = std::move(op->inputIndexes);
383 auto originOutput = std::move(op->outputIndexes);
384 lists[i].reset(flatbuffers::GetRoot<Op>(newOp.GetBufferPointer())->UnPack());
385 lists[i]->inputIndexes = std::move(originInputs);
386 lists[i]->outputIndexes = std::move(originOutput);
387 }
388 }
389}
390
391Calibration::Calibration(MNN::NetT* model, const uint8_t* modelBuffer, const int bufferSize, const std::string& configPath, std::string originalModelFile, std::string destModelFile) : _originalModel(model), _originalModelFile(originalModelFile), _destModelFile(destModelFile) {
392 // when the format of input image is RGB/BGR, channels equal to 3, GRAY is 1

Callers 1

CalibrationMethod · 0.85

Calls 10

AsConvolution2DMethod · 0.80
AsScaleMethod · 0.80
AsLayerNormMethod · 0.80
_RebuildExternalOpFunction · 0.70
sizeMethod · 0.45
getMethod · 0.45
FinishMethod · 0.45
c_strMethod · 0.45
resetMethod · 0.45
UnPackMethod · 0.45

Tested by

no test coverage detected