| 677 | } |
| 678 | |
| 679 | void test_io_no_copy_ax(std::string model_name, int record = 1) { |
| 680 | std::string model_path = model_name; |
| 681 | std::vector<std::string> input_names, output_names; |
| 682 | |
| 683 | std::vector<std::vector<std::shared_ptr<Tensor>>> inputs; |
| 684 | std::vector<std::vector<std::shared_ptr<Tensor>>> outputs; |
| 685 | |
| 686 | Config config; |
| 687 | |
| 688 | config.options.graph_opt_level = 0; |
| 689 | std::shared_ptr<Network> network = std::make_shared<Network>(config); |
| 690 | network->load_model(model_path); |
| 691 | |
| 692 | input_names = network->get_all_input_name(); |
| 693 | output_names = network->get_all_output_name(); |
| 694 | |
| 695 | // prepare test data |
| 696 | for (int i = 0; i < 3; i++) { |
| 697 | std::vector<std::shared_ptr<Tensor>> net_inputs; |
| 698 | std::vector<std::shared_ptr<Tensor>> net_outputs; |
| 699 | |
| 700 | for (size_t j = 0; j < input_names.size(); j++) { |
| 701 | auto in_tesnor = network->get_io_tensor(input_names[j]); |
| 702 | auto in_layout = in_tesnor->get_layout(); |
| 703 | auto tmp_in = std::make_shared<Tensor>(LiteDeviceType::LITE_CPU, in_layout); |
| 704 | |
| 705 | auto size = in_tesnor->get_tensor_total_size_in_byte() / |
| 706 | in_layout.get_elem_size(); |
| 707 | if (in_layout.data_type == LiteDataType::LITE_INT16) { |
| 708 | auto ptr = static_cast<short*>(tmp_in->get_memory_ptr()); |
| 709 | for (size_t id = 0; id < size; id++) { |
| 710 | ptr[id] = i + 1; |
| 711 | } |
| 712 | } else if (in_layout.data_type == LiteDataType::LITE_UINT8) { |
| 713 | auto ptr = static_cast<uint8_t*>(tmp_in->get_memory_ptr()); |
| 714 | for (size_t id = 0; id < size; id++) { |
| 715 | ptr[id] = i + 1; |
| 716 | } |
| 717 | } |
| 718 | net_inputs.push_back(tmp_in); |
| 719 | in_tesnor->copy_from(*tmp_in); |
| 720 | } |
| 721 | |
| 722 | inputs.push_back(net_inputs); |
| 723 | network->forward(); |
| 724 | network->wait(); |
| 725 | |
| 726 | for (size_t j = 0; j < output_names.size(); j++) { |
| 727 | auto out_tesnor = network->get_io_tensor(output_names[j]); |
| 728 | auto out_layout = out_tesnor->get_layout(); |
| 729 | auto tmp_out = |
| 730 | std::make_shared<Tensor>(LiteDeviceType::LITE_CPU, out_layout); |
| 731 | |
| 732 | tmp_out->copy_from(*out_tesnor); |
| 733 | net_outputs.push_back(tmp_out); |
| 734 | } |
| 735 | outputs.push_back(net_outputs); |
| 736 | } |
no test coverage detected