Class: TensorFlow::Context
- Inherits:
-
Object
- Object
- TensorFlow::Context
- Defined in:
- lib/tensorflow/context.rb
Class Method Summary collapse
Instance Method Summary collapse
- #device_policy ⇒ Object
- #disable_run_metadata ⇒ Object
- #enable_run_metadata ⇒ Object
- #end_step ⇒ Object
- #function?(name) ⇒ Boolean
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #shared_name ⇒ Object
- #start_step ⇒ Object
- #to_ptr ⇒ Object
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
3 4 5 6 7 8 9 10 |
# File 'lib/tensorflow/context.rb', line 3 def initialize = FFI.TFE_NewContextOptions @status = TensorFlow::FFI.TF_NewStatus @pointer = FFI.TFE_NewContext(, @status) Utils.check_status @status ObjectSpace.define_finalizer(self, self.class.finalize(@pointer)) FFI.TFE_DeleteContextOptions() end |
Class Method Details
.finalize(pointer) ⇒ Object
36 37 38 39 |
# File 'lib/tensorflow/context.rb', line 36 def self.finalize(pointer) # must use proc instead of stabby lambda proc { FFI.TFE_DeleteContext(pointer) } end |
Instance Method Details
#device_policy ⇒ Object
16 17 18 |
# File 'lib/tensorflow/context.rb', line 16 def device_policy FFI::ContextDevicePlacementPolicy[FFI.TFE_ContextGetDevicePlacementPolicy(@pointer)] end |
#disable_run_metadata ⇒ Object
24 25 26 |
# File 'lib/tensorflow/context.rb', line 24 def FFI.TFE_ContextDisableRunMetadata(@pointer) end |
#enable_run_metadata ⇒ Object
20 21 22 |
# File 'lib/tensorflow/context.rb', line 20 def FFI.TFE_ContextEnableRunMetadata(@pointer) end |
#end_step ⇒ Object
32 33 34 |
# File 'lib/tensorflow/context.rb', line 32 def end_step FFI.TFE_ContextEndStep(@pointer) end |
#function?(name) ⇒ Boolean
12 13 14 |
# File 'lib/tensorflow/context.rb', line 12 def function?(name) FFI.TFE_ContextHasFunction(@pointer, name) != 0 end |
#shared_name ⇒ Object
45 46 47 48 |
# File 'lib/tensorflow/context.rb', line 45 def shared_name # hard-coded in Python library "cd2c89b7-88b7-44c8-ad83-06c2a9158347" end |
#start_step ⇒ Object
28 29 30 |
# File 'lib/tensorflow/context.rb', line 28 def start_step FFI.TFE_ContextStartStep(@pointer) end |
#to_ptr ⇒ Object
41 42 43 |
# File 'lib/tensorflow/context.rb', line 41 def to_ptr @pointer end |