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

Function _createModel

test/clone/CloneNetTest.cpp:21–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19const int height = 720;
20const int channel = 3;
21static std::shared_ptr<Module> _createModel() {
22 float fac = 0.23;
23 int res = 10;
24 float tail = 0.05;
25 std::vector<float> constdata(channel * height * width);
26 for (int j = 0; j < channel; ++j) {
27 for (int k = 0; k < height * width; k++) {
28 constdata[j * height * width + k] = (j * height * width + k) % (height * width) * fac + tail;
29 }
30 }
31
32 auto x = _Input({1, channel, height, width}, NCHW, halide_type_of<float>());
33 x->setName("Input");
34 auto c = _Const(constdata.data(), {1, channel, height, width}, NCHW);
35 auto y = x + c;
36 y->setName("Output");
37 std::unique_ptr<NetT> net(new NetT);
38 Variable::save({y}, net.get());
39 flatbuffers::FlatBufferBuilder builder;
40 auto len = MNN::Net::Pack(builder, net.get());
41 builder.Finish(len);
42 return std::shared_ptr<Module>(Module::load({"Input"}, {"Output"}, builder.GetBufferPointer(), builder.GetSize()));
43}
44
45class CloneNetTest : public MNNTestCase {
46public:

Callers 1

runMethod · 0.70

Calls 9

_InputFunction · 0.85
_ConstFunction · 0.85
saveFunction · 0.50
loadFunction · 0.50
setNameMethod · 0.45
dataMethod · 0.45
getMethod · 0.45
FinishMethod · 0.45
GetSizeMethod · 0.45

Tested by

no test coverage detected