MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / create_graph_dump

Function create_graph_dump

src/serialization/test/extern_c_opr.cpp:183–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181#endif
182
183std::vector<uint8_t> create_graph_dump(
184 float bias, float extra_scale, float sleep, MGBDType dtype) {
185 HostTensorGenerator<> gen;
186 auto host_x = gen({1}, "cpux");
187 auto graph = ComputingGraph::make();
188 auto x = opr::Host2DeviceCopy::make(*graph, host_x);
189 if (sleep)
190 x = opr::Sleep::make(x, sleep);
191 x = opr::ExternCOprRunner::make_placeholder(
192 {x}, {TensorShape{1}},
193 dtype == MGB_DTYPE_FLOAT32
194 ? "bias_adder_dump:test"
195 : (dtype == MGB_DTYPE_INT32 ? "bias_adder_dump_i32"
196 : "bias_adder_dump_f16"),
197 &bias, sizeof(bias), {}, {dtype_c2cpp(dtype)})
198 ->output(0);
199 if (extra_scale)
200 x = x * extra_scale;
201
202 std::vector<uint8_t> ret;
203 auto dumper = GraphDumper::make(OutputFile::make_vector_proxy(&ret));
204 dumper->dump({x});
205 return ret;
206}
207
208void check_dump_by_compute(
209 std::unique_ptr<serialization::InputFile> input_file, CompNode cn,

Callers 2

run_compute_testFunction · 0.70

Calls 5

dtype_c2cppFunction · 0.70
genFunction · 0.50
makeFunction · 0.50
outputMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected