R/compilation_unit.R

Defines functions .DollarNames.torch_compilation_unit `$.torch_compilation_unit`

CompilationUnit <- R7Class(
  classname = "torch_compilation_unit",
  public = list(
    ptr = NULL,
    initialize = function() {
      cpp_jit_compilation_unit()
    },
    print = function() {
      cat("<torch_compilation_unit>")
    }
  )
)

#' @export
`$.torch_compilation_unit` <- function(x, name) {
  f <- cpp_jit_compile_get_function(x, name)
  if (is.null(f)) {
    return(NextMethod("$", x))
  }
  new_script_function(f)
}

#' @export
.DollarNames.torch_compilation_unit <- function(x, pattern = "") {
  candidates <- cpp_jit_compile_list_methods(x)
  candidates <- sort(candidates[grepl(pattern, candidates)])
  # attr(candidates, "helpHandler") <- "torch:::help_handler"
  candidates
}

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.