Sha256: f05ba979ac453a74ee161532aeaae5ef0ca41de9ba270e1de85513a6b4d9cb0c

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

module TensorStream
  class RubyStorageManager
    def self.current_storage_manager
      @storage_manager ||= RubyStorageManager.new
    end

    def initialize
      @variables = {}
    end

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

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

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

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

    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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tensor_stream-1.0.9 lib/tensor_stream/evaluator/ruby/storage_manager.rb