Skip to content

Advanced(Inc)Subtensor text representation #1906

@ricardoV94

Description

@ricardoV94

Description

After #1756 Advanced and IncSubtensor take idx_list (just like Subtensor did). It would be nice to use the same string representation we used for Subtensor to make dprint more readable.

import pytensor.tensor as pt

x = pt.zeros((2, 3, 4, 5))

basic_sub = x[0, :, :1, 1]
basic_sub.dprint()
# Subtensor{i, :, :stop, j} [id A]
#  ├─ Alloc [id B]
#  │  ├─ 0.0 [id C]
#  │  ├─ 2 [id D]
#  │  ├─ 3 [id E]
#  │  ├─ 4 [id F]
#  │  └─ 5 [id G]
#  ├─ 0 [id H]
#  ├─ 1 [id I]
#  └─ 1 [id J]

adv_sub = x[[0], :, :1, 1]
adv_sub.dprint()
# AdvancedSubtensor{idx_list=(0, slice(None, None, None), slice(None, 1, None), 2)} [id A]
#  ├─ Alloc [id B]
#  │  ├─ 0.0 [id C]
#  │  ├─ 2 [id D]
#  │  ├─ 3 [id E]
#  │  ├─ 4 [id F]
#  │  └─ 5 [id G]
#  ├─ [0] [id H]
#  ├─ TensorFromScalar [id I]
#  │  └─ 1 [id J]
#  └─ TensorFromScalar [id K]
#     └─ 1 [id L]

(We should also check what's going on with those TensorFromScalar in AdvancedSubtensor...)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions