Skip to main content
Introduction
=============
MindTorch is MindSpore tool for adapting the PyTorch interface, which is designed to make PyTorch code perform efficiently on Ascend without changing the habits of the original PyTorch users.

|MindTorch-architecture|

Install
=======

MindTorch has some prerequisites that need to be installed first, including MindSpore, PIL, NumPy.

.. code:: bash

# for last stable version
pip install mindtorch

# for latest release candidate
pip install --upgrade --pre mindtorch

Alternatively, you can install the latest or development version by directly pulling from OpenI:

.. code:: bash

pip3 install git+https://openi.pcl.ac.cn/OpenI/MSAdapter.git

User guide
===========
You can start using it straight away, for example:

Import mstorch_enable in the main program of the code file to adapt PyTorch code to MindTorch

.. code:: python

from mindtorch.tools import mstorch_enable # It needs to be used before importing torch related modules in the main program

import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision import datasets, transforms

class LeNet(nn.Module):
def __init__(self):
super(LeNet, self).__init__()
self.conv1 = nn.Conv2d(3, 16, 5)
self.pool1 = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(16, 32, 5)
self.pool2 = nn.MaxPool2d(2, 2)
self.fc1 = nn.Linear(32*5*5, 120)
self.fc2 = nn.Linear(120, 84)
self.fc3 = nn.Linear(84, 10)

def forward(self, x):
x = F.relu(self.conv1(x))
x = self.pool1(x)
x = F.relu(self.conv2(x))
x = self.pool2(x)
x = x.view(-1, 32*5*5)
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x

criterion = nn.CrossEntropyLoss()

transform = transforms.Compose(
[transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])

train_set = datasets.CIFAR10(root='./data', train=True, download=True, transform=transform)
train_data = DataLoader(train_set, batch_size=128, shuffle=True, num_workers=2, drop_last=True)

After importing mstorch_enable, the imported module with the same name of torch will be automatically converted to the corresponding module of mindtorch when the code is executed (currently supports automatic conversion of torch, torchvision, torchaudio related modules), and then execute the .py file of the main program. For more information on how to use it, please refer to User's Guide.


License
=======

MindTorch is released under the Apache 2.0 license.

.. |MindTorch-architecture| image:: https://openi.pcl.ac.cn/OpenI/MSAdapter/raw/branch/master/doc/readthedocs/source_zh/docs/pic/MSA_F.png

Metadata

Release files for mindtorch 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for mindtorch 0.4.0
File Interpreter ABI Platform Actions
mindtorch-0.4.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for mindtorch-0.4.0-py2.py3-none-any.whl

Release files / mindtorch-0.4.0-py2.py3-none-any.whl

Download URL mindtorch-0.4.0-py2.py3-none-any.whl
Size 1.4 MB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
99fb74d6b646d1858a9c3369858f232e4e861e44ea3e7709ab8f7a1436b39dba
BLAKE2b-256 checksum
How to use checksums
4c8a67bb218d50898f3a5ec8cc4fc3140c6de463c358b986b4519c92d810ec77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.18

Security for mindtorch 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page