pytorch subclass of torch.autograd.Function's backward can be traced by pytest-cov

Abierto
#537 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
python, pytorch
Área
testing

Línea de trabajo

Reproduce the example using the pytest=7.1.2 and pytest-cov=3.0.0 versions, with the configuration in setup.cfg and the Test.backward entry point. Compare the execution log with the coverage report to determine why backward is omitted, then document or correct the behavior and verify that the report reflects the executed function.

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

Descripción

Summary

According to the log, the backward function in subclass of torch.autograd.Function has been executed. but pytest-cov reports this function is missing.
image

please help me check this problem, why it happened. Thank you very much.

Versions

pytest=7.1.2
pytest-cov=3.0.0

Config

setup.cfg

# pytest-cov config
[coverage:run]
branch = True
omit =
    # exclude some file that should not be tested
    */test_*.py
    */*_test.py

[coverage:report]
# result precision
precision = 2
exclude_lines =
    # Don't complain about missing debug-only code:
    if __name__ == .__main__.:
 
[coverage:html]
# report output dir
directory = ./tests/report/cov

Code


class Test(torch.autograd.Function):
    @staticmethod
    def forward(ctx, x):
         return x
    @staticmethod
    def backward(ctx,grad_out):
       return grad_out

test = Test.apply
input = torch.randn(2,3)
output = test(input)

output.backward(torch.ones_like(output))

Lenguaje dominante
Python
Estrellas
2.1k
Forks
256
Merge medio
6 d 10 min
PR fusionados (30 d)
2

Preparar el entorno

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 pytest-dev/pytest-cov

Todos los issues de pytest-dev/pytest-cov

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.