Metadata-Version: 2.1
Name: torchlib-xpu
Version: 0.1.0
Summary: Intel® XPU Library for PyTorch* Ecosystem Projects
Author-email: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
License: BSD 3-Clause License
        
        Copyright (c) 2026 Intel Corporation. All Rights Reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: GitHub, https://github.com/intel/torchlib-xpu
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torchcodec-xpu
Provides-Extra: test
Requires-Dist: ruff ; extra == 'test'
Requires-Dist: torchcodec-xpu[test] ; extra == 'test'

[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/intel/torchlib-xpu/badge)](https://scorecard.dev/viewer/?uri=github.com/intel/torchlib-xpu)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/intel-torchlib-xpu/badge.svg)](https://scan.coverity.com/projects/intel-torchlib-xpu)

# Intel® XPU Library for PyTorch* Ecosystem Projects

This project contains a set of plugins for PyTorch* ecosystem libraries which enable hardware acceleration on Intel® GPUs thru the `xpu` PyTorch* device backend. The goal of the project is to:

* Facilitate enabling of the Intel® GPUs support across PyTorch* ecosystem projects
* Provide the plugins till the support for Intel® GPUs will be accepted in the respective upstream projects

At the moment project provides plugins for the following frameworks:

* Intel® XPU plugin for [TorchCodec]

## Plugins

### Intel® XPU plugin for TorchCodec

[TorchCodec] is a high-performance Python library designed for media processing (decoding and encoding) using PyTorch* tensors. Intel® XPU plugin for [TorchCodec] enables hardware acceleration for video operations (only decoding at the moment) on Linux. Both [TorchCodec] and Intel® plugin rely on the FFmpeg libraries for their operations which must be pre-installed on the system. Intel® plugin further assumes that FFmpeg is built with the VAAPI support.

To use Intel® XPU plugin for [TorchCodec], load it in the Python script and pass XPU device to initialize [TorchCodec] decoder or encoder:

```
import torchcodec
import torchcodec_xpu

decoder = torchcodec.decoders.VideoDecoder(
    "input.mp4", device="xpu:0")
```

## Build from sources

* Install [uv]

* Install oneAPI [2025.3]

* Install FFmpeg development environment with enabled VAAPI hardware acceleration. For example:

  * By installing FFmpeg provided by your Linux distribution. For Ubuntu:

```
apt-get update && apt-get install -y \
    libavcodec-dev \
    libavdevice-dev \
    libavfilter-dev \
    libavformat-dev \
    libavutil-dev \
    libswresample-dev \
    libswscale-dev
```

  * By self-building FFmpeg from sources:

```
git clone https://git.ffmpeg.org/ffmpeg.git && cd ffmpeg
./configure \
  --prefix=$HOME/_install \
  --libdir=$HOME/_install/lib \
  --disable-static \
  --disable-stripping \
  --disable-doc \
  --enable-shared \
  --enable-vaapi
make -j$(nproc) && make install

export PKG_CONFIG_PATH=$HOME/_install/lib/pkgconfig
export LD_LIBRARY_PATH=$HOME/_install/lib:$LD_LIBRARY_PATH
```

* Build and install plugins supplied by Intel® XPU Library for PyTorch* Ecosystem Projects:

```
git clone https://github.com/intel/torchlib-xpu.git && cd torchlib-xpu

uv venv && uv pip install torch -e . \
  --index https://download.pytorch.org/whl/xpu -vv
```

[Getting Started on Intel GPU]: https://docs.pytorch.org/docs/stable/notes/get_start_xpu.html
[TorchCodec]: https://github.com/meta-pytorch/torchcodec
[uv]: https://github.com/astral-sh/uv

[2025.3]: https://www.intel.com/content/www/us/en/developer/articles/tool/pytorch-prerequisites-for-intel-gpu/2-10.html
