Permalink
Browse files

Merge pull request #108 from WGautier/master

Fix missing null termination in tag list when loading a saved model
  • Loading branch information...
Arafatk committed Aug 17, 2018
2 parents bb916cf + 9131a35 commit 1adf4fe9fa60e006fcecb4858ec22aa71f149ec0
Showing with 2 additions and 7 deletions.
  1. +2 −7 ext/sciruby/tensorflow_c/files/tf_tensor_helper.cc
@@ -259,17 +259,12 @@ TF_OperationDescription* input_list_helper(TF_OperationDescription* cdesc, TF_Ou
}

TF_Session* Saved_model_helper(TF_SessionOptions* cOpt, std::string cExportDir, std::vector<std::string> tags, TF_Graph* (graph_c),TF_Status* status_c){
char **tags_array;
tags_array = new char*[tags.size()];
const char* tags_array[tags.size()];
for(auto i = 0; i < tags.size(); i++) {
tags_array[i] = new char[tags[i].length()];
for(auto j = 0; j < tags[i].length(); j++) tags_array[i][j] = tags[i][j];
tags_array[i] = tags[i].c_str();
}
const char* ExportDir = cExportDir.c_str();
auto cSess = TF_LoadSessionFromSavedModel(cOpt, NULL, ExportDir,&tags_array[0], tags.size(), graph_c, NULL, status_c);
for(auto i = 0; i < tags.size(); i++) {
free(tags_array[i]);
}
TF_DeleteSessionOptions(cOpt);
return cSess;
}

0 comments on commit 1adf4fe

Please sign in to comment.