dwavesystems / dwavesystems/dwave-optimization

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

Open
#442 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
31
Forks
36
Avg merge
16h 55m
Merged PRs (30d)
8

Description

Say you want to do
```python
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
```python
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`

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.