Understanding C Inference code
iamsurya opened this issue · 3 comments
This isn't a bug, but I'd like some help understanding this particular section of the code in
inference/c/inference_c.c (lines 61 - 78). It looks like a string to the checkpoint file is setup but nothing is done with it?
char* checkpoint_path_str = "./exported/my_model";
size_t checkpoint_path_str_len = strlen(checkpoint_path_str);
size_t encoded_size = TF_StringEncodedSize(checkpoint_path_str_len);
// The format for TF_STRING tensors is:
// start_offset: array[uint64]
// data: byte[...]
size_t total_size = sizeof(int64_t) + encoded_size;
char* input_encoded = (char*)malloc(total_size);
memset(input_encoded, 0, total_size);
TF_StringEncode(checkpoint_path_str, checkpoint_path_str_len,
input_encoded + sizeof(int64_t), encoded_size, status);
if (TF_GetCode(status) != TF_OK) {
fprintf(stderr, "ERROR: something wrong with encoding: %s",
TF_Message(status));
return 1;
}
The checkpoint_path_str
as a C-string is converted to a TF-String input_encoded
and then used to load a checkpoint file. TensorFlow does not understand a plain C-String (as far as I know).
Thanks that makes sense. However, assuming the graph is frozen using Tensorflow python, what use is a checkpoint? Shouldn't the frozen graph already contain the latest weights?
I'd also like to thank you for this project. I was able to use a variation of your C inference code with libtensorflow on Windows / Visual Studio to make an inference. I see some users are having issues trying to run on Windows, I might be able to try and help them a little bit.
Shouldn't the frozen graph already contain the latest weights?
The graph isn't a frozen graph:
tensorflow-cmake/inference/example.py
Lines 16 to 17 in dc0b4ee
I see some users are having issues trying to run on Windows, I might be able to try and help them a little bit.
That would be indeed nice. I would like to adjust the CMakeLists.txt to support windows if possible.