module Tensorflow::Decorator

Public Class Methods

extended(klass) click to toggle source
# File lib/tensorflow/decorators.rb, line 15
def self.extended(klass)
  @waiting_for_method = false
  this = self
  klass.instance_eval do
    @tf = this
  end

  if klass.is_a?(Object) && klass.to_s == 'main'
    klass.class.extend(self)
  end
end
function(input_signature = []) click to toggle source
# File lib/tensorflow/decorators.rb, line 27
def self.function(input_signature = [])
  @current_function = Function.new(input_signature)
end
wrap_method(method) click to toggle source
# File lib/tensorflow/decorators.rb, line 31
def self.wrap_method(method)
  # We do this little dance because when the method is wrapped it will trigger method_added. So first we need
  # to clear out @current_function before continuing
  if @current_function
    current_function = @current_function
    @current_function = nil
    current_function&.wrap(method)
  end
end

Public Instance Methods

method_added(method_name) click to toggle source
Calls superclass method
# File lib/tensorflow/decorators.rb, line 47
def method_added(method_name)
  super(method_name)
  method = self.instance_method(method_name)
  @tf.wrap_method(method)
end
singleton_method_added(method_name) click to toggle source
Calls superclass method
# File lib/tensorflow/decorators.rb, line 41
def singleton_method_added(method_name)
  super(method_name)
  method = self.method(method_name)
  @tf.wrap_method(method)
end