jit_trace_module | R Documentation |
Trace a module and return an executable ScriptModule that will be optimized
using just-in-time compilation. When a module is passed to jit_trace()
, only
the forward method is run and traced. With jit_trace_module()
, you can specify
a named list of method names to example inputs to trace (see the inputs)
argument below.
jit_trace_module(mod, ..., strict = TRUE)
mod |
A torch |
... |
A named list containing sample inputs indexed by method names
in mod. The inputs will be passed to methods whose names correspond to inputs
keys while tracing. |
strict |
run the tracer in a strict mode or not (default: |
See jit_trace for more information on tracing.
if (torch_is_installed()) {
linear <- nn_linear(10, 1)
tr_linear <- jit_trace_module(linear, forward = list(torch_randn(10, 10)))
x <- torch_randn(10, 10)
torch_allclose(linear(x), tr_linear(x))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.