[Bug] InferLayoutStack does not handle negative axis

Abierto
#20,902 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp, python
Área
compilers

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.script import ir as I
from tvm.script import relax 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)
Lenguaje dominante
Python
Estrellas
13.9k
Forks
4k
Merge medio
8 h 2 min
PR fusionados (30 d)
180

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/tvm

Todos los issues de apache/tvm

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.