Skip to content

tenzr::ExecutionEngine

Compiles and executes tensor graphs, dispatching work through the hardware manager and JIT cache.

#include <execution_engine.h>

Public Functions

Name
ExecutionEngine()
Construct an engine bound to the global hardware manager, initializing it if needed.
ExecutionEngine(HardwareManager & hw_manager)
~ExecutionEngine() =default
std::shared_ptr< CachedExecutable > Compile(const Tensor & root)
std::shared_ptr< CachedExecutable > CompileOptimized(const std::shared_ptr< Node > & target_node)
ExecutionResult Execute(const Tensor & root)
std::future< ExecutionResult > ExecuteAsync(const Tensor & root)

Public Functions Documentation

function ExecutionEngine

ExecutionEngine()

Construct an engine bound to the global hardware manager, initializing it if needed.

function ExecutionEngine

explicit ExecutionEngine(
    HardwareManager & hw_manager
)

Parameters:

  • hw_manager Hardware manager to use.

Construct an engine bound to a specific hardware manager.

function ~ExecutionEngine

~ExecutionEngine() =default

function Compile

std::shared_ptr< CachedExecutable > Compile(
    const Tensor & root
)

Parameters:

  • root Root node of the graph to compile.
  • root Tensor expression to compile.

Return:

  • Cached executable for the graph.
  • The compiled, cached executable.

Compile a graph into a cached executable. Optimize, lower, and compile a tensor's expression graph to a cached PJRT executable.

function CompileOptimized

std::shared_ptr< CachedExecutable > CompileOptimized(
    const std::shared_ptr< Node > & target_node
)

Parameters:

  • target_node Root node of the graph to compile.
  • target_node Optimized graph root.

Return:

  • Cached executable for the graph.
  • The compiled, cached executable.

Compile a graph root into a cached executable. Emit StableHLO for an already-optimized AST and compile it through PJRT, consulting the JIT cache.

function Execute

ExecutionResult Execute(
    const Tensor & root
)

Parameters:

  • root Root node of the graph to execute.
  • root Tensor expression to evaluate.

Return:

  • Execution result holding device and host storage.
  • The execution result.

Execute a graph synchronously on the device. Run a tensor expression, uploading parameters and returning a device-resident result.

function ExecuteAsync

inline std::future< ExecutionResult > ExecuteAsync(
    const Tensor & root
)

Parameters:

  • root Root node of the graph to execute.

Return: Future yielding the ExecutionResult once the work completes.

Execute a graph asynchronously on the default stream's worker thread.