onnx-tensorflow
onnx-tensorflow copied to clipboard
When indices_shape is a tensor, cannot index it
https://github.com/onnx/onnx-tensorflow/blob/0874ca1378a8fe2d06e66f23323c3f828652e900/onnx_tf/handlers/backend/gather_and_scatter_mixin.py#L69 if tf_shape returns a tensor, indexing with indices_shape gives an error: https://github.com/onnx/onnx-tensorflow/blob/0874ca1378a8fe2d06e66f23323c3f828652e900/onnx_tf/handlers/backend/gather_and_scatter_mixin.py#L74
TypeError: slice indices must be integers or None or have an index method
It should work because the entire method is wrapped in tf.function. There is a test case in https://github.com/onnx/onnx-tensorflow/blob/0874ca1378a8fe2d06e66f23323c3f828652e900/test/backend/test_dynamic_shape.py#L336. It will produce indices_shape as a tensor and it works as expected.
If you continue to have the issue, please share your onnx file. Thanks.
It should work because the entire method is wrapped in tf.function. There is a test case in
https://github.com/onnx/onnx-tensorflow/blob/0874ca1378a8fe2d06e66f23323c3f828652e900/test/backend/test_dynamic_shape.py#L336
. It will produce indices_shape as a tensor and it works as expected. If you continue to have the issue, please share your onnx file. Thanks.
Sorry, it's not convenient for me to provide the onnx file due to some restrictions, but my data of gather_nd has static shape and my indices of gather_nd has dynamic shape. And sorry again I didn't mention I'm using branch v1.7.0, using tensorflow-1.15 which I now notice is not supported now. But I still think numpy.ndarray[tensor] will create an error. I tried the test_dynamic_shape.py by copying it from branch master, if I change https://github.com/onnx/onnx-tensorflow/blob/0874ca1378a8fe2d06e66f23323c3f828652e900/test/backend/test_dynamic_shape.py#L351 to [2, 3]), it throws the same error. So I think this should be irrelevant with which tf I use.