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

Method run_apply_on_var_node

imperative/src/test/helper.cpp:153–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153VarNodeArray OprChecker::run_apply_on_var_node(std::vector<InputSpec> inp_keys) {
154 HostTensorGenerator<> gen;
155 size_t nr_inps = inp_keys.size();
156 SmallVector<HostTensorND> host_inp(nr_inps);
157 VarNodeArray sym_inp(nr_inps);
158 auto graph = ComputingGraph::make();
159 graph->options().graph_opt_level = 0;
160 for (size_t i = 0; i < nr_inps; ++i) {
161 // TODO: remove std::visit for support osx 10.12
162 host_inp[i] = std::visit(
163 [&gen](auto&& arg) -> HostTensorND {
164 using T = std::decay_t<decltype(arg)>;
165 if constexpr (std::is_same_v<TensorShape, T>) {
166 return *gen(arg);
167 } else {
168 static_assert(std::is_same_v<HostTensorND, T>);
169 return arg;
170 }
171 },
172 inp_keys[i]);
173 sym_inp[i] = opr::SharedDeviceTensor::make(*graph, host_inp[i]).node();
174 }
175 return OpDef::apply_on_var_node(*m_op, sym_inp);
176}
177
178TEST(TestHelper, PyModule) {
179 py::module m = PyEnv::get();

Callers 1

TESTFunction · 0.80

Calls 5

makeFunction · 0.50
genFunction · 0.50
apply_on_var_nodeFunction · 0.50
sizeMethod · 0.45
nodeMethod · 0.45

Tested by

no test coverage detected