in source/neuropod/backends/tensorflow/tf_backend.cc [214:259]
void TensorflowNeuropodBackend::load_model_internal()
{
// Load custom ops (if any)
for (const auto &item : model_config_->custom_ops)
{
const auto path = "0/ops/" + item;
const auto hash = loader_->get_hash_for_file(path);
// Don't load a custom op if we've already loaded it
std::lock_guard<std::mutex> lock(loaded_op_mutex);
if (loaded_op_hashes.count(hash) == 0)
{
if (dlopen(loader_->get_file_path(path).c_str(), RTLD_NOW) == nullptr)
{
const auto err = dlerror();
if (err == nullptr)
{
NEUROPOD_ERROR("Failed to load custom op. dlopen failed but no error was available");
}
else
{
NEUROPOD_ERROR("Failed to load custom op. Error from dlopen: {}", err);
}
}
loaded_op_hashes.insert(hash);
}
}
// Get a list of the output nodes
for (const auto &output : model_config_->outputs)
{
output_names_.emplace_back(output.name);
}
// Get a stream for the graph
auto graph_stream = loader_->get_istream_for_file("0/data/model.pb");
if (graph_stream)
{
load_frozen_graph(*graph_stream);
}
else
{
load_saved_model();
}
}