Intel NPU加速库使用样例
矩阵乘法
配置 Python 环境, 安装 git (用于从 huggingface 下载模型) 后, 运行项目提供的矩阵乘法示例代码:
from intel_npu_acceleration_library.backend import MatMul |
注意到运行程序时有如下提示:
UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. |
查阅资料知是由于新版setuptools弃用旧版语法导致, 卸载并重新安装 67.6.1 版本解决.
该程序计算了一个32×512矩阵和一个512×256矩阵相乘, 输出result.shape结果为
(32, 256) |
知输出结果正确, 代码可正常运行.