exportModelToJson

fun <T : Any> exportModelToJson(model: T, label: String = model::class.simpleName ?: "model"): SkJsonExport(source)

Facade to export a high-level model or a prebuilt ComputeGraph into the JSON export model.

Capabilities:

  • If model is already a ComputeGraph, delegates to exportGraphToJson.

  • Otherwise, prefer using the overload that accepts a forwardPass lambda to run a single forward execution under a recording tape; the tape is then converted to a ComputeGraph and exported.


fun <T : Any> exportModelToJson(model: T, forwardPass: () -> Unit, label: String = model::class.simpleName ?: "model"): SkJsonExport(source)

Fallback overload for models without a direct adapter.

Provide a forwardPass that executes exactly one forward run of the model with example inputs. The facade will:

  1. Start a recording tape

  2. Execute forwardPass

  3. Convert the tape to a ComputeGraph

  4. Delegate to exportGraphToJson