R/storage.R

#' @include tensor.R
NULL

Tensor$set("public", "storage", function() {
  Storage$new(cpp_Tensor_storage(self$ptr))
})

Tensor$set("public", "has_storage", function() {
  Storage$new(cpp_Tensor_has_storage(self$ptr))
})

Storage <- R6::R6Class(
  "torch_storage",
  lock_objects = FALSE,
  public = list(
    initialize = function(ptr) {
      self$ptr <- ptr
    },
    data_ptr = function() {
      cpp_Storage_data_ptr(self$ptr)
    }
  )
)

Try the torch package in your browser

Any scripts or data that you put into this service are public.

torch documentation built on June 7, 2023, 6:19 p.m.