Module: NDAV::Torch::FromNDAV
- Defined in:
- lib/ndav/torch/tensor.rb
Instance Method Summary collapse
Instance Method Details
#from_ndav(ndav) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ndav/torch/tensor.rb', line 8 def from_ndav(ndav) dtype = Tensor::FORMAT_TO_TYPE[ndav.format] raise ArgumentError, "unsupported format: #{input.format}, currently supported: #{Tensor::TYPE_TO_FORMAT.values}" unless dtype opts = (dtype:) tensor = _from_blob_ref(ndav.to_s, [ndav.byte_size / ndav.item_size], opts) .reshape(ndav.shape) tensor.instance_variable_set(:@ndav, ndav) # keep reference to NDAV to prevent GC tensor end |