MCPcopy Create free account
hub / github.com/OpenNMT/CTranslate2 / load_model

Method load_model

python/cpp/replica_pool.h:141–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139 }
140
141 void load_model(const bool keep_cache) {
142 std::unique_lock lock(_mutex);
143 if (_model_is_loaded)
144 return;
145
146 std::vector<std::shared_ptr<const models::Model>> loaded_models;
147 if (_cached_models.empty())
148 loaded_models = _model_loader.load();
149 else
150 loaded_models = clone_models(_device, _device_index, _cached_models, _num_replicas_per_device);
151
152 _pool->set_models(loaded_models);
153 if (!keep_cache)
154 _cached_models.clear();
155 _model_is_loaded = true;
156 }
157
158 protected:
159 std::unique_ptr<T> _pool;

Callers 2

test_model_unloadFunction · 0.45

Calls 3

set_modelsMethod · 0.80
emptyMethod · 0.45
loadMethod · 0.45

Tested by 2

test_model_unloadFunction · 0.36