You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by Duke via Apache TVM Discuss <no...@discuss.tvm.ai> on 2021/07/29 11:45:08 UTC

[Apache TVM Discuss] [Questions] [Relay][Frontend] Why Transpose before GatherND


```
class GatherND(OnnxOpConverter):
    """Operator converter for GatherND."""

    @classmethod
    def _impl_common(cls, data, indices, batch_dims=0):
        indices_dims = len(infer_shape(indices))
        indices_shape = infer_shape(indices)
        indices = _op.transpose(indices, axes=[-1] + list(range(indices_dims - 1)))
        index_rank = indices_shape[-1]
        return _op.gather_nd(data, indices, batch_dims, index_rank)
```
## Observation
In `python/tvm/relay/onnx.py`, I found `_op.transpose()` was inserted before real `_op.gather_nd` operator. Actually, other OnnxOpConverters, like `ScatterND` have same or more relative insertions before the real ops. 

In test_cases however, `test_op_level3.py`, input data are fed into `relay.gather_nd` directly.

## Question
Is this `_op.transpose` necessary? What would happen to dataflow if we remove it?

Thanks!





---
[Visit Topic](https://discuss.tvm.apache.org/t/relay-frontend-why-transpose-before-gathernd/10657/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/be3c1b85c839320860ac34c565105b2929c59395495b54164f7bde0334e1661f).

[Apache TVM Discuss] [Questions] [Relay][Frontend] Why Transpose before GatherND

Posted by Chenfan via Apache TVM Discuss <no...@discuss.tvm.ai>.

The `nn.dense` & `nn.batch_matmul` have a same history I think. So recently I've added extra attrs to them to support the input tensor in transposed or non-transposed format.





---
[Visit Topic](https://discuss.tvm.apache.org/t/relay-frontend-why-transpose-before-gathernd/10657/3) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/0615b7e67b95175b6dc92bdfa51ead0a752b260f631f9f83120b5ffc5b68d366).

[Apache TVM Discuss] [Questions] [Relay][Frontend] Why Transpose before GatherND

Posted by masahi via Apache TVM Discuss <no...@discuss.tvm.ai>.

I remember this transpose is necessary since our op follows MXNet convention. `gather`, `gather_nd` in MXNet have different expectation on `indices` argument compared to other framework.





---
[Visit Topic](https://discuss.tvm.apache.org/t/relay-frontend-why-transpose-before-gathernd/10657/2) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/c28940e5ca6efabdf76509ce8f5ff0005510ff3f446a9c701b03f7639bfaf249).