Permalink
Browse files

Fix graph operation returning null pointer operation

Previously, graph.operation would warn about an operation being nil (if
the operation didn't exist in the graph), but still return a new
tensorflow operation created using the null pointer.  This results in a
crash if that operation is ever used in a SessionRun call.
  • Loading branch information...
AshtonO committed Jul 19, 2017
1 parent 27fdff3 commit 91f34387ec7144271dbe7bf773650d0686760930
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/tensorflow/graph.rb
@@ -62,8 +62,12 @@ def read_file(filename)
# operation is present.
def operation(name)
c_operation = Tensorflow::TF_GraphOperationByName(c, CString(name))
warn("No Operation with the name #{name} exists.") if c_operation.nil?
Tensorflow::Operation.new(c_operation, self)
if c_operation.nil?
warn("No Operation with the name #{name} exists.")
nil
else
Tensorflow::Operation.new(c_operation, self)
end
end

# Adds a placeholder to the Graph, a placeholder is an

0 comments on commit 91f3438

Please sign in to comment.