Aharrypotter commented on PR #19814:
URL: https://github.com/apache/tvm/pull/19814#issuecomment-4764397763
> I think `REVERSE_SEQUENCE` needs one more change before merge.
>
> The new lowering emits `R.call_dps_packed("topi.reverse_sequence", ...)`
at `python/tvm/relax/frontend/tflite/tflite_frontend.py:5023`. However, the
registered `topi.reverse_sequence` packed function in `src/topi/transform.cc`
is a TOPI/TE compute wrapper that casts the first two arguments to
`te::Tensor`. `call_dps_packed` invokes the symbol at runtime with runtime
tensors, so the imported model fails when compiled and executed.
>
> I reproduced this with the new hand-built `REVERSE_SEQUENCE` model: the
structural test passes, but running the compiled module fails with:
>
> ```
> TypeError: Cannot convert from type ``ffi.Tensor`` to ``te.Tensor``
> ```
>
> Could we either lower this through a real TIR path, e.g.
`BlockBuilder.emit_te(topi.reverse_sequence, ...)`, or provide a proper runtime
DPS packed implementation? It would also be good to add a runtime regression
test for `REVERSE_SEQUENCE`, since the current test only checks the generated
IR shape.
Good catch, thanks @tlopex. Instead of patching the packed path, I
registered `REVERSE_SEQUENCE` as a proper Relax op (`relax.reverse_sequence`)
that legalizes through `bb.call_te(topi.reverse_sequence, ...)`, so it lowers
to real TIR at compile time and the `ffi.Tensor → te.Tensor` issue is gone.
This also let me drop the old `batch_dim != 0` restriction, since the op now
carries both `seq_axis` and `batch_axis`.
I also added a runtime test: `test_reverse_sequence` now compiles and runs
the module on the VM and checks the output against NumPy, plus unit tests for
the op and its legalization. PTAL.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]