Skip to main content

define_extension_runtime

Macro define_extension_runtime 

Source
define_extension_runtime!() { /* proc-macro */ }
Expand description

Generate a standard extension module, preparation engine, and prepared operation.

Exactly one execution route must be supplied.

  • execute_reads runs the operation inside the runtime-formed context and has this signature: fn<B: BackendSession + ?Sized>(&OpType, &[TensorRead<'_>], &mut ExtensionExecutionContext<'_, B>). The generated owner entry opens the backend session and the context borrows it (B is dyn BackendSession), so the callback never runs on the owner. Prefer the session route below for new extensions.
  • the session route (execute_in_session + session_supported) is the preferred one: session_supported has signature fn<B: BackendBound + 'static>(&OpType) -> bool and execute_in_session has signature fn(&OpType, &mut dyn BackendSession, &mut ExtensionCacheStore, &[TensorRead<'_>]). With it, the generated owner entry forms the session itself and hands the extension only a session, so no operation ever runs on the owner.

The legacy execute argument is accepted but unused and may be omitted.