| 274 | |
| 275 | template <typename Opr, typename Proxy> |
| 276 | void AccuracyShakeChecker<Opr, Proxy>::exec(TensorLayoutArray layouts) { |
| 277 | auto opr_cur = this->opr(); |
| 278 | opr_cur->param() = m_param; |
| 279 | |
| 280 | m_proxy.deduce_layout(opr_cur, layouts); |
| 281 | |
| 282 | TensorLayoutArray layouts_single_batch = layouts; |
| 283 | for (size_t i = 0; i < layouts_single_batch.size(); ++i) { |
| 284 | ASSERT_TRUE(layouts[i].is_physical_contiguous()) |
| 285 | << "layouts should be physical contiguous " << layouts[i].to_string(); |
| 286 | } |
| 287 | |
| 288 | ASSERT_TRUE(0 == BatchTrait<Opr>::index_of_batch(opr_cur->param())) |
| 289 | << "index of batch should be 0 "; |
| 290 | |
| 291 | LayoutsModifier<Opr>::on(layouts_single_batch, opr_cur->param(), 1); |
| 292 | |
| 293 | // allocate input |
| 294 | auto tensors_single_batch_storage = |
| 295 | alloc_tensors(m_handle_cur, layouts_single_batch, 0); |
| 296 | m_tensors_single_batch_host = |
| 297 | alloc_tensors(m_handle_naive.get(), layouts_single_batch, 0); |
| 298 | auto tensors_cur_storage = alloc_tensors(m_handle_cur, layouts, 0); |
| 299 | m_tensors_cur_host = alloc_tensors(m_handle_naive.get(), layouts, 0); |
| 300 | auto&& tensors_single_batch = *tensors_single_batch_storage; |
| 301 | auto&& tensors_single_batch_host = *m_tensors_single_batch_host; |
| 302 | auto&& tensors_cur = *tensors_cur_storage; |
| 303 | auto&& tensors_cur_host = *m_tensors_cur_host; |
| 304 | |
| 305 | // allocate output |
| 306 | auto tensors_single_batch_storage_out = |
| 307 | alloc_tensors(m_handle_naive.get(), layouts_single_batch, 0); |
| 308 | auto tensors_cur_storage_out = alloc_tensors(m_handle_naive.get(), layouts, 0); |
| 309 | auto&& tensors_single_batch_out = *tensors_single_batch_storage_out; |
| 310 | auto&& tensors_cur_out = *tensors_cur_storage_out; |
| 311 | |
| 312 | init_host_values(); |
| 313 | |
| 314 | copy_tensors_to_device(tensors_cur, tensors_cur_host); |
| 315 | copy_tensors_to_device(tensors_single_batch, tensors_single_batch_host); |
| 316 | |
| 317 | std::vector<Algorithm::Info::Desc> algo_desc; |
| 318 | if (m_before_exec_callback) { |
| 319 | algo_desc = m_before_exec_callback(opr_cur, tensors_cur); |
| 320 | } else { |
| 321 | algo_desc.push_back({}); |
| 322 | } |
| 323 | for (size_t i = 0; i < algo_desc.size(); ++i) { |
| 324 | opr_cur->execution_policy().algo = algo_desc[i]; |
| 325 | m_proxy.exec(opr_cur, tensors_cur); |
| 326 | m_proxy.exec(opr_cur, tensors_single_batch); |
| 327 | |
| 328 | copy_tensors_from_device(tensors_cur_out, tensors_cur); |
| 329 | copy_tensors_from_device(tensors_single_batch_out, tensors_single_batch); |
| 330 | |
| 331 | check_tensors_ignore_batch( |
| 332 | tensors_single_batch_out, tensors_cur_out, algo_desc[i]); |
| 333 | } |
nothing calls this directly
no test coverage detected