This commit is contained in:
brucexiaj 2020-07-05 14:10:24 +08:00
parent 510dc78710
commit b94de0ccf0
2 changed files with 19 additions and 3 deletions

12
main.py
View File

@ -1,4 +1,12 @@
from source import main_func
from source import define_tensor
from mindspore import Tensor
if __name__ == '__main__':
main_func()
t1= define_tensor()
if not isinstance(t1, Tensor):
print("定义的不是张量")
if len(t1.shape) != 3:
print("定义的张量不是三阶张量")
if t1.dtype != mindspore.int32
print("定义的张量不是int32类型")
print("定义张量成功")

View File

@ -1 +1,9 @@

import mindspore
from mindspore import Tensor
def define_tensor():
# 定义一个int32类型的三阶张量内容不限
# 将这个张量作为函数的返回值
########## Begin ##########
tensor = Tensor([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], mindspore.int32) # 定义一个张量
return tensor
########## End##########