A PyTorch adapter running on MindSpore
Project description
torch-ms-adapter
torch-ms-adapter 是一个在 MindSpore 上模拟 PyTorch API 的适配器库。
目标是让你几乎无需修改 PyTorch 代码,就能在 MindSpore 上运行。
特性
- 支持 nn.Module, Conv2d, Linear, ReLU, CrossEntropyLoss
- 封装了 DataLoader 和 Trainer(底层使用 MindSpore)
- 提供 torch.nn.functional 基本操作
- 自动屏蔽 PyTorch,兼容原始导入语句
安装
pip install torch-ms-adapter
使用示例
import torch_ms_adapter as torch
import torch_ms_adapter.nn as nn
import torch_ms_adapter.functional as F
class LeNet5(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(1, 6, 5)
self.fc1 = nn.Linear(16*4*4, 120)
self.fc2 = nn.Linear(120, 10)
def forward(self, x):
x = F.relu(self.conv1(x))
x = torch.flatten(x, 1)
x = self.fc2(F.relu(self.fc1(x)))
return x
运行方式与pytorch一致,只需替换
import torch
为
import torch_ms_adapter as torch
路线图
- 支持基础层(linear,Conv2d,ReLU)
- 支持Loss函数
- 封装Optimizer
- 支持更多PyTorch模块(YOLO,ResNet)
- 完善Autograd
贡献
欢迎提交issue和PR,一起完善torch-ms-adopter
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file torch_ms_adapter-0.1.4.tar.gz.
File metadata
- Download URL: torch_ms_adapter-0.1.4.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b29c9e82c3e3ce8881f06f22a0cca08e674345bffa7186894bb97c40f981ad5b
|
|
| MD5 |
73b4cbff2c19659d6b9773cc379bb567
|
|
| BLAKE2b-256 |
4a0f687071bc9be06362e936bedd9c559c7fdef277b9c3eda098dc7373060cd3
|
File details
Details for the file torch_ms_adapter-0.1.4-py3-none-any.whl.
File metadata
- Download URL: torch_ms_adapter-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bb086157f02156a22025282853005b591dbbe02b4ac6cdbcf8c35019d5ac2aa
|
|
| MD5 |
03a8d2b66b618f212ed2ce7239bf03b4
|
|
| BLAKE2b-256 |
fbca7bddfa9a316d678563beaef421b043148d5e4a6b193d18cff3d615fdf799
|