class Tensorflow::ExecutionContext
Public Class Methods
context()
click to toggle source
# File lib/tensorflow/execution_context.rb, line 8 def self.context Thread.current[:execution_context] ||= self.new end
new()
click to toggle source
# File lib/tensorflow/execution_context.rb, line 12 def initialize @stack = Array.new end
Public Instance Methods
current(inputs=[])
click to toggle source
# File lib/tensorflow/execution_context.rb, line 48 def current(inputs=[]) figure_from_context || figure_from_inputs(inputs) || figure_from_execution_mode end
eager?(inputs=[])
click to toggle source
# File lib/tensorflow/execution_context.rb, line 52 def eager?(inputs=[]) context = self.current(inputs) context.is_a?(Eager::Context) end
figure_from_context()
click to toggle source
# File lib/tensorflow/execution_context.rb, line 36 def figure_from_context @stack.last end
figure_from_execution_mode()
click to toggle source
# File lib/tensorflow/execution_context.rb, line 40 def figure_from_execution_mode if ::Tensorflow.execution_mode == Tensorflow::GRAPH_MODE Graph::Graph.default else Eager::Context.default end end
figure_from_inputs(inputs=[])
click to toggle source
# File lib/tensorflow/execution_context.rb, line 24 def figure_from_inputs(inputs=[]) inputs.flatten.each do |input| case input when Graph::Operation return input.graph when Eager::TensorHandle return input.context end end nil end
graph?(inputs=[])
click to toggle source
# File lib/tensorflow/execution_context.rb, line 57 def graph?(inputs=[]) context = self.current(inputs) context.is_a?(Graph::Graph) end
pop()
click to toggle source
# File lib/tensorflow/execution_context.rb, line 20 def pop @stack.pop end
push(value)
click to toggle source
# File lib/tensorflow/execution_context.rb, line 16 def push(value) @stack.push(value) end