Module Ocannl_tensor.PrintBox_utils

PrintBox helpers shared by tensor printing, the tutorials and the benchmarks: the dag pre-layout that Tensor.print renders, a wrapper over printbox-ext-plot plots, and the benchmark comparison table. The module exports what those callers use; the sexp converters behind the layout types had no caller and are not derived (gh-ocannl-915).

type box = PrintBox.t
type dag = [
  1. | `Empty
  2. | `Pad of dag
  3. | `Frame of dag
  4. | `Align of [ `Left | `Center | `Right ] * [ `Top | `Center | `Bottom ] * dag
  5. | `Text of string
  6. | `Box of box
  7. | `Vlist of bool * dag list
  8. | `Hlist of bool * dag list
  9. | `Table of dag array array
  10. | `Tree of dag * dag list
  11. | `Embed_subtree_ID of string
  12. | `Subtree_with_ID of string * dag
]

A tree-shaped layout that boxify flattens level by level before dag_to_box renders it. A `Subtree_with_ID marks a subtree that an `Embed_subtree_ID elsewhere refers back to; the identifier is shown only where the reference exists.

val boxify : int -> dag -> dag

boxify depth b rewrites the outermost depth levels of `Tree nodes into vertical lists of the node over a horizontal list of its children.

val dag_to_box : dag -> PrintBox.t

Renders a dag into a box, resolving subtree references by identifier.

val reformat_dag : int -> dag -> PrintBox.t

reformat_dag depth b is boxify depth b |> dag_to_box.

val plot : ?as_canvas:bool -> ?x_label:string -> ?y_label:string -> ?axes:bool -> ?size:(int * int) -> ?small:bool -> PrintBox_ext_plot.plot_spec list -> PrintBox.t

A plot box over printbox-ext-plot's defaults. ~as_canvas drops the labels and axes; ~small quarters the size in both directions.

type table_row_spec =
  1. | Benchmark of {
    1. bench_title : string;
    2. time_in_sec : float;
    3. mem_in_bytes : int;
    4. result_label : string;
    5. result : Base.Sexp.t;
    }
val table : table_row_spec list -> PrintBox.t

Groups the rows by result_label, preserving first-seen label order, and renders each group with speedup and memory-gain columns relative to the group's slowest and largest rows.