Skip to main content

Module writer

Module writer 

Source
Expand description

com.microsoft::EPContext dump / writer path (§55.4) — the inverse of the load path in crate::epcontext.

After the session partitions a graph and an EP compiles a claimed subgraph, it asks that EP for its compiled context (save_context) and hands the result here. This module:

  1. builds one com.microsoft::EPContext Node per compiled partition, carrying the §55.2 attributes (source, ep_sdk_version, partition_name, main_context, embed_mode, ep_cache_context);
  2. handles embed_mode: inline the compiled blob into the ep_cache_context STRING attribute (byte-exact, via the byte-preserving IR string attr), or write it to an external sidecar .bin next to the output model and store the relative path (mirroring the §19.2 external-data convention so the produced model round-trips through the §55.3 load path);
  3. replaces each partition’s nodes with its single EPContext node, wiring the partition’s boundary inputs/outputs to the node’s variadic i/o; and
  4. serialises the resulting model to <orig_stem>_ctx.onnx (or an explicit output path) via the crate::encoder seam.

§Model-agnostic (§55.6 HARD RULE)

Nothing here hardcodes a vendor/op/model name. The EPContext op-type/domain come from the shared constants in crate::epcontext; every source key, SDK version, partition name, and blob comes from the caller (ultimately from the EP via its trait). Adding a new compiled EP needs no change here.

Structs§

EpContextDumpConfig
Configuration for the EPContext dump path (§55.4).
EpContextPartition
One EP-compiled partition to serialise into an EPContext node (§55.4).

Functions§

dump_ep_context
Dump model to a *_ctx.onnx context-cache model, replacing each compiled partition’s subgraph with a single com.microsoft::EPContext node (§55.4).