Thanks to visit codestin.com
Credit goes to github.com

Skip to content

add mindspore support#193

Closed
lvyufeng wants to merge 2 commits into
arogozhnikov:masterfrom
lvyufeng:master
Closed

add mindspore support#193
lvyufeng wants to merge 2 commits into
arogozhnikov:masterfrom
lvyufeng:master

Conversation

@lvyufeng
Copy link
Copy Markdown

@lvyufeng lvyufeng commented Jun 22, 2022

Add mindspore deep learning framework support.

@lvyufeng
Copy link
Copy Markdown
Author

lvyufeng commented Jul 6, 2022

@arogozhnikov hello sir, I have committed a merge request for adding a new backend named MindSpore, which is a new DL framework. Would please review this pr and give some comments or merge it if no problems?

@arogozhnikov
Copy link
Copy Markdown
Owner

Hi @lvyufeng

thanks for a well-organized PR. Github CI does not have cuda, so effectively tests were turned off in your branch.

I've modified it to include tests (but skip einsum) and run on linux. Result is:

  • ops are working
  • but layers are failing with quite a strange error,

you can see error here in the log: https://github.com/arogozhnikov/einops/runs/7266742212?check_suite_focus=true

here is the branch that includes your code and my change to turn tests on: https://github.com/arogozhnikov/einops/tree/mindspore-show-issue

@lvyufeng
Copy link
Copy Markdown
Author

lvyufeng commented Jul 27, 2022

It looks like a bug on CPU platform, I will check it and try to fix it. BTW, I remember the mindspore-gpu package i used was a development version, which is a daily compiled package, maybe the bug had beed fixed in MindSpore 1.8(which is released at July 26).

@lvyufeng
Copy link
Copy Markdown
Author

lvyufeng commented Sep 5, 2022

it seems that only Pynative mode works well, you should add the following code snippet:

from mindspore import context
context.set_context(mode=context.PYNATIVE_MODE)

BTW, mindspore will set Pynative mode as the default running mode since 1.9.0.

@lvyufeng
Copy link
Copy Markdown
Author

lvyufeng commented Sep 5, 2022

the error has been fixed.

@lvyufeng
Copy link
Copy Markdown
Author

@arogozhnikov the error has been fixed, would you please review the code and merge it?

Comment thread einops/_backends.py
def __init__(self):
super().__init__()
import mindspore as ms
ms.set_context(mode=ms.PYNATIVE_MODE)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use GRAPH_MODE right now ? it seems the very important identity feature in MindSpore.
Thoes who use MindSpore would like to try the jit accelerator.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some pythonic code style or specific grammar is not supported on GRAPH_MODE, like try...except, so I have to change the default mode to PYNATIVE. BTW, MindSpore plans to set PYNATIVE mode to support flexible writing, and partial accelerating can use mindspore.ms_function.

here is a simple case:

from mindspore import ms_function
from mindspore import nn
class TestNet(nn.Cell):
    def __init__():
        super().__init__():
        self.net = nn.Dense(30, 40)
  
    @ms_function
    def construct(self, x)
        return self.net(x)

@jiangxiluning
Copy link
Copy Markdown

This feature hasn't been merged yet?

@arogozhnikov
Copy link
Copy Markdown
Owner

Einops does not accept new backends, those require sufficient time for maintenance.

Lib authors can implement array api:
https://data-apis.org/array-api/latest/API_specification/index.html
and einops.array_api will immediately work for them.

Array api support will be available in einops 0.7

Relevant PR: #261

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants