functionalize.functionalize_parametric
functionalize.functionalize_parametric(sdf)Compile an SDF to a function whose parameters are arguments.
:func:functionalize closes over the parameter values, so jax.jit of the result folds every one of them into the program as a literal: two designs that differ only in a slider value lower to two different HLO modules, compile separately, and miss each other in the persistent compilation cache. This form takes them as arrays instead, so the lowered text is byte-identical for every value of every parameter and one compiled executable serves them all.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| sdf | The SDF to compile. | required |
Returns
| Name | Type | Description |
|---|---|---|
| Callable | fn(free_params, fixed_params, point) -> distance, safe to wrap in :func:jax.jit directly. |
Example
free, fixed, _ = extract_parameters(scene)
evaluate = jax.jit(functionalize_parametric(scene))
distance = evaluate(free, fixed, jnp.zeros(3))