about summary refs log tree commit diff
path: root/pkgs/development/python-modules/torchinfo/default.nix
blob: 59b7e99c9dfca93ffa987d253e73f7da260c9bff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{ lib
, buildPythonPackage
, fetchFromGitHub
, fetchpatch
, pythonOlder
, torch
, torchvision
, pytestCheckHook
, transformers
}:

buildPythonPackage rec {
  pname = "torchinfo";
  version = "1.8.0";
  format = "setuptools";

  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "TylerYep";
    repo = "torchinfo";
    rev = "refs/tags/v${version}";
    hash = "sha256-pPjg498aT8y4b4tqIzNxxKyobZX01u+66ScS/mee51Q=";
  };

  patches = [
    (fetchpatch {  # Add support for Python 3.11 and pytorch 2.1
      url = "https://github.com/TylerYep/torchinfo/commit/c74784c71c84e62bcf56664653b7f28d72a2ee0d.patch";
      hash = "sha256-xSSqs0tuFpdMXUsoVv4sZLCeVnkK6pDDhX/Eobvn5mw=";
      includes = [
        "torchinfo/model_statistics.py"
      ];
    })
  ];

  propagatedBuildInputs = [
    torch
    torchvision
  ];

  nativeCheckInputs = [
    pytestCheckHook
    transformers
  ];

  preCheck = ''
    export HOME=$(mktemp -d)
  '';

  disabledTests = [
    # Skip as it downloads pretrained weights (require network access)
    "test_eval_order_doesnt_matter"
    "test_flan_t5_small"
    # AssertionError in output
    "test_google"
    # "addmm_impl_cpu_" not implemented for 'Half'
    "test_input_size_half_precision"
  ];

  disabledTestPaths = [
    # Test requires network access
    "tests/torchinfo_xl_test.py"
  ];

  pythonImportsCheck = [
    "torchinfo"
  ];

  meta = with lib; {
    description = "API to visualize pytorch models";
    homepage = "https://github.com/TylerYep/torchinfo";
    license = licenses.mit;
    maintainers = with maintainers; [ petterstorvik ];
  };
}