• Home
Name
Date
Size
#Lines
LOC

..--

.github/12-May-2024-11165

.jenkins/12-May-2024-370358

akg/12-May-2024-

cmake/12-May-2024-4,2863,848

config/12-May-2024-859854

docs/12-May-2024-42

graphengine/12-May-2024-

include/12-May-2024-4,4841,752

mindspore/12-May-2024-1,631,0741,271,140

model_zoo/12-May-2024-2212

scripts/12-May-2024-5,2294,258

tests/12-May-2024-796,952679,938

third_party/12-May-2024-17,28713,384

.clang-formatD12-May-20243.9 KiB152150

.gitignoreD12-May-20241.6 KiB10891

.gitmodulesD12-May-2024264 109

CMakeLists.txtD12-May-20244.3 KiB10792

CONTRIBUTING.mdD12-May-20247.4 KiB13589

LICENSED12-May-202411.1 KiB202169

NOTICED12-May-202459 32

OAT.xmlD12-May-20246.8 KiB9240

OWNERSD12-May-2024329 2723

README.OpenSourceD12-May-2024268 1211

README.mdD12-May-202415.5 KiB305219

README_CN.mdD12-May-202416.2 KiB351260

RELEASE.mdD12-May-2024153.7 KiB3,1352,364

SECURITY.mdD12-May-20242.3 KiB2818

Third_Party_Open_Source_Software_NoticeD12-May-2024554.7 KiB9,7778,955

build.batD12-May-20243 KiB9281

build.shD12-May-20242.7 KiB9970

requirements.txtD12-May-2024414 1514

setup.pyD12-May-20246.7 KiB228167

version.txtD12-May-20245 11

README.OpenSource

1[
2  {
3    "Name": "MindSpore",
4    "License": "Apache-2.0",
5    "License File": "LICENSE",
6    "Version Number": "1.5.1",
7    "Owner": "zhaizhiqiang@huawei.com",
8    "Upstream URL": "https://gitee.com/mindspore/mindspore/tree/v1.5.1/",
9    "Description": "...."
10  }
11]
12

README.md

1![MindSpore Logo](https://gitee.com/mindspore/mindspore/raw/master/docs/MindSpore-logo.png "MindSpore logo")
2
3[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mindspore.svg)](https://pypi.org/project/mindspore)
4[![PyPI](https://badge.fury.io/py/mindspore.svg)](https://badge.fury.io/py/mindspore)
5[![Downloads](https://pepy.tech/badge/mindspore)](https://pepy.tech/project/mindspore)
6[![DockerHub](https://img.shields.io/docker/pulls/mindspore/mindspore-cpu.svg)](https://hub.docker.com/r/mindspore/mindspore-cpu)
7[![LICENSE](https://img.shields.io/github/license/mindspore-ai/mindspore.svg?style=flat-square)](https://github.com/mindspore-ai/mindspore/blob/master/LICENSE)
8[![Slack](https://img.shields.io/badge/slack-chat-green.svg?logo=slack)](https://join.slack.com/t/mindspore/shared_invite/zt-dgk65rli-3ex4xvS4wHX7UDmsQmfu8w)
9[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://gitee.com/mindspore/mindspore/pulls)
10
11[查看中文](./README_CN.md)
12
13<!-- TOC -->
14
15- [What Is MindSpore](#what-is-mindspore)
16    - [Automatic Differentiation](#automatic-differentiation)
17    - [Automatic Parallel](#automatic-parallel)
18- [Installation](#installation)
19    - [Pip mode method installation](#pip-mode-method-installation)
20    - [Source code compilation installation](#source-code-compilation-installation)
21    - [Docker Image](#docker-image)
22- [Quickstart](#quickstart)
23- [Docs](#docs)
24- [Community](#community)
25    - [Governance](#governance)
26    - [Communication](#communication)
27- [Contributing](#contributing)
28- [Maintenance phases](#maintenance-phases)
29- [Maintenance status](#maintenance-status)
30- [Release Notes](#release-notes)
31- [License](#license)
32
33<!-- /TOC -->
34
35## What Is MindSpore
36
37MindSpore is a new open source deep learning training/inference framework that
38could be used for mobile, edge and cloud scenarios. MindSpore is designed to
39provide development experience with friendly design and efficient execution for
40the data scientists and algorithmic engineers, native support for Ascend AI
41processor, and software hardware co-optimization. At the meantime MindSpore as
42a global AI open source community, aims to further advance the development and
43enrichment of the AI software/hardware application ecosystem.
44
45<img src="https://gitee.com/mindspore/mindspore/raw/r1.5/docs/MindSpore-architecture.png" alt="MindSpore Architecture" width="600"/>
46
47For more details please check out our [Architecture Guide](https://www.mindspore.cn/docs/programming_guide/en/r1.5/architecture.html).
48
49### Automatic Differentiation
50
51There are currently three automatic differentiation techniques in mainstream deep learning frameworks:
52
53- **Conversion based on static compute graph**: Convert the network into a static data flow graph at compile time, then turn the chain rule into a data flow graph to implement automatic differentiation.
54- **Conversion based on dynamic compute graph**: Record the operation trajectory of the network during forward execution in an operator overloaded manner, then apply the chain rule to the dynamically generated data flow graph to implement automatic differentiation.
55- **Conversion based on source code**: This technology is evolving from the functional programming framework and performs automatic differential transformation on the intermediate expression (the expression form of the program during the compilation process) in the form of just-in-time compilation (JIT), supporting complex control flow scenarios, higher-order functions and closures.
56
57TensorFlow adopted static calculation diagrams in the early days, whereas PyTorch used dynamic calculation diagrams. Static maps can utilize static compilation technology to optimize network performance, however, building a network or debugging it is very complicated. The use of dynamic graphics is very convenient, but it is difficult to achieve extreme optimization in performance.
58
59But MindSpore finds another way, automatic differentiation based on source code conversion. On the one hand, it supports automatic differentiation of automatic control flow, so it is quite convenient to build models like PyTorch. On the other hand, MindSpore can perform static compilation optimization on neural networks to achieve great performance.
60
61<img src="https://gitee.com/mindspore/mindspore/raw/r1.5/docs/Automatic-differentiation.png" alt="Automatic Differentiation" width="600"/>
62
63The implementation of MindSpore automatic differentiation can be understood as the symbolic differentiation of the program itself. Because MindSpore IR is a functional intermediate expression, it has an intuitive correspondence with the composite function in basic algebra. The derivation formula of the composite function composed of arbitrary basic functions can be derived. Each primitive operation in MindSpore IR can correspond to the basic functions in basic algebra, which can build more complex flow control.
64
65### Automatic Parallel
66
67The goal of MindSpore automatic parallel is to build a training method that combines data parallelism, model parallelism, and hybrid parallelism. It can automatically select a least cost model splitting strategy to achieve automatic distributed parallel training.
68
69<img src="https://gitee.com/mindspore/mindspore/raw/r1.5/docs/Automatic-parallel.png" alt="Automatic Parallel" width="600"/>
70
71At present, MindSpore uses a fine-grained parallel strategy of splitting operators, that is, each operator in the figure is split into a cluster to complete parallel operations. The splitting strategy during this period may be very complicated, but as a developer advocating Pythonic, you don't need to care about the underlying implementation, as long as the top-level API compute is efficient.
72
73## Installation
74
75### Pip mode method installation
76
77MindSpore offers build options across multiple backends:
78
79| Hardware Platform | Operating System | Status |
80| :---------------- | :--------------- | :----- |
81| Ascend910 | Ubuntu-x86 | ✔️ |
82|  | Ubuntu-aarch64 | ✔️ |
83|  | EulerOS-aarch64 | ✔️ |
84|  | CentOS-x86 | ✔️ |
85|  | CentOS-aarch64 | ✔️ |
86| GPU CUDA 10.1 | Ubuntu-x86 | ✔️ |
87| CPU | Ubuntu-x86 | ✔️ |
88|  | Ubuntu-aarch64 | ✔️ |
89|  | Windows-x86 | ✔️ |
90
91For installation using `pip`, take `CPU` and `Ubuntu-x86` build version as an example:
92
931. Download whl from [MindSpore download page](https://www.mindspore.cn/versions/en), and install the package.
94
95    ```bash
96    pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.2.0-rc1/MindSpore/cpu/ubuntu_x86/mindspore-1.2.0rc1-cp37-cp37m-linux_x86_64.whl
97    ```
98
992. Run the following command to verify the install.
100
101    ```python
102    import numpy as np
103    import mindspore.context as context
104    import mindspore.nn as nn
105    from mindspore import Tensor
106    from mindspore.ops import operations as P
107
108    context.set_context(mode=context.GRAPH_MODE, device_target="CPU")
109
110    class Mul(nn.Cell):
111        def __init__(self):
112            super(Mul, self).__init__()
113            self.mul = P.Mul()
114
115        def construct(self, x, y):
116            return self.mul(x, y)
117
118    x = Tensor(np.array([1.0, 2.0, 3.0]).astype(np.float32))
119    y = Tensor(np.array([4.0, 5.0, 6.0]).astype(np.float32))
120
121    mul = Mul()
122    print(mul(x, y))
123    ```
124
125    ```text
126    [ 4. 10. 18.]
127    ```
128
129Use pip mode method to install MindSpore in different environments. Refer to the following documents.
130
131- [Using pip mode method to install MindSpore in Ascend environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_ascend_install_pip_en.md)
132- [Using pip mode method to install MindSpore in GPU environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_gpu_install_pip_en.md)
133- [Using pip mode method to install MindSpore in CPU environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_cpu_install_pip_en.md)
134
135### Source code compilation installation
136
137Use the source code compilation method to install MindSpore in different environments. Refer to the following documents.
138
139- [Using the source code compilation method to install MindSpore in Ascend environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_ascend_install_source_en.md)
140- [Using the source code compilation method to install MindSpore in GPU environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_gpu_install_source_en.md)
141- [Using the source code compilation method to install MindSpore in CPU environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_cpu_install_source_en.md)
142
143### Docker Image
144
145MindSpore docker image is hosted on [Docker Hub](https://hub.docker.com/r/mindspore),
146currently the containerized build options are supported as follows:
147
148| Hardware Platform | Docker Image Repository | Tag | Description |
149| :---------------- | :---------------------- | :-- | :---------- |
150| CPU | `mindspore/mindspore-cpu` | `x.y.z` | Production environment with pre-installed MindSpore `x.y.z` CPU release. |
151|  |  | `devel` | Development environment provided to build MindSpore (with `CPU` backend) from the source, refer to <https://www.mindspore.cn/install/en> for installation details. |
152|  |  | `runtime` | Runtime environment provided to install MindSpore binary package with `CPU` backend. |
153| GPU | `mindspore/mindspore-gpu` | `x.y.z` | Production environment with pre-installed MindSpore `x.y.z` GPU release. |
154|  |  | `devel` | Development environment provided to build MindSpore (with `GPU CUDA10.1` backend) from the source, refer to <https://www.mindspore.cn/install/en> for installation details. |
155|  |  | `runtime` | Runtime environment provided to install MindSpore binary package with `GPU CUDA10.1` backend. |
156
157> **NOTICE:** For GPU `devel` docker image, it's NOT suggested to directly install the whl package after building from the source, instead we strongly RECOMMEND you transfer and install the whl package inside GPU `runtime` docker image.
158
159- CPU
160
161    For `CPU` backend, you can directly pull and run the latest stable image using the below command:
162
163    ```bash
164    docker pull mindspore/mindspore-cpu:1.1.0
165    docker run -it mindspore/mindspore-cpu:1.1.0 /bin/bash
166    ```
167
168- GPU
169
170    For `GPU` backend, please make sure the `nvidia-container-toolkit` has been installed in advance, here are some install guidelines for `Ubuntu` users:
171
172    ```bash
173    DISTRIBUTION=$(. /etc/os-release; echo $ID$VERSION_ID)
174    curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add -
175    curl -s -L https://nvidia.github.io/nvidia-docker/$DISTRIBUTION/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list
176
177    sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit nvidia-docker2
178    sudo systemctl restart docker
179    ```
180
181    Then edit the file daemon.json:
182
183    ```bash
184    $ vim /etc/docker/daemon.json
185    {
186        "runtimes": {
187            "nvidia": {
188                "path": "nvidia-container-runtime",
189                "runtimeArgs": []
190            }
191        }
192    }
193    ```
194
195    Restart docker again:
196
197    ```bash
198    sudo systemctl daemon-reload
199    sudo systemctl restart docker
200    ```
201
202    Then you can pull and run the latest stable image using the below command:
203
204    ```bash
205    docker pull mindspore/mindspore-gpu:1.1.0
206    docker run -it -v /dev/shm:/dev/shm --runtime=nvidia --privileged=true mindspore/mindspore-gpu:1.1.0 /bin/bash
207    ```
208
209    To test if the docker image works, please execute the python code below and check the output:
210
211    ```python
212    import numpy as np
213    import mindspore.context as context
214    from mindspore import Tensor
215    from mindspore.ops import functional as F
216
217    context.set_context(mode=context.PYNATIVE_MODE, device_target="GPU")
218
219    x = Tensor(np.ones([1,3,3,4]).astype(np.float32))
220    y = Tensor(np.ones([1,3,3,4]).astype(np.float32))
221    print(F.tensor_add(x, y))
222    ```
223
224    ```text
225    [[[ 2.  2.  2.  2.],
226    [ 2.  2.  2.  2.],
227    [ 2.  2.  2.  2.]],
228
229    [[ 2.  2.  2.  2.],
230    [ 2.  2.  2.  2.],
231    [ 2.  2.  2.  2.]],
232
233    [[ 2.  2.  2.  2.],
234    [ 2.  2.  2.  2.],
235    [ 2.  2.  2.  2.]]]
236    ```
237
238If you want to learn more about the building process of MindSpore docker images,
239please check out [docker](https://gitee.com/mindspore/mindspore/blob/r1.5/scripts/docker/README.md) repo for the details.
240
241## Quickstart
242
243See the [Quick Start](https://www.mindspore.cn/tutorials/en/r1.5/quick_start.html)
244to implement the image classification.
245
246## Docs
247
248More details about installation guide, tutorials and APIs, please see the
249[User Documentation](https://gitee.com/mindspore/docs).
250
251## Community
252
253### Governance
254
255Check out how MindSpore Open Governance [works](https://gitee.com/mindspore/community/blob/master/governance.md).
256
257### Communication
258
259- [MindSpore Slack](https://join.slack.com/t/mindspore/shared_invite/zt-dgk65rli-3ex4xvS4wHX7UDmsQmfu8w) - Communication platform for developers.
260- IRC channel at `#mindspore` (only for meeting minutes logging purpose)
261- Video Conferencing: TBD
262- Mailing-list: <https://mailweb.mindspore.cn/postorius/lists>
263
264## Contributing
265
266Welcome contributions. See our [Contributor Wiki](https://gitee.com/mindspore/mindspore/blob/master/CONTRIBUTING.md) for
267more details.
268
269## Maintenance phases
270
271Project stable branches will be in one of the following states:
272
273| **State**       | **Time frame**    | **Summary**                                          |
274|-------------|---------------|--------------------------------------------------|
275| Planning    | 1 - 3 months  | Features are under planning.                     |
276| Development | 3 months      | Features are under development.                  |
277| Maintained  | 6 - 12 months | All bugfixes are appropriate. Releases produced. |
278| Unmaintained| 0 - 3 months  | All bugfixes are appropriate. No Maintainers and No Releases produced.                                                 |
279| End Of Life (EOL) |  N/A |  Branch no longer accepting changes.    |
280
281## Maintenance status
282
283| **Branch** | **Status**   | **Initial Release Date** | **Next Phase**                         | **EOL Date**|
284|------------|--------------|--------------------------|----------------------------------------|-------------|
285| **r1.5**   | Maintained   | 2021-10-15               | Unmaintained <br> 2022-10-15 estimated |             |
286| **r1.4**   | Maintained   | 2021-08-15               | Unmaintained <br> 2022-08-15 estimated |             |
287| **r1.3**   | Maintained   | 2021-07-15               | Unmaintained <br> 2022-07-15 estimated |             |
288| **r1.2**   | Unmaintained | 2021-04-15               | End Of Life  <br> 2022-04-15 estimated |             |
289| **r1.1**   | End Of Life  | 2020-12-31               |                                        | 2021-09-30  |
290| **r1.0**   | End Of Life  | 2020-09-24               |                                        | 2021-07-30  |
291| **r0.7**   | End Of Life  | 2020-08-31               |                                        | 2021-02-28  |
292| **r0.6**   | End Of Life  | 2020-07-31               |                                        | 2020-12-30  |
293| **r0.5**   | End Of Life  | 2020-06-30               |                                        | 2021-06-30  |
294| **r0.3**   | End Of Life  | 2020-05-31               |                                        | 2020-09-30  |
295| **r0.2**   | End Of Life  | 2020-04-30               |                                        | 2020-08-31  |
296| **r0.1**   | End Of Life  | 2020-03-28               |                                        | 2020-06-30  |
297
298## Release Notes
299
300The release notes, see our [RELEASE](https://gitee.com/mindspore/mindspore/blob/master/RELEASE.md).
301
302## License
303
304[Apache License 2.0](https://gitee.com/mindspore/mindspore#/mindspore/mindspore/blob/master/LICENSE)
305

README_CN.md

1![MindSpore标志](https://gitee.com/mindspore/mindspore/raw/master/docs/MindSpore-logo.png "MindSpore logo")
2
3[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mindspore.svg)](https://pypi.org/project/mindspore)
4[![PyPI](https://badge.fury.io/py/mindspore.svg)](https://badge.fury.io/py/mindspore)
5[![Downloads](https://pepy.tech/badge/mindspore)](https://pepy.tech/project/mindspore)
6[![DockerHub](https://img.shields.io/docker/pulls/mindspore/mindspore-cpu.svg)](https://hub.docker.com/r/mindspore/mindspore-cpu)
7[![LICENSE](https://img.shields.io/github/license/mindspore-ai/mindspore.svg?style=flat-square)](https://github.com/mindspore-ai/mindspore/blob/master/LICENSE)
8[![Slack](https://img.shields.io/badge/slack-chat-green.svg?logo=slack)](https://join.slack.com/t/mindspore/shared_invite/zt-dgk65rli-3ex4xvS4wHX7UDmsQmfu8w)
9[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://gitee.com/mindspore/mindspore/pulls)
10
11[View English](./README.md)
12
13<!-- TOC -->
14
15- [MindSpore介绍](#mindspore介绍)
16  - [自动微分](#自动微分)
17  - [自动并行](#自动并行)
18- [安装](#安装)
19  - [pip方式安装](#pip方式安装)
20  - [源码编译方式安装](#源码编译方式安装)
21  - [Docker镜像](#docker镜像)
22- [快速入门](#快速入门)
23- [文档](#文档)
24- [社区](#社区)
25  - [治理](#治理)
26  - [交流](#交流)
27- [贡献](#贡献)
28- [分支维护策略](#分支维护策略)
29- [现有分支维护状态](#现有分支维护状态)
30- [版本说明](#版本说明)
31- [许可证](#许可证)
32- [OpenHarmony系统部件](#openharmony系统部件)
33  - [MindSpore Lite](#mindspore-lite)
34    - [使用方法](#使用方法)
35  - [MindIR 构图接口](#mindir-构图接口)
36    - [使用方法](#使用方法-1)
37
38<!-- /TOC -->
39
40## MindSpore介绍
41
42MindSpore是一种适用于端边云场景的新型开源深度学习训练/推理框架。
43MindSpore提供了友好的设计和高效的执行,旨在提升数据科学家和算法工程师的开发体验,并为Ascend AI处理器提供原生支持,以及软硬件协同优化。
44
45同时,MindSpore作为全球AI开源社区,致力于进一步开发和丰富AI软硬件应用生态。
46
47<img src="https://gitee.com/mindspore/mindspore/raw/r1.5/docs/MindSpore-architecture.png" alt="MindSpore Architecture" width="600"/>
48
49欲了解更多详情,请查看我们的[总体架构](https://www.mindspore.cn/docs/programming_guide/zh-CN/r1.5/architecture.html)50
51### 自动微分
52
53当前主流深度学习框架中有三种自动微分技术:
54
55- **基于静态计算图的转换**:编译时将网络转换为静态数据流图,将链式法则应用于数据流图,实现自动微分。
56- **基于动态计算图的转换**:记录算子过载正向执行时网络的运行轨迹,对动态生成的数据流图应用链式法则,实现自动微分。
57- **基于源码的转换**:该技术是从功能编程框架演进而来,以即时编译(Just-in-time Compilation,JIT)的形式对中间表达式(程序在编译过程中的表达式)进行自动差分转换,支持复杂的控制流场景、高阶函数和闭包。
58
59TensorFlow早期采用的是静态计算图,PyTorch采用的是动态计算图。静态映射可以利用静态编译技术来优化网络性能,但是构建网络或调试网络非常复杂。动态图的使用非常方便,但很难实现性能的极限优化。
60
61MindSpore找到了另一种方法,即基于源代码转换的自动微分。一方面,它支持自动控制流的自动微分,因此像PyTorch这样的模型构建非常方便。另一方面,MindSpore可以对神经网络进行静态编译优化,以获得更好的性能。
62
63<img src="https://gitee.com/mindspore/mindspore/raw/r1.5/docs/Automatic-differentiation.png" alt="Automatic Differentiation" width="600"/>
64
65MindSpore自动微分的实现可以理解为程序本身的符号微分。MindSpore IR是一个函数中间表达式,它与基础代数中的复合函数具有直观的对应关系。复合函数的公式由任意可推导的基础函数组成。MindSpore IR中的每个原语操作都可以对应基础代数中的基本功能,从而可以建立更复杂的流控制。
66
67### 自动并行
68
69MindSpore自动并行的目的是构建数据并行、模型并行和混合并行相结合的训练方法。该方法能够自动选择开销最小的模型切分策略,实现自动分布并行训练。
70
71<img src="https://gitee.com/mindspore/mindspore/raw/r1.5/docs/Automatic-parallel.png" alt="Automatic Parallel" width="600"/>
72
73目前MindSpore采用的是算子切分的细粒度并行策略,即图中的每个算子被切分为一个集群,完成并行操作。在此期间的切分策略可能非常复杂,但是作为一名Python开发者,您无需关注底层实现,只要顶层API计算是有效的即可。
74
75## 安装
76
77### pip方式安装
78
79MindSpore提供跨多个后端的构建选项:
80
81| 硬件平台      | 操作系统        | 状态  |
82| :------------ | :-------------- | :--- |
83| Ascend 910    | Ubuntu-x86      | ✔️   |
84|               | Ubuntu-aarch64  | ✔️   |
85|               | EulerOS-aarch64 | ✔️   |
86|               | CentOS-x86      | ✔️   |
87|               | CentOS-aarch64  | ✔️   |
88| GPU CUDA 10.1 | Ubuntu-x86      | ✔️   |
89| CPU           | Ubuntu-x86      | ✔️   |
90|               | Ubuntu-aarch64  | ✔️   |
91|               | Windows-x86     | ✔️   |
92
93使用`pip`命令安装,以`CPU`和`Ubuntu-x86`build版本为例:
94
951. 请从[MindSpore下载页面](https://www.mindspore.cn/versions)下载并安装whl包。
96
97    ```bash
98    pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.2.0-rc1/MindSpore/cpu/ubuntu_x86/mindspore-1.2.0rc1-cp37-cp37m-linux_x86_64.whl
99    ```
100
1012. 执行以下命令,验证安装结果。
102
103    ```python
104    import numpy as np
105    import mindspore.context as context
106    import mindspore.nn as nn
107    from mindspore import Tensor
108    from mindspore.ops import operations as P
109
110    context.set_context(mode=context.GRAPH_MODE, device_target="CPU")
111
112    class Mul(nn.Cell):
113        def __init__(self):
114            super(Mul, self).__init__()
115            self.mul = P.Mul()
116
117        def construct(self, x, y):
118            return self.mul(x, y)
119
120    x = Tensor(np.array([1.0, 2.0, 3.0]).astype(np.float32))
121    y = Tensor(np.array([4.0, 5.0, 6.0]).astype(np.float32))
122
123    mul = Mul()
124    print(mul(x, y))
125    ```
126
127    ```text
128    [ 4. 10. 18.]
129    ```
130
131使用pip方式,在不同的环境安装MindSpore,可参考以下文档。
132
133- [Ascend环境使用pip方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_ascend_install_pip.md)
134- [GPU环境使用pip方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_gpu_install_pip.md)
135- [CPU环境使用pip方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_cpu_install_pip.md)
136
137### 源码编译方式安装
138
139使用源码编译方式,在不同的环境安装MindSpore,可参考以下文档。
140
141- [Ascend环境使用源码编译方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_ascend_install_source.md)
142- [GPU环境使用源码编译方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_gpu_install_source.md)
143- [CPU环境使用源码编译方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_cpu_install_source.md)
144
145### Docker镜像
146
147MindSpore的Docker镜像托管在[Docker Hub](https://hub.docker.com/r/mindspore)上。
148目前容器化构建选项支持情况如下:
149
150| 硬件平台   | Docker镜像仓库                | 标签                       | 说明                                       |
151| :----- | :------------------------ | :----------------------- | :--------------------------------------- |
152| CPU    | `mindspore/mindspore-cpu` | `x.y.z`                  | 已经预安装MindSpore `x.y.z` CPU版本的生产环境。       |
153|        |                           | `devel`                  | 提供开发环境从源头构建MindSpore(`CPU`后端)。安装详情请参考<https://www.mindspore.cn/install> 。 |
154|        |                           | `runtime`                | 提供运行时环境安装MindSpore二进制包(`CPU`后端)。         |
155| GPU    | `mindspore/mindspore-gpu` | `x.y.z`                  | 已经预安装MindSpore `x.y.z` GPU版本的生产环境。       |
156|        |                           | `devel`                  | 提供开发环境从源头构建MindSpore(`GPU CUDA10.1`后端)。安装详情请参考<https://www.mindspore.cn/install> 。 |
157|        |                           | `runtime`                | 提供运行时环境安装MindSpore二进制包(`GPU CUDA10.1`后端)。 |
158
159> **注意:** 不建议从源头构建GPU `devel` Docker镜像后直接安装whl包。我们强烈建议您在GPU `runtime` Docker镜像中传输并安装whl包。
160
161- CPU
162
163    对于`CPU`后端,可以直接使用以下命令获取并运行最新的稳定镜像:
164
165    ```bash
166    docker pull mindspore/mindspore-cpu:1.1.0
167    docker run -it mindspore/mindspore-cpu:1.1.0 /bin/bash
168    ```
169
170- GPU
171
172    对于`GPU`后端,请确保`nvidia-container-toolkit`已经提前安装,以下是`Ubuntu`用户安装指南:
173
174    ```bash
175    DISTRIBUTION=$(. /etc/os-release; echo $ID$VERSION_ID)
176    curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add -
177    curl -s -L https://nvidia.github.io/nvidia-docker/$DISTRIBUTION/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list
178
179    sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit nvidia-docker2
180    sudo systemctl restart docker
181    ```
182
183    编辑文件 daemon.json:
184
185    ```bash
186    $ vim /etc/docker/daemon.json
187    {
188        "runtimes": {
189            "nvidia": {
190                "path": "nvidia-container-runtime",
191                "runtimeArgs": []
192            }
193        }
194    }
195    ```
196
197    再次重启docker:
198
199    ```bash
200    sudo systemctl daemon-reload
201    sudo systemctl restart docker
202    ```
203
204    使用以下命令获取并运行最新的稳定镜像:
205
206    ```bash
207    docker pull mindspore/mindspore-gpu:1.1.0
208    docker run -it -v /dev/shm:/dev/shm --runtime=nvidia --privileged=true mindspore/mindspore-gpu:1.1.0 /bin/bash
209    ```
210
211    要测试Docker是否正常工作,请运行下面的Python代码并检查输出:
212
213    ```python
214    import numpy as np
215    import mindspore.context as context
216    from mindspore import Tensor
217    from mindspore.ops import functional as F
218
219    context.set_context(mode=context.PYNATIVE_MODE, device_target="GPU")
220
221    x = Tensor(np.ones([1,3,3,4]).astype(np.float32))
222    y = Tensor(np.ones([1,3,3,4]).astype(np.float32))
223    print(F.tensor_add(x, y))
224    ```
225
226    ```text
227    [[[ 2.  2.  2.  2.],
228    [ 2.  2.  2.  2.],
229    [ 2.  2.  2.  2.]],
230
231    [[ 2.  2.  2.  2.],
232    [ 2.  2.  2.  2.],
233    [ 2.  2.  2.  2.]],
234
235    [[ 2.  2.  2.  2.],
236    [ 2.  2.  2.  2.],
237    [ 2.  2.  2.  2.]]]
238    ```
239
240如果您想了解更多关于MindSpore Docker镜像的构建过程,请查看[docker](https://gitee.com/mindspore/mindspore/blob/r1.5/scripts/docker/README.md) repo了解详细信息。
241
242## 快速入门
243
244参考[快速入门](https://www.mindspore.cn/tutorials/zh-CN/r1.5/quick_start.html)实现图片分类。
245
246## 文档
247
248有关安装指南、教程和API的更多详细信息,请参阅[用户文档](https://gitee.com/mindspore/docs)249
250## 社区
251
252### 治理
253
254查看MindSpore如何进行[开放治理](https://gitee.com/mindspore/community/blob/master/governance.md)255
256### 交流
257
258- [MindSpore Slack](https://join.slack.com/t/mindspore/shared_invite/zt-dgk65rli-3ex4xvS4wHX7UDmsQmfu8w) 开发者交流平台。
259- `#mindspore`IRC频道(仅用于会议记录)
260- 视频会议:待定
261- 邮件列表:<https://mailweb.mindspore.cn/postorius/lists>
262
263## 贡献
264
265欢迎参与贡献。更多详情,请参阅我们的[贡献者Wiki](https://gitee.com/mindspore/mindspore/blob/master/CONTRIBUTING.md)266
267## 分支维护策略
268
269MindSpore的版本分支有以下几种维护阶段:
270
271| **状态**       | **持续时间**    | **说明**                                          |
272|-------------|---------------|--------------------------------------------------|
273| Planning    | 1 - 3 months  | 特性规划。                     |
274| Development | 3 months      | 特性开发。                  |
275| Maintained  | 6 - 12 months | 允许所有问题修复的合入,并发布版本。 |
276| Unmaintained| 0 - 3 months  | 允许所有问题修复的合入,无专人维护,不再发布版本。                                                 |
277| End Of Life (EOL) |  N/A |  不再接受修改合入该分支。    |
278
279## 现有分支维护状态
280
281| **分支名** | **当前状态**  | **上线时间**          | **后续状态**                           | **EOL 日期**|
282|------------|--------------|----------------------|----------------------------------------|------------|
283| **r1.5**   | Maintained   | 2021-10-15           | Unmaintained <br> 2022-10-15 estimated |            |
284| **r1.4**   | Maintained   | 2021-08-15           | Unmaintained <br> 2022-08-15 estimated |            |
285| **r1.3**   | Maintained   | 2021-07-15           | Unmaintained <br> 2022-07-15 estimated |            |
286| **r1.2**   | Unmaintained | 2021-04-15           | End Of Life  <br> 2022-04-15 estimated |            |
287| **r1.1**   | End Of Life  | 2020-12-31           |                                        | 2021-09-30 |
288| **r1.0**   | End Of Life  | 2020-09-24           |                                        | 2021-07-30 |
289| **r0.7**   | End Of Life  | 2020-08-31           |                                        | 2021-02-28 |
290| **r0.6**   | End Of Life  | 2020-07-31           |                                        | 2020-12-30 |
291| **r0.5**   | End Of Life  | 2020-06-30           |                                        | 2021-06-30 |
292| **r0.3**   | End Of Life  | 2020-05-31           |                                        | 2020-09-30 |
293| **r0.2**   | End Of Life  | 2020-04-30           |                                        | 2020-08-31 |
294| **r0.1**   | End Of Life  | 2020-03-28           |                                        | 2020-06-30 |
295
296## 版本说明
297
298版本说明请参阅[RELEASE](https://gitee.com/mindspore/mindspore/blob/master/RELEASE.md)299
300## 许可证
301
302[Apache License 2.0](https://gitee.com/mindspore/mindspore#/mindspore/mindspore/blob/master/LICENSE)
303
304## OpenHarmony系统部件
305目前OpenHarmony的标准系统内置了Mindspore Lite,和MindIR构图接口。
306### MindSpore Lite
307关于MindSpore Lite的介绍详见(MindSpore Lite介绍)[mindspore/lite/README_CN.md]。
308#### 使用方法
309BUILD.gn中加入如下依赖即可使用MindSpore Lite:
310```gn
311include_dirs = [
312    "//third_party/mindspore/"
313]
314external_deps = ["mindspore:mindspore_lib"]
315```
316
317C++ 的头文件存放在`include/api`目录中,使用方法:
318```C++
319#include "include/api/xxx"
320```
321
322C 的头文件存放在`include/c_api`目录中,使用方法:
323```C++
324#include "include/c_api/xxx"
325```
326### MindIR 构图接口
327MindIR是MindSpore 用于描述图结构的中间表达方式。
328Primitive 是一套基于flatbuffers的对模型进行序列化的工具,MindSpore Lite使用它存储图结构、算子、张量等信息。
329Lite Graph是MindSpore Lite用于描述模型中节点、张量、子图等信息的结构,并且可以通过MindIR接口构建Lite Graph。
330
331#### 使用方法
332BUILD.gn中加入如下依赖即可使用MindIR 构图接口:
333```gn
334include_dirs = [
335    "//third_party/mindspore/mindspore/lite/mindir/include"
336]
337external_deps = ["mindspore:mindir"]
338```
339
340C++ 接口存放目录为`mindspore/mindspore/lite/mindir/include`直接使用
341```
342├── include                     # 对外的所有头文件
343│   ├── mindir.h                # MindIR所有功能的头文件
344│   ├── mindir_lite_graph.h     # Lite Graph相关的头文件
345│   ├── mindir_primitive.h      # Primitive相关头文件
346│   ├── mindir_tensor.h         # Tensor相关头文件
347│   └── mindir_types.h          # 类型相关的头文件
348├── inner_headers               # 内部使用的头文件
349├── src                         # MindIR构图接口的源代码
350└── tests                       # 测试代码
351```