s2t.Prensor

May 7, 2026 ยท View on GitHub

description: A expression of NodeTensor objects.

s2t.Prensor

A expression of NodeTensor objects.

`node` the NodeTensor of the root.
`children` a map from edge to subexpression.
`is_leaf` True iff the node value is a LeafNodeTensor.
`node` The node of the root of the subtree.

Methods

field_names

View source

Returns the field names of the children.

get_child

View source

Gets the child at field_name.

get_child_or_error

View source

Gets the child at field_name.

get_children

View source

A map from field name to subexpression.

get_descendant

View source

Finds the descendant at the path.

get_descendant_or_error

View source

Finds the descendant at the path.

get_descendants

View source

A map from paths to all subexpressions.

get_ragged_tensor

View source

Get a ragged tensor for a path.

All steps are represented in the ragged tensor.

Args
`p` the path to a leaf node in `t`.
`options` Options for calculating ragged tensors.
Returns
A ragged tensor containing values of the leaf node, preserving the structure along the path. Raises an error if the path is not found.

get_ragged_tensors

View source

Gets ragged tensors for all the leaves of the prensor expression.

Args
`options` Options for calculating ragged tensors.
Returns
A map from paths to ragged tensors.

get_sparse_tensor

View source

Gets a sparse tensor for path p.

Note that any optional fields are not registered as dimensions, as they can't be represented in a sparse tensor.

Args
`p` The path to a leaf node in `t`.
`options` Currently unused.
Returns
A sparse tensor containing values of the leaf node, preserving the structure along the path. Raises an error if the path is not found.

get_sparse_tensors

View source

Gets sparse tensors for all the leaves of the prensor expression.

Args
`options` Currently unused.
Returns
A map from paths to sparse tensors.