tvm_tirx.tirx.structural.structural_map_with_constraint_context

tvm_tirx.tirx.structural.structural_map_with_constraint_context#

tvm_tirx.tirx.structural.structural_map_with_constraint_context(root, callback, *, order='post')#

Structurally map a value with its active symbolic facts.

The callback returns the unchanged input or a replacement value and must not mutate its input in place. Callbacks run at each occurrence with the same intermediate-array exception as walk. A graph rewrite that must preserve sharing keeps its own callback memo.

Parameters:
  • root (Any) – Root value to transform. A regular Python reference is preserved through copy-on-write.

  • callback (callable) – Called as callback(value, constraints) with the active tvm_tirx.sym.ConstraintContext (do not append during traversal). Return the value to preserve it or a replacement; do not modify the callback’s input in place.

  • order ({"post", "pre"}, optional) – Transform children before invoking the callback (the default), or invoke the callback first and traverse its returned value’s children.

Returns:

result (Any) – The transformed root value.

Raises:

ValueError – If order is neither "pre" nor "post".