Sha256: a0518a9b06a9114d9aa4873c84685a96e5f1579686b541689d9b7f9775b93011

Contents?: true

Size: 644 Bytes

Versions: 3

Compression:

Stored size: 644 Bytes

Contents

module TensorFlow
  class Context
    def initialize
      options = FFI.TFE_NewContextOptions
      @status = TensorFlow::FFI.TF_NewStatus
      @pointer = FFI.TFE_NewContext(options, @status)
      Utils.check_status @status
      ObjectSpace.define_finalizer(self, self.class.finalize(@pointer))
      FFI.TFE_DeleteContextOptions(options)
    end

    def self.finalize(pointer)
      # must use proc instead of stabby lambda
      proc { FFI.TFE_DeleteContext(pointer) }
    end

    def to_ptr
      @pointer
    end

    def shared_name
      # hard-coded in Python library
      "cd2c89b7-88b7-44c8-ad83-06c2a9158347"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tensorflow-0.1.2 lib/tensorflow/context.rb
tensorflow-0.1.1 lib/tensorflow/context.rb
tensorflow-0.1.0 lib/tensorflow/context.rb