Class: TensorStream::RubyStorageManager

Inherits:
Object
  • Object
show all
Defined in:
lib/tensor_stream/evaluator/ruby/storage_manager.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRubyStorageManager

Returns a new instance of RubyStorageManager.



7
8
9
# File 'lib/tensor_stream/evaluator/ruby/storage_manager.rb', line 7

def initialize
  @variables = {}
end

Class Method Details

.current_storage_managerObject



3
4
5
# File 'lib/tensor_stream/evaluator/ruby/storage_manager.rb', line 3

def self.current_storage_manager
  @storage_manager ||= RubyStorageManager.new
end

Instance Method Details

#assign_value(graph, name, value) ⇒ Object



23
24
25
26
27
28
# File 'lib/tensor_stream/evaluator/ruby/storage_manager.rb', line 23

def assign_value(graph, name, value)
  raise "no name specified" if name.nil?

  @variables[graph.object_id] ||= {}
  @variables[graph.object_id][name.to_sym] = value
end

#clear_variables(graph) ⇒ Object



36
37
38
# File 'lib/tensor_stream/evaluator/ruby/storage_manager.rb', line 36

def clear_variables(graph)
  @variables[graph.object_id] = {}
end

#create_variable(graph, name, value) ⇒ Object



17
18
19
20
21
# File 'lib/tensor_stream/evaluator/ruby/storage_manager.rb', line 17

def create_variable(graph, name, value)
  raise "no name specified" if name.nil?

  @variables[graph.object_id][name.to_sym] = value
end

#exists?(graph, name) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/tensor_stream/evaluator/ruby/storage_manager.rb', line 11

def exists?(graph, name)
  return false if !@variables.key?(graph.object_id)

  @variables[graph.object_id].key?(name.to_sym)
end

#read_value(graph, name) ⇒ Object



30
31
32
33
34
# File 'lib/tensor_stream/evaluator/ruby/storage_manager.rb', line 30

def read_value(graph, name)
  raise "no name specified" if name.nil?

  @variables[graph.object_id][name.to_sym]
end