Class: Torch::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/torch/device.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object



13
14
15
# File 'lib/torch/device.rb', line 13

def ==(other)
  eql?(other)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/torch/device.rb', line 17

def eql?(other)
  other.is_a?(Device) && other.type == type && other.index == index
end

#hashObject



21
22
23
# File 'lib/torch/device.rb', line 21

def hash
  [type, index].hash
end

#indexObject



3
4
5
# File 'lib/torch/device.rb', line 3

def index
  index? ? _index : nil
end

#inspectObject Also known as: to_s



7
8
9
10
# File 'lib/torch/device.rb', line 7

def inspect
  extra = ", index: #{index.inspect}" if index?
  "device(type: #{type.inspect}#{extra})"
end