Class: Tensorflow::Status
- Inherits:
-
Object
- Object
- Tensorflow::Status
- Defined in:
- lib/tensorflow/status.rb
Class Method Summary collapse
Instance Method Summary collapse
- #check ⇒ Object
- #code ⇒ Object
-
#initialize ⇒ Status
constructor
A new instance of Status.
- #message ⇒ Object
- #set(code, message) ⇒ Object
- #to_ptr ⇒ Object
Constructor Details
Class Method Details
.check ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/tensorflow/status.rb', line 11 def self.check status = Status.new result = yield status status.check status = nil result end |
.finalize(pointer) ⇒ Object
5 6 7 8 9 |
# File 'lib/tensorflow/status.rb', line 5 def self.finalize(pointer) proc do FFI::TF_DeleteStatus(pointer) end end |
Instance Method Details
#check ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/tensorflow/status.rb', line 40 def check if self.code != :tf_ok camel_case = self.code[3..-1].capitalize camel_case.gsub!(/(?:_|(\/))([a-z\d]*)/i) {"#{$1}#{$2.capitalize}"} error_klass = Tensorflow::Error.const_get("#{camel_case}Error") raise(error_klass, self.) end end |
#code ⇒ Object
28 29 30 |
# File 'lib/tensorflow/status.rb', line 28 def code FFI.TF_GetCode(self) end |
#message ⇒ Object
32 33 34 |
# File 'lib/tensorflow/status.rb', line 32 def FFI.TF_Message(self) end |
#set(code, message) ⇒ Object
36 37 38 |
# File 'lib/tensorflow/status.rb', line 36 def set(code, ) FFI.TF_SetStatus(self, code, ) end |
#to_ptr ⇒ Object
24 25 26 |
# File 'lib/tensorflow/status.rb', line 24 def to_ptr @pointer end |