File size: 2,302 Bytes
847619e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
name: Python tests

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

env:
  OMP_NUM_THREADS: 2
  MKL_NUM_THREADS: 2

jobs:
  test:
    name: Run tests on ${{ matrix.os }} with Python ${{ matrix.python }}
    strategy:
      matrix:
        os: [ubuntu-latest]
        python: ['3.10', '3.12']
        torch: [{base: '1.13.0', vision: '0.14.0'}, {base: '2.4.1', vision: '0.19.1'}]
        testmarker: ['-k "not test_models"', '-m base', '-m cfg', '-m torchscript', '-m features', '-m fxforward', '-m fxbackward']
        exclude:
          - python: '3.12'
            torch: {base: '1.13.0', vision: '0.14.0'}
    runs-on: ${{ matrix.os }}

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python }}
    - name: Install testing dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements-dev.txt
    - name: Install torch on mac
      if: startsWith(matrix.os, 'macOS')
      run: pip install --no-cache-dir torch==${{ matrix.torch.base }} torchvision==${{ matrix.torch.vision }}
    - name: Install torch on Windows
      if: startsWith(matrix.os, 'windows')
      run: pip install --no-cache-dir torch==${{ matrix.torch.base }} torchvision==${{ matrix.torch.vision }}
    - name: Install torch on ubuntu
      if: startsWith(matrix.os, 'ubuntu')
      run: |
        sudo sed -i 's/azure\.//' /etc/apt/sources.list
        sudo apt update
        sudo apt install -y google-perftools
        pip install --no-cache-dir torch==${{ matrix.torch.base }}+cpu torchvision==${{ matrix.torch.vision }}+cpu --index-url https://download.pytorch.org/whl/cpu
    - name: Install requirements
      run: |
        pip install -r requirements.txt
    - name: Run tests on Windows
      if: startsWith(matrix.os, 'windows')
      env:
        PYTHONDONTWRITEBYTECODE: 1
      run: |
        pytest -vv tests
    - name: Run '${{ matrix.testmarker }}' tests on Linux / Mac
      if: ${{ !startsWith(matrix.os, 'windows') }}
      env:
        LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libtcmalloc.so.4
        PYTHONDONTWRITEBYTECODE: 1
      run: |
        pytest -vv --forked --durations=0 ${{ matrix.testmarker }} tests