Expand description
Compiles environments exported from JAX into the Rust modules of a crate, from its build script.
ruxla.export_env (or python -m ruxla.export) writes each environment
to a directory (manifest.json, reset.json, step.json, …). A build
script imports every such directory under one root and generates, in
$OUT_DIR/ruxla_envs.rs, a module per environment with a unit struct
Env that implements CompiledEnv,
plus MODULES (the module names) and visit (an environment by name,
through a Visitor).
[dependencies]
ruxla-env = "..."
ruxla-codegen = "..." # the generated code refers to these three crates
ruxla-ir = "..."
[build-dependencies]
ruxla-build = "..."
# The code generator runs in the build script: optimize it.
[profile.dev.build-override]
opt-level = 3
[profile.release.build-override]
opt-level = 3ⓘ
// build.rs
fn main() {
ruxla_build::compile_envs("envs");
}ⓘ
// lib.rs
ruxla_env::include_envs!();
// gymnax_cartpole_v1::Env, MODULES, visit(...)A cdylib that also has ruxla_env::export_vec_envs!(); can be loaded by
programs built separately, such as ruxla.compile_env in Python
(ruxla_env::dylib).
Structs§
- Builder
- The compilation of a directory of exported environments.
- Options
- The options of the optimizations.
Constants§
- OUT_
FILE - The file that
Builder::compilewrites in$OUT_DIR.
Functions§
- compile_
envs - Compiles every exported environment under
dir(seeBuilder):RUXLA_JAX_ENVSreplacesdirandRUXLA_JAX_ENVS_ONLYselects modules. Returns the compiled modules.