jit_compile: Compile TorchScript code into a graph

View source: R/jit-compile.R

jit_compileR Documentation

Compile TorchScript code into a graph

Description

See the TorchScript language reference for documentation on how to write TorchScript code.

Usage

jit_compile(source)

Arguments

source

valid TorchScript source code.

Examples

if (torch_is_installed()) {
comp <- jit_compile("
def fn (x):
  return torch.abs(x)

def foo (x):
  return torch.sum(x)

")

comp$fn(torch_tensor(-1))
comp$foo(torch_randn(10))
}

torch documentation built on May 29, 2024, 9:54 a.m.