Method: Torch::Tensor#coerce

Defined in:
lib/torch/tensor.rb

#coerce(other) ⇒ Object


205
206
207
208
209
210
211
# File 'lib/torch/tensor.rb', line 205

def coerce(other)
  if other.is_a?(Numeric)
    [Torch.tensor(other), self]
  else
    raise TypeError, "#{self.class} can't be coerced into #{other.class}"
  end
end