File: action.yml

package info (click to toggle)
elastix 5.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 45,644 kB
  • sloc: cpp: 85,720; lisp: 4,118; python: 1,045; sh: 200; xml: 182; makefile: 33
file content (110 lines) | stat: -rw-r--r-- 3,556 bytes parent folder | download
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Build libtorch
description: "Build LibTorch from source with cache (CPU by default)"
inputs:
  pytorch_repo:
    description: "PyTorch repo URL"
    default: "https://github.com/pytorch/pytorch.git"
    required: false
  pytorch_ref:
    description: "Git ref (branch, tag, or commit SHA)"
    default: "v2.8.0"
    required: false
  install_prefix:
    description: "CMAKE_INSTALL_PREFIX for LibTorch"
    default: ${{ github.workspace }}/libtorch-install
    required: false
  build_dir:
    description: "Out-of-source build directory"
    default: ${{ runner.temp }}/libtorch-build
    required: false
  build_type:
    description: "CMAKE_BUILD_TYPE"
    default: "Release"
    required: false
  use_cuda:
    description: "Enable CUDA build (ON/OFF)"
    default: "OFF"
    required: false
  use_mps:
    description: "Enable MPS (Apple) build (ON/OFF)"
    default: "OFF"
    required: false
  extra_cmake_flags:
    description: "Extra CMake flags"
    default: ""
    required: false
  python_version:
    description: "Python version to setup"
    default: "3.11"
    required: false

outputs:
  install_prefix:
    description: "Where LibTorch was installed"
    value: ${{ inputs.install_prefix }}

runs:
  using: "composite"
  steps:
    - name: Cache libtorch install
      id: cache-libtorch
      uses: actions/cache@v4
      with:
        path: ${{ inputs.install_prefix }}
        key: libtorch-install-${{ runner.os }}-${{ inputs.pytorch_ref }}-${{ inputs.build_type }}-cuda${{ inputs.use_cuda }}-mps${{ inputs.use_mps }}

    - name: Setup Python
      if: ${{ steps['cache-libtorch'].outputs['cache-hit'] != 'true' }}
      uses: actions/setup-python@v5
      with:
        python-version: ${{ inputs.python_version }}

    - name: Install Python tooling
      if: ${{ steps['cache-libtorch'].outputs['cache-hit'] != 'true' }}
      shell: bash
      run: |
        python -m pip install --upgrade pip
        python -m pip install ninja

    - name: Clone PyTorch
      if: ${{ steps['cache-libtorch'].outputs['cache-hit'] != 'true' }}
      shell: bash
      run: |
        git clone ${{ inputs.pytorch_repo }} "${{ github.workspace }}/pytorch"
        cd "${{ github.workspace }}/pytorch"
        git checkout --recurse-submodules ${{ inputs.pytorch_ref }}
        git submodule sync --recursive
        git submodule update --init --recursive

    - name: Install PyTorch requirements (build only)
      if: ${{ steps['cache-libtorch'].outputs['cache-hit'] != 'true' }}
      shell: bash
      working-directory: ${{ github.workspace }}/pytorch
      run: |
        python -m pip install -r requirements.txt


    - name: Configure (CMake)
      if: ${{ steps['cache-libtorch'].outputs['cache-hit'] != 'true' }}
      shell: bash
      run: |
        cmake -S "${{ github.workspace }}/pytorch" \
              -B "${{ inputs.build_dir }}" \
              -G Ninja \
              -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} \
              -DCMAKE_INSTALL_PREFIX="${{ inputs.install_prefix }}" \
              -DBUILD_PYTHON=OFF \
              -DBUILD_TEST=OFF \
              -DUSE_CUDA=${{ inputs.use_cuda }} \
              -DUSE_MPS=${{ inputs.use_mps }} \
              -DUSE_MKLDNN=OFF \
              -DUSE_QNNPACK=OFF \
              -DUSE_XNNPACK=OFF \
              -DUSE_FBGEMM=OFF \
              ${{ inputs.extra_cmake_flags }}

    - name: Build & Install
      if: ${{ steps['cache-libtorch'].outputs['cache-hit'] != 'true' }}
      shell: bash
      run: |
        ninja -C "${{ inputs.build_dir }}" install