INNER CODE UNIT · Python
_capture
lean-dojo/TorchLean · torchlean/__init__.py:56
def _capture(model: Any, examples: tuple[Any, ...], frontend: str, command: list[str],
directory: Path, checks: Sequence[str]) -> dict[str, Any]:
compare = "compare" in checks or "compare_bitwise" in checks
execute = compare or "execute" in checks
if not examples or examples[0] is None:
raise ValueError("capturing a computation requires example tensors")
if frontend == "jax":
from NN.Runtime.JAX.jaxpr import Unsupported, encode, export, references
try:
artifact = export(model, *examples)
except Unsupported as error:
raise NotImplementedError(str(error)) from error
if execute:
artifact["arguments"] = [encode(value) for value in examples]
if compare:
artifact.update(references(model, *examples))
return artifact