"""
mindspore.run_check
The goal is to provide a convenient API to check if the installation is successful or failed.
"""
def _check_mul():
"""
Define the mul method.
"""
from importlib import import_module
import numpy as np
try:
ms = import_module("mindspore")
except ModuleNotFoundError:
ms = None
finally:
pass
print(f"MindSpore version:", ms.__version__)
input_x = ms.Tensor(np.array([1.0, 2.0, 3.0]), ms.float32)
input_y = ms.Tensor(np.array([4.0, 5.0, 6.0]), ms.float32)
mul = ms.ops.Mul()
mul(input_x, input_y)
print(f"The result of multiplication calculation is correct, MindSpore has been installed successfully!")
def run_check():
"""
Provide a convenient API to check if the installation is successful or failed.
If there is no return value, the verification status will be displayed directly.
Examples:
>>> import mindspore
>>> mindspore.run_check()
MindSpore version: xxx
The result of multiplication calculation is correct, MindSpore has been installed successfully!
"""
try:
_check_mul()
except Exception as e:
print("MindSpore running check failed.")
print(str(e))
finally:
pass