initialization lite_tensors when input is composed of discrete multiple tensors
| 795 | |
| 796 | //! initialization lite_tensors when input is composed of discrete multiple tensors |
| 797 | void NetworkImplDft::update_input_lite_tensors() { |
| 798 | auto device_type = m_user_config->device_type; |
| 799 | auto device_id = m_compnode_locator.device; |
| 800 | auto stream_id = m_compnode_locator.stream; |
| 801 | |
| 802 | for (auto&& in_tensor_iter : m_load_result.tensor_map) { |
| 803 | if (in_tensor_iter.first != m_user_config->discrete_input_name) { |
| 804 | continue; |
| 805 | } |
| 806 | for (auto&& config_in : m_network_io->inputs) { |
| 807 | if (in_tensor_iter.first == config_in.name) { |
| 808 | size_t bs = in_tensor_iter.second->shape(0); |
| 809 | auto shape = in_tensor_iter.second->shape(); |
| 810 | if (config_in.config_layout.ndim) { |
| 811 | bs = config_in.config_layout.shapes[0]; |
| 812 | for (size_t i = 0; i < config_in.config_layout.ndim; ++i) { |
| 813 | shape.shape[i] = config_in.config_layout.shapes[i]; |
| 814 | } |
| 815 | } |
| 816 | shape.shape[0] = 1; |
| 817 | for (size_t i = 0; i < bs; ++i) { |
| 818 | HostTensorND tensor( |
| 819 | in_tensor_iter.second->comp_node(), shape, |
| 820 | in_tensor_iter.second->dtype(), |
| 821 | in_tensor_iter.second->format()); |
| 822 | if (config_in.is_host) { |
| 823 | config_in.lite_tensors.push_back(std::make_shared<Tensor>( |
| 824 | device_id, stream_id, device_type, true)); |
| 825 | TensorHelper::implement(config_in.lite_tensors[i]) |
| 826 | ->cast_final_safe<TensorImplDft>() |
| 827 | .m_host_tensor = std::make_shared<HostTensorND>(tensor); |
| 828 | config_in.lite_tensors[i]->update_from_implement(); |
| 829 | } else { |
| 830 | config_in.lite_tensors.push_back(std::make_shared<Tensor>( |
| 831 | device_id, stream_id, device_type)); |
| 832 | config_in.lite_tensors[i]->set_layout( |
| 833 | to_lite_layout(tensor.layout())); |
| 834 | } |
| 835 | TensorHelper::implement(config_in.lite_tensors[i]) |
| 836 | ->cast_final_safe<TensorImplDft>() |
| 837 | .m_record_reset = |
| 838 | m_user_config->options.comp_node_seq_record_level > 0; |
| 839 | } |
| 840 | } |
| 841 | } |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | void NetworkImplDft::update_output() { |
| 846 | auto device_type = m_user_config->device_type; |
nothing calls this directly
no test coverage detected