| 19 | const int height = 720; |
| 20 | const int channel = 3; |
| 21 | static 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 | |
| 45 | class CloneNetTest : public MNNTestCase { |
| 46 | public: |