Skip to content

Consider changing BroadcastTo to allow its shape to be derived from another symbol #442

@arcondello

Description

@arcondello

Say you want to do

x = model.set(5).reshape(-1, 1)
y = model.constant(np.arange(3).reshape(1, 3))
z = x + y

this should be valid because the resulting z should have shape (-1, 3). But unfortunately our current BinaryOp implementation does not support non-scalar broadcasting and our BroadcastTo symbol does not support getting the desired shape from another symbol.

We should change the latter. Something like

xb = broadcast_to(x, shape=(-1, 3))  # we can do this now
yb = broadcast_to(y, shape=x)  # this saying `yb` should have the shape that would result from broadcasting `y` and `x`

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions