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

Method exec

dnn/test/common/checker.h:361–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359
360template <typename Opr, typename Proxy>
361void Checker<Opr, Proxy>::exec(TensorLayoutArray layouts) {
362 auto opr_naive = m_handle_naive->create_operator<Opr>();
363 auto opr_relayout = m_handle_naive->create_operator<RelayoutForward>();
364
365 auto opr_cur = this->opr();
366 opr_naive->param() = m_param;
367 opr_cur->param() = m_param;
368 bool deduce_layout = layouts.back().ndim == 0;
369 if (deduce_layout || m_force_deduce_dst) {
370 m_naive_proxy.deduce_layout(opr_naive.get(), layouts);
371 }
372 auto exec_naive = [this, &opr_naive, &layouts,
373 &opr_relayout](const TensorValueArray& values) {
374 TensorValueArray contig_values = values;
375 TensorValueArray real_values = values;
376 std::shared_ptr<TensorValueArray> tensors_naive_contig_storage;
377 if (m_enable_contig_naive) {
378 TensorLayoutArray contig_layouts;
379 for (auto&& layout : layouts) {
380 contig_layouts.emplace_back(TensorLayout{
381 static_cast<const TensorShape&>(layout), layout.dtype});
382 }
383 m_naive_proxy.deduce_layout(opr_naive.get(), contig_layouts);
384 tensors_naive_contig_storage =
385 alloc_tensors(m_handle_naive.get(), contig_layouts, m_offset);
386 contig_values = *tensors_naive_contig_storage;
387 //! relayout value to the contig_values
388 for (size_t i = 0; i < contig_values.size(); ++i) {
389 if (real_values[i].layout.ndim == 0)
390 continue;
391 real_values[i].layout.format = {};
392 opr_relayout->exec(
393 real_values[i], contig_values[i], m_handle_naive.get());
394 }
395 }
396
397 m_naive_proxy.exec(opr_naive.get(), contig_values);
398
399 if (m_enable_contig_naive) {
400 //! relayout to the values
401 for (size_t i = 0; i < contig_values.size(); ++i) {
402 if (real_values[i].layout.ndim == 0)
403 continue;
404 opr_relayout->exec(
405 contig_values[i], real_values[i], m_handle_naive.get());
406 }
407 }
408 };
409 auto exec_opr = [this, opr_cur](const TensorValueArray& values) {
410 if (m_before_exec_callback) {
411 m_before_exec_callback(opr_cur, values);
412 }
413 m_cur_proxy.exec(opr_cur, values);
414 };
415 auto user_layouts = layouts;
416 do_exec(user_layouts, layouts, exec_naive, exec_opr);
417}
418

Callers 15

TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
test_lstmFunction · 0.45
TEST_FFunction · 0.45
run_pooling_checkFunction · 0.45
benchmark_implFunction · 0.45
TEST_FFunction · 0.45
benchmark_implFunction · 0.45
TEST_FFunction · 0.45

Calls 8

oprMethod · 0.95
backMethod · 0.80
emplace_backMethod · 0.80
do_execFunction · 0.50
paramMethod · 0.45
deduce_layoutMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected