火炬延伸 这是PyTorch的CUDA扩展的示例,该扩展使用CuPy计算两个张量的Hadamard乘积。 有关也使用CuPy的更高级的PyTorch扩展,请参阅: : 设置 确保安装CuPy,这可以使用pip install cupy或使用CuPy信息库中概述的提供的之一来完成。 用法 无需单独的构建过程,只需运行python run.py进行测试。 下面还显示了如何使用示例扩展的最小示例。 import torch import hadamard class Network ( torch . nn . Module ): def __init__ ( self ): super ( Network , self ). __init__ () # end def forward ( self , input1 , input2 ): return hadamard
2022-02-16 18:46:40 15KB python deep-learning cuda pytorch
1
主要介绍了pytorch中使用cuda扩展的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
2022-02-16 18:46:16 45KB pytorch cuda扩展 pytorch cuda
1