somaticio / tensorflow.rb

tensorflow for ruby
BSD 3-Clause "New" or "Revised" License
829 stars 63 forks source link

Fix missing null termination in tag list when loading a saved model #108

Closed WGautier closed 6 years ago

WGautier commented 6 years ago

On one of our servers, we were seeing this behaviour:

2018-08-16 16:11:32.549690: I tensorflow/cc/saved_model/loader.cc:233] SavedModel load for tags { serve  }; Status: fail. Took 1261 microseconds.

Notice the extra space after 'serve'. This extra space was actually garbage data from Tensorflow converting the tag list from an array of chars, without null termination, to a string.

Using c_str() creates a correctly null-terminated array of chars and fixes the problem.

As a bonus, though my C++ is rusty, I believe this removes the need for the memory allocation/destruction with new.

arafatkatze commented 6 years ago

@WGautier Thanks a lot for doing this.