jit_save: Saves a 'script_function' to a path

Description Usage Arguments Examples

View source: R/trace.R

Description

Saves a script_function to a path

Usage

1
jit_save(obj, path, ...)

Arguments

obj

An script_function to save

path

The path to save the serialized function.

...

currently unused

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
if (torch_is_installed()) {
fn <- function(x) {
  torch_relu(x)
}

input <- torch_tensor(c(-1, 0, 1))
tr_fn <- jit_trace(fn, input)

tmp <- tempfile("tst", fileext = "pt")
jit_save(tr_fn, tmp)

}

torch documentation built on Oct. 7, 2021, 9:22 a.m.