Class: TensorFlow::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/tensorflow/context.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContext

Returns a new instance of Context.



3
4
5
6
7
8
9
10
# File 'lib/tensorflow/context.rb', line 3

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

Class Method Details

.finalize(pointer) ⇒ Object



12
13
14
15
# File 'lib/tensorflow/context.rb', line 12

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

Instance Method Details

#shared_nameObject



21
22
23
24
# File 'lib/tensorflow/context.rb', line 21

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

#to_ptrObject



17
18
19
# File 'lib/tensorflow/context.rb', line 17

def to_ptr
  @pointer
end