| 103 | } |
| 104 | |
| 105 | std::shared_ptr<void> ModelParser::parse_model( |
| 106 | size_t& model_length, const Config& config) const { |
| 107 | if (m_is_bare_model) { |
| 108 | if (config.bare_model_cryption_name.size() == 0) { |
| 109 | model_length = m_total_length; |
| 110 | return m_model; |
| 111 | } else { |
| 112 | return decrypt_memory( |
| 113 | static_cast<uint8_t*>(m_model.get()), m_total_length, |
| 114 | config.bare_model_cryption_name, model_length); |
| 115 | } |
| 116 | } |
| 117 | LITE_ASSERT(m_model_data, "packed model parse error!"); |
| 118 | model_length = m_model_data->data()->size(); |
| 119 | const uint8_t* model_data = m_model_data->data()->Data(); |
| 120 | LITE_ASSERT(model_length > 0, "The loaded model is of zero length."); |
| 121 | return decrypt_memory( |
| 122 | model_data, model_length, m_model_decryption_name, model_length); |
| 123 | } |
| 124 | |
| 125 | std::shared_ptr<void> ModelParser::decrypt_memory( |
| 126 | const uint8_t* data, size_t length, const std::string decryption_name, |
no test coverage detected