Fallbacks of ChainerX on GetItem fail when indices contains chainerx.ndarray
See original GitHub issueWhen chainerx with native
backend falls back to numpy:
>>> chainer.Variable(chainerx.zeros(3, device='native'))[numpy.arange(3)]
variable([0., 0., 0.])
>>> chainer.Variable(chainerx.zeros(3, device='native'))[chainerx.arange(3, device='native')]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/fujita/.local/share/virtualenvs/chainerrl_20180827-9TPAa4mI/lib/python3.5/site-packages/chainer/functions/array/get_item.py", line 143, in get_item
return GetItem(slices).apply((x,))[0]
File "/home/fujita/.local/share/virtualenvs/chainerrl_20180827-9TPAa4mI/lib/python3.5/site-packages/chainer/function_node.py", line 315, in apply
outputs = self.forward(in_data)
File "/home/fujita/.local/share/virtualenvs/chainerrl_20180827-9TPAa4mI/lib/python3.5/site-packages/chainer/functions/array/get_item.py", line 41, in forward
return utils.force_array(xs[0][self.slices]),
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
When chainerx with cuda:0
backend falls back to cupy:
>>> chainer.Variable(chainerx.zeros(3, device='cuda:0'))[cupy.arange(3)]
variable([0., 0., 0.])
>>> chainer.Variable(chainerx.zeros(3, device='cuda:0'))[chainerx.arange(3, device='cuda:0')]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/fujita/.local/share/virtualenvs/chainerrl_20180827-9TPAa4mI/lib/python3.5/site-packages/chainer/functions/array/get_item.py", line 143, in get_item
return GetItem(slices).apply((x,))[0]
File "/home/fujita/.local/share/virtualenvs/chainerrl_20180827-9TPAa4mI/lib/python3.5/site-packages/chainer/function_node.py", line 315, in apply
outputs = self.forward(in_data)
File "/home/fujita/.local/share/virtualenvs/chainerrl_20180827-9TPAa4mI/lib/python3.5/site-packages/chainer/functions/array/get_item.py", line 41, in forward
return utils.force_array(xs[0][self.slices]),
File "cupy/core/core.pyx", line 1650, in cupy.core.core.ndarray.__getitem__
File "cupy/core/core.pyx", line 3255, in cupy.core.core._simple_getitem
TypeError: Invalid index type: <class 'chainerx.ndarray'>
I want these to work so I can write numpy/cupy/chainerx-agnostic code.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
chainer/_fallback_workarounds.py at master · chainer/chainer · GitHub
This file defines workaround implementation for. # NumPy-compatibility functions that fall back to NumPy/CuPy functions.
Read more >ChainerX Tutorial — Chainer 7.8.1 documentation
Graph construction and backpropagation is built into the array, meaning that any function, including the NumPy-like functions, can be backpropagated through. In ...
Read more >Chainer Documentation - Read the Docs
It contains a sorted indices of the input variables w.r.t. which the gradients are ... held by the Variable object is not a...
Read more >Chainer and ChainerX - Nvidia
W2.array -= lr * W2.grad. Write forward prop as a plain Python script. Variables hold how they were computed. Use it to compute...
Read more >A flexible framework of neural networks for deep learning
import numpy as np import cupy import chainer import chainerx as chx ... of ChainerX on GetItem fail when indices contains chainerx.ndarray ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks https://github.com/chainer/chainer/pull/6769 contains the fallback fix for this issue.
Thank you so much for fixing the issue!