Skip to main content

A PyTorch adapter running on MindSpore

Project description

torch-ms-adapter

PyPI version Python License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torch_ms_adapter-0.1.3.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torch_ms_adapter-0.1.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file torch_ms_adapter-0.1.3.tar.gz.

File metadata

  • Download URL: torch_ms_adapter-0.1.3.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

Hashes for torch_ms_adapter-0.1.3.tar.gz
Algorithm Hash digest
SHA256 26f33223890e64b6454a54872d1cd19a931c3fd165a2b08bb1a1985eed4779f8
MD5 3e7abe32de4ee32446977a07a35806d1
BLAKE2b-256 edee0ea0ec0d5c5c4582371525df34e67cafd898ae95db771ceccabb66f021f6

See more details on using hashes here.

File details

Details for the file torch_ms_adapter-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for torch_ms_adapter-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 eaac5000095c3ec6c57d2b172efda4420f5289f565aacccd72b24206502db5ec
MD5 b27dd919409c984dd1519241d7764c58
BLAKE2b-256 757716f907090b0a620f130660e8c336cbb4624e69f57c86a445d201c9dd8339

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page