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

Đang mở
#537 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python, pytorch
Lĩnh vực
testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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))

Ngôn ngữ chính
Python
Star
2.1k
Fork
256
Merge trung bình
6 ngày 10 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pytest-dev/pytest-cov

Tất cả issue của pytest-dev/pytest-cov

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.