Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Gather" operator not implemented yet error #926

Open
Wardo82 opened this issue Aug 13, 2019 · 2 comments
Open

"Gather" operator not implemented yet error #926

Wardo82 opened this issue Aug 13, 2019 · 2 comments

Comments

@Wardo82
Copy link

Wardo82 commented Aug 13, 2019

Looking at the source i have this problem constantly showing up. I want to export a model from pytorch.

raise NotImplementedError("[ONNXConverter] Operator "Gather" is not supported yet.")

@milhidaka
Copy link
Member

As the error message says, the needed operator is not implemented now.
You can implement it by referencing other operator's implementation.

@Wardo82
Copy link
Author

Wardo82 commented Aug 13, 2019

Hi, thanks for the quick reply! Looking at the docs i found

`node = onnx.helper.make_node(
'Gather',
inputs=['data', 'indices'],
outputs=['y'],
axis=1,
)
data = np.random.randn(5, 4, 3, 2).astype(np.float32)
indices = np.array([0, 1, 3])
y = np.take(data, indices, axis=1)

expect(node, inputs=[data, indices.astype(np.int64)], outputs=[y],
name='test_gather_1')`

and came up with

`
@ONNXConverter.register_handler("Gather")
def _convert_gather(converter: ONNXConverter, onnx_op: INodeProto):
x = converter.get_variable(onnx_op.input[0])
indices = converter.get_variable(onnx_op.input[1])
axis = onnx_op.attribute[0].i

new_data = x.data.copy().astype(np.float32)
new_indices = indices.data.copy().astype(np.int64)
y = np.take(new_data, new_indices , axis=axis)

y = ConstantVariable(y, Order(y.shape))
converter.set_variable(onnx_op.output[0], y) `

what do you think? I now get dimensionalities error:
ValueError:
Unification failed: Number of dimension mismatch
(self.ndim) = 2
(other.ndim) = 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants