| 58 | } |
| 59 | |
| 60 | __attribute__((unused)) static std::shared_ptr<Tensor> get_input_data( |
| 61 | std::string path) { |
| 62 | std::string type_str; |
| 63 | std::vector<npy::ndarray_len_t> stl_shape; |
| 64 | std::vector<int8_t> raw; |
| 65 | npy::LoadArrayFromNumpy(path, type_str, stl_shape, raw); |
| 66 | auto lite_tensor = std::make_shared<Tensor>(LiteDeviceType::LITE_CPU); |
| 67 | Layout layout; |
| 68 | layout.ndim = stl_shape.size(); |
| 69 | const std::map<std::string, LiteDataType> type_map = { |
| 70 | {"f4", LiteDataType::LITE_FLOAT}, {"f2", LiteDataType::LITE_HALF}, |
| 71 | {"i8", LiteDataType::LITE_INT64}, {"i4", LiteDataType::LITE_INT}, |
| 72 | {"u4", LiteDataType::LITE_UINT}, {"i2", LiteDataType::LITE_INT16}, |
| 73 | {"u2", LiteDataType::LITE_UINT16}, {"i1", LiteDataType::LITE_INT8}, |
| 74 | {"u1", LiteDataType::LITE_UINT8}}; |
| 75 | layout.shapes[0] = 1; |
| 76 | for (size_t i = 0; i < stl_shape.size(); i++) { |
| 77 | layout.shapes[i] = static_cast<size_t>(stl_shape[i]); |
| 78 | } |
| 79 | for (auto& item : type_map) { |
| 80 | if (type_str.find(item.first) != std::string::npos) { |
| 81 | layout.data_type = item.second; |
| 82 | break; |
| 83 | } |
| 84 | } |
| 85 | lite_tensor->set_layout(layout); |
| 86 | size_t length = lite_tensor->get_tensor_total_size_in_byte(); |
| 87 | void* dest = lite_tensor->get_memory_ptr(); |
| 88 | memcpy(dest, raw.data(), length); |
| 89 | return lite_tensor; |
| 90 | } |
| 91 | |
| 92 | __attribute__((unused)) static std::shared_ptr<Tensor> mgelite_lar( |
| 93 | std::string model_path, const Config& config, std::string, |
no test coverage detected