It is for our project mandotary, that the network is loaded by file not per directory.
At the moment I load per directory the saved_model.pb this way and it is working:
auto tfSessionOpts = TF_NewSessionOptions();
runOpts = nullptr:
TF_Session * pSession = TF_LoadSessionFromSavedModel(tfSessionOpts,
runOpts,
m_strModelDir.c_str(),
m_vecTags.data(),
static_cast<int>(m_vecTags.size()),
m_graph,
nullptr,
status);
Now I have to switch to a load per file methode, while using the c_apiI have a frozen_graph.pb which I want to load in C and get some information from it.
What I do is:
Load the frozen_graph.pb into the buffer:
std::ifstream f(m_strModelFile, std::ios::binary);
if (f.seekg(0, std::ios::end).fail()) { throw; }
auto fsize = f.tellg();
if (f.seekg(0, std::ios::beg).fail()) { throw; }
if (fsize <= 0) { throw; }
auto data = static_cast<char*>(std::malloc(fsize));
if (f.read(data, fsize).fail()) { throw; }
TF_Buffer* pBuffer = TF_NewBuffer();
pBuffer->data = data;
pBuffer->length = fsize;
pBuffer->data_deallocator = DeallocateBuffer;
load the graph with the buffer (status is okay):
TF_ImportGraphDefOptions* pGraphDefOptions = TF_NewImportGraphDefOptions();
TF_GraphImportGraphDef(m_graph, pBuffer, pGraphDefOptions, status);
load the session (status is okay):
auto tfSessionOpts = TF_NewSessionOptions();
TF_Session* session = TF_NewSession(m_graph, sessionOptions, status);
Well, the buffer has the correct size, the graph and session is not nullptr and status says “ok”.
But when I want to use the graph, then there is no information I can use.
Like for example I can not get specific Operation:
auto input_op = TF_Output{ TF_GraphOperationByName(m_graph, "StatefulPartitionedCall"), 1 };
if (input_op.oper == nullptr)
{
throw; // this happens
}
But this is possible, when I construct the graph with the TF_LoadSessionFromSavedModel function.
Am I doing sth. wrong or can a graph with usefull information not be loaded per filename?
If it is not possible with the c_api, is it possible with the c++ API?