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

Method run

test/core/IDSTTest.cpp:18–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16public:
17 virtual ~IDSTTest() = default;
18 virtual bool run(int precision) {
19 int kernelNum = 2, kernelSize = 8;
20 std::vector<float> weight(kernelNum * kernelSize, 0.f);
21 std::vector<float> scale(kernelNum, 0.f);
22 std::vector<int8_t> quantWeight(kernelNum * kernelSize, 0);
23 // IDST encode
24 std::unique_ptr<IDSTQuanT> idstQuantT = IDSTEncoder::encode(weight.data(), scale, kernelSize, kernelNum, false, quantWeight.data(), -127);
25 Convolution2DT* conv2dT = new Convolution2DT;
26 std::unique_ptr<OpT> opT(new OpT);
27 conv2dT->quanParameter = std::move(idstQuantT);
28 opT->type = OpType_Convolution;
29 opT->main.type = OpParameter_Convolution2D;
30 opT->main.value = conv2dT;
31 flatbuffers::FlatBufferBuilder builder;
32 auto lastOffset = Op::Pack(builder, opT.get());
33 builder.Finish(lastOffset);
34 auto op = flatbuffers::GetRoot<Op>(builder.GetBufferPointer());
35 // IDST decode
36 std::shared_ptr<ConvolutionCommon::Int8Common> common = ConvolutionCommon::load(op);
37 // is input == output ?
38 bool res = (0 == memcmp(common->weightFloat.get(), weight.data(), weight.size()));
39 return res;
40 }
41};
42MNNTestSuiteRegister(IDSTTest, "core/idst");

Callers

nothing calls this directly

Calls 6

encodeFunction · 0.85
loadFunction · 0.50
dataMethod · 0.45
getMethod · 0.45
FinishMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected