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

Method run

test/op/MatrixBandPart.cpp:17–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15public:
16 virtual ~MatrixBandPartTest() = default;
17 virtual bool run(int precision) {
18 auto input = _Input({4, 4}, NHWC);
19 input->setName("input_tensor");
20 // set input data
21 const float inpudata[] = {0.0, 1.0, 2.0, 3.0, -1.0, 0.0, 1.0, 2.0, -2.0, -1.0, 0.0, 1.0, -3.0, -2.0, -1.0, 0.0};
22 auto inputPtr = input->writeMap<float>();
23 memcpy(inputPtr, inpudata, 16 * sizeof(float));
24 input->unMap();
25 int lower_data = 1;
26 int higher_data = -1;
27 auto lower = _Const(&lower_data, {}, NCHW, halide_type_of<int>());
28 auto higher = _Const(&higher_data, {}, NCHW, halide_type_of<int>());
29 auto output = _MatrixBandPart(input, lower, higher);
30 const std::vector<float> expectedOutput = {0.0, 1.0, 2.0, 3.0, -1.0, 0.0, 1.0, 2.0,
31 0.0, -1.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.0};
32 auto gotOutput = output->readMap<float>();
33 if (!checkVector<float>(gotOutput, expectedOutput.data(), 16, 0.01)) {
34 MNN_ERROR("MatrixBandPartTest test failed!\n");
35 return false;
36 }
37 return true;
38 }
39};
40MNNTestSuiteRegister(MatrixBandPartTest, "op/matrixbandpart");

Callers

nothing calls this directly

Calls 6

_InputFunction · 0.85
_ConstFunction · 0.85
_MatrixBandPartFunction · 0.85
unMapMethod · 0.80
setNameMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected