# pr-tools **Repository Path**: aimerick/pr-tools ## Basic Information - **Project Name**: pr-tools - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-01-04 - **Last Updated**: 2026-01-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # pr-tools PyTorch 扩展库,提供 PR 核心算法实现。 ## 安装 ### 前置要求 - Python >= 3.8 - PyTorch >= 1.10 - CUDA >= 11.0 - nvcc 编译器 ### 从源码安装 ```bash git clone cd pr-tools pip install -e . ``` ## 功能 ### pr 精度救援操作,用于数值量化。 **参数:** - `src` (`torch.Tensor`): 待处理的源张量,应为 2D 张量 - `mbit` (`int`): 尾数位宽 - `swsf` (`int`): 额外指数范围的偏置 - `expth` (`torch.Tensor`, 可选): 指数阈值,默认为全 True **示例:** ```python import torch from pr_tools import pr src = torch.randn(100, 256, dtype=torch.float32).cuda() expth = torch.ones_like(src, dtype=torch.bool).cuda() swsf = torch.tensor([1], dtype=torch.int8).cuda() result = pr(src, mbit=8, swsf=swsf, expth=expth) ``` ## 项目结构 ``` pr-tools/ ├── src/ │ ├── pr_tools/ # Python 包 │ │ ├── __init__.py │ │ ├── _C/ # C++ 扩展绑定 │ │ └── ops/ # Python 操作接口 │ └── extensions/ # CUDA/C++ 源码 │ ├── ops.h │ ├── pybind.cpp │ └── *.cu # CUDA 内核 ├── setup.py └── README.md ``` ## 开发 ### 构建扩展 ```bash python setup.py build_ext --inplace ``` ### 清理构建文件 ```bash python setup.py clean ``` ## 许可证 MIT License