| 446 | } |
| 447 | |
| 448 | SmallVector<Handle> ChannelImpl::apply_op_impl( |
| 449 | std::shared_ptr<OpDef> op, const SmallVector<Handle>& inputs) { |
| 450 | auto& state = get_channel_state(); |
| 451 | for (auto i : inputs) { |
| 452 | mgb_assert( |
| 453 | m_valid_handle.find(i) != m_valid_handle.end(), "invalid handle: %p", |
| 454 | i); |
| 455 | } |
| 456 | SmallVector<TensorInfo*> input_infos; |
| 457 | SmallVector<LogicalTensorDesc> input_descs; |
| 458 | { |
| 459 | MGB_LOCK_GUARD(m_info_spin); |
| 460 | for (auto i : inputs) { |
| 461 | auto info = reinterpret_cast<TensorInfo*>(i); |
| 462 | mgb_assert( |
| 463 | !info->invalid, |
| 464 | "an input tensor is unusable due to previous error"); |
| 465 | input_infos.push_back(info); |
| 466 | input_descs.push_back(info->desc); |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | SmallVector<Handle> outputs; |
| 471 | DispatchMode dispatch_mode = state.options.enable_host_compute |
| 472 | ? OpDef::decide_dispatch_mode(*op, input_descs) |
| 473 | : DispatchMode::KERNEL; |
| 474 | switch (dispatch_mode) { |
| 475 | case DEFAULT_CPU: { |
| 476 | dispatch_default_cpu(op, input_infos, input_descs, &outputs); |
| 477 | break; |
| 478 | } |
| 479 | case KERNEL: { |
| 480 | dispatch_kernel(op, input_infos, input_descs, &outputs); |
| 481 | break; |
| 482 | } |
| 483 | } |
| 484 | return outputs; |
| 485 | } |
| 486 | |
| 487 | HostTensorND ChannelImpl::get_value(Handle handle) { |
| 488 | MGB_LOCK_GUARD(m_spin); |
nothing calls this directly
no test coverage detected