[Bug] InferLayoutStack does not handle negative axis

Aperta
#20,902 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp, python
Ambito
compilers

Direzione di ricerca

Start at src/relax/op/tensor/manipulate.cc around line 1787, where InferLayoutStack handles the axis, and reproduce the failure with the provided R.stack(..., axis=-1) example followed by ConvertLayout({}). Trace how the axis is validated and used to insert into layout_str; done means this negative-axis case no longer crashes and the relevant tests pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

needs-triage type: bug

https://github.com/apache/tvm/blob/main/src/relax/op/tensor/manipulate.cc#L1787 trys to convert axis to size_t and insert a character at such position to layout_str. However as described by https://tvm.apache.org/docs/reference/api/python/relax/op.html#tvm.relax.op.stack, the axis can be negative. Program will crash if the axis is negative.

C++ does check whether the position is valid, and throws errors like tvm.error.InternalError: basic_string::replace: __pos (which is 18446744073709551615) > this->size() (which is 2)

Steps to reproduce
from tvm_tirx.script import ir as I
from tvm.relax import script as R

@I.ir_module
class Module:
    @R.function
    def main(inp_0: R.Tensor((2, 3), dtype="float32")) -> R.Tuple(R.Tensor((2, 3, 2), dtype="float32")):
        with R.dataflow():
            lv: R.Tensor((2, 3, 2), dtype="float32") = R.stack((inp_0, inp_0), axis=-1)
            gv: R.Tuple(R.Tensor((2, 3, 2), dtype="float32")) = (lv,)
            R.output(gv)
        return gv

import tvm
tvm.relax.transform.ConvertLayout({})(Module)

(If using released version of tvm, you should change the first two lines to from tvm.script import ir as I and from tvm.script import relax as R)

Lingua principale
Python
Stelle
13.9k
Fork
4k
Merge medio
8h 5m
PR unite (30g)
170

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/tvm

Tutte le issue di apache/tvm

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.