Skip to content

Commit

Permalink
Xが4D、Yが2D、axisが0の場合に対応
Browse files Browse the repository at this point in the history
  • Loading branch information
Masato Hori committed Apr 23, 2018
1 parent 98e01e5 commit 94e7037
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python/test/function/test_broadcast_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def ref_broadcast_to(x, y, axis):
return np.broadcast_to(t, x.shape)
elif ys == 2:
if axis == 0:
pass
t = y[:, :, np.newaxis, np.newaxis]
return np.broadcast_to(t, x.shape)
elif axis == 1:
t = y[np.newaxis, :, :, np.newaxis]
return np.broadcast_to(t, x.shape)
Expand All @@ -87,6 +88,7 @@ def ref_broadcast_to(x, y, axis):
((2, 3, 4, 5), (3), 1),
((2, 3, 4, 5), (4), 2),
((2, 3, 4, 5), (5), 3),
((2, 3, 4, 5), (2, 3), 0),
((2, 3, 4, 5), (3, 4), 1),
((2, 3, 4, 5), (4, 5), 2),
#((2, 3, 4, 5), (2, 3, 4), 0),
Expand Down
4 changes: 4 additions & 0 deletions src/nbla/function/broadcast_to.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ void BroadcastTo<T>::forward_impl(const Variables &inputs, const Variables &outp
switch(axis_) {
case 0:
// X: (2,3,4,5) Y: (2,3) axis=0
copy_buf_vertically_to_block(
z, y,
xs[0], ys[1],
xs[1], xs[2]*xs[3]);
break;
case 1:
{
Expand Down

0 comments on commit 94e7037

Please sign in to comment.