Class: Tensorflow::Eager::TensorHandle
- Inherits:
-
Object
- Object
- Tensorflow::Eager::TensorHandle
show all
- Includes:
- Operators, TensorMixin
- Defined in:
- lib/tensorflow/eager/tensor_handle.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Operators
#%, #*, #**, #+, #-, #-@, #/
#numo, #shape
Constructor Details
#initialize(context, value) ⇒ TensorHandle
Returns a new instance of TensorHandle.
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/tensorflow/eager/tensor_handle.rb', line 30
def initialize(context, value)
@context = context
case value
when ::FFI::Pointer
@pointer = value
when Tensor
Status.check do |status|
@pointer = FFI.TFE_NewTensorHandle(value, status)
end
@tensor = value
else
raise(Error::InvalidArgumentError, "Invalid value passed to tensor_handle: #{value}")
end
ObjectSpace.define_finalizer(self, self.class.finalize(@pointer))
end
|
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
7
8
9
|
# File 'lib/tensorflow/eager/tensor_handle.rb', line 7
def context
@context
end
|
Class Method Details
.finalize(pointer) ⇒ Object
9
10
11
12
13
|
# File 'lib/tensorflow/eager/tensor_handle.rb', line 9
def self.finalize(pointer)
proc do
FFI.TFE_DeleteTensorHandle(pointer)
end
end
|
.from_value(context, value, dtype: nil) ⇒ Object
Instance Method Details
#dtype ⇒ Object
58
59
60
|
# File 'lib/tensorflow/eager/tensor_handle.rb', line 58
def dtype
FFI.TFE_TensorHandleDataType(self)
end
|
#element_count ⇒ Object
62
63
64
65
66
|
# File 'lib/tensorflow/eager/tensor_handle.rb', line 62
def element_count
Status.check do |status|
FFI.TFE_TensorHandleNumElements(self, status)
end
end
|
#tensor ⇒ Object
52
53
54
55
56
|
# File 'lib/tensorflow/eager/tensor_handle.rb', line 52
def tensor
Status.check do |status|
Tensor.from_pointer(FFI.TFE_TensorHandleResolve(self, status))
end
end
|
#to_ptr ⇒ Object
48
49
50
|
# File 'lib/tensorflow/eager/tensor_handle.rb', line 48
def to_ptr
@pointer
end
|
#value ⇒ Object
68
69
70
|
# File 'lib/tensorflow/eager/tensor_handle.rb', line 68
def value
self.tensor.value
end
|