Skip to content

tenzr::debug

Functions

Name
void Print(std::string_view label, const Array & x, bool print_data =true, std::ostream & os =std::cout)
void CheckFinite(const Array & x, std::string_view op_context ="")
std::string Inspect(const Array & x)
std::string FormatTxpr(const txpr::Txpr & txpr)
void DumpTxpr(const txpr::Txpr & txpr, std::ostream & os =std::cout)
std::string FormatStablehlo(const txpr::Txpr & txpr)
void DumpStablehlo(const txpr::Txpr & txpr, std::ostream & os =std::cout)

Functions Documentation

function Print

void Print(
    std::string_view label,
    const Array & x,
    bool print_data =true,
    std::ostream & os =std::cout
)

Parameters:

  • label A label printed alongside the value.
  • x The array to print.
  • print_data Whether to include the array's element values.
  • os The output stream.
  • label Text shown before the array summary.
  • x Array to describe.
  • print_data When true, also stream the array values.
  • os Output stream.

Prints runtime or symbolic array information without disrupting tracing or execution; analogous to jax.debug.print. Print a labelled description of x, optionally including its data.

function CheckFinite

void CheckFinite(
    const Array & x,
    std::string_view op_context =""
)

Parameters:

  • x The array to check.
  • op_context Context describing the operation, included in the failure message.
  • x Array to inspect; symbolic or non-float arrays are ignored.
  • op_context Operation name included in the failure message.

Inspects array values for NaNs and infinities, throwing tenzr::TenzrException if detected; analogous to jax_debug_nans. Scan a floating-point array for NaN/Inf values and throw NumericalInstabilityException if any are found.

function Inspect

std::string Inspect(
    const Array & x
)

Parameters:

  • x The array to inspect.
  • x Array to inspect.

Return:

  • The diagnostic description.
  • Human-readable multi-line report.

Returns a forensic diagnostic string describing tensor shape, rank, dtype, residency, and statistics. Build a forensic report describing x's shape, dtype, residency, and finite-value statistics.

function FormatTxpr

std::string FormatTxpr(
    const txpr::Txpr & txpr
)

Parameters:

  • txpr The graph to format.
  • txpr IR graph to format.

Return:

  • The formatted text.
  • Textual representation of the graph.

Pretty-prints a Txpr intermediate representation (SSA equations, variables, inputs, outputs). Render a Txpr IR graph in the compact textual txpr { ... } form.

function DumpTxpr

void DumpTxpr(
    const txpr::Txpr & txpr,
    std::ostream & os =std::cout
)

Parameters:

  • txpr The graph to dump.
  • os The output stream.
  • txpr IR graph to dump.
  • os Output stream.

Writes format_txpr(txpr) to a stream. Write the format_txpr rendering of txpr to os.

function FormatStablehlo

std::string FormatStablehlo(
    const txpr::Txpr & txpr
)

Parameters:

  • txpr The graph to format.
  • txpr IR graph to lower.

Return:

  • The StableHLO MLIR text.
  • Emitted StableHLO text.

Formats the lowered StableHLO MLIR text for a Txpr graph. Lower a Txpr graph to StableHLO MLIR text.

function DumpStablehlo

void DumpStablehlo(
    const txpr::Txpr & txpr,
    std::ostream & os =std::cout
)

Parameters:

  • txpr The graph to dump.
  • os The output stream.
  • txpr IR graph to lower.
  • os Output stream.

Writes format_stablehlo(txpr) to a stream. Write the StableHLO lowering of txpr to os.