odin_build: Build an odin model generator from its IR

Description Usage Arguments Details See Also Examples

View source: R/odin_build.R

Description

Build an odin model generator from its intermediate representation, as generated by odin_parse. This function is for advanced use.

Usage

1

Arguments

x

An odin ir (json) object or output from odin_validate.

options

Options to pass to the build stage (see odin_options

Details

In applications that want to inspect the intermediate representation rather before compiling, rather than directly using odin, use either odin_parse or odin_validate and then pass the result to odin_build.

The return value of this function includes information about how long the compilation took, if it was successful, etc, in the same style as odin_validate:

success

Logical, indicating if compilation was successful

elapsed

Time taken to compile the model, as a proc_time object, as returned by proc.time.

output

Any output produced when compiling the model (only present if compiling to C, and if the cache was not hit.

model

The model itself, as an odin_generator object, as returned by odin.

ir

The intermediate representation.

errorAny error thrown during compilation

See Also

odin_parse, which creates intermediate representations used by this function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
##' # Parse a model of exponential decay
ir <- odin::odin_parse({
  deriv(y) <- -0.5 * y
  initial(y) <- 1
})

# Compile the model:
options <- odin::odin_options(target = "r")
res <- odin::odin_build(ir, options)

# All results:
res

# The model:
mod <- res$model()
mod$run(0:10)

richfitz/odin documentation built on July 21, 2020, 7:43 p.m.