name: xpu

on:
  push:
    tags:
      - ciflow/xpu/*
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
  cancel-in-progress: true

jobs:

  get-label-type:
    if: github.repository_owner == 'pytorch'
    name: get-label-type
    uses: pytorch/pytorch/.github/workflows/_runner-determinator.yml@release/2.7
    with:
      triggering_actor: ${{ github.triggering_actor }}
      issue_owner: ${{ github.event.pull_request.user.login || github.event.issue.user.login }}
      curr_branch: ${{ github.head_ref || github.ref_name }}
      curr_ref_type: ${{ github.ref_type }}

  linux-jammy-xpu-2025_0-py3_9-build:
    name: linux-jammy-xpu-2025.0-py3.9
    uses: ./.github/workflows/_linux-build.yml
    needs: get-label-type
    with:
      sync-tag: linux-xpu-2025-0-build
      runner_prefix: ${{ needs.get-label-type.outputs.label-type }}
      build-environment: linux-jammy-xpu-2025.0-py3.9
      docker-image-name: pytorch-linux-jammy-xpu-2025.0-py3
      runner: linux.12xlarge
      test-matrix: |
        { include: [
          { config: "default", shard: 1, num_shards: 4, runner: "linux.idc.xpu" },
          { config: "default", shard: 2, num_shards: 4, runner: "linux.idc.xpu" },
          { config: "default", shard: 3, num_shards: 4, runner: "linux.idc.xpu" },
          { config: "default", shard: 4, num_shards: 4, runner: "linux.idc.xpu" },
        ]}
    secrets: inherit

  linux-jammy-xpu-2025_0-py3_9-test:
    name: linux-jammy-xpu-2025.0-py3.9
    uses: ./.github/workflows/_xpu-test.yml
    needs: linux-jammy-xpu-2025_0-py3_9-build
    permissions:
      id-token: write
      contents: read
    with:
      build-environment: linux-jammy-xpu-2025.0-py3.9
      docker-image: ${{ needs.linux-jammy-xpu-2025_0-py3_9-build.outputs.docker-image }}
      test-matrix: ${{ needs.linux-jammy-xpu-2025_0-py3_9-build.outputs.test-matrix }}
    secrets: inherit

  windows-xpu-2025_0-build:
    if: github.repository_owner == 'pytorch'
    name: win-vs2022-xpu-2025_0-py3
    uses: ./.github/workflows/_win-build.yml
    with:
      build-environment: win-vs2022-xpu-py3
      cuda-version: cpu
      use-xpu: true
      xpu-version: '2025.0'
      vc-year: '2022'
    secrets: inherit
