Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
正统之独孤求败
mindspore
提交
d3dbb10b
M
mindspore
项目概览
正统之独孤求败
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d3dbb10b
编写于
5月 29, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
5月 29, 2020
浏览文件
操作
浏览文件
下载
差异文件
!1563 Fixing some tiny faults about Pylint in my code(ops)
Merge pull request !1563 from liuwenhao/master
上级
0b3da2c7
f87c70a9
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
150 addition
and
168 deletion
+150
-168
mindspore/ops/_op_impl/_custom_op/batch_matmul_impl.py
mindspore/ops/_op_impl/_custom_op/batch_matmul_impl.py
+4
-3
mindspore/ops/_op_impl/_custom_op/matmul_cube_dense_left_impl.py
...re/ops/_op_impl/_custom_op/matmul_cube_dense_left_impl.py
+17
-16
mindspore/ops/_op_impl/_custom_op/matmul_cube_fracz_left_cast_impl.py
...s/_op_impl/_custom_op/matmul_cube_fracz_left_cast_impl.py
+7
-7
mindspore/ops/_op_impl/_custom_op/matmul_cube_fracz_right_mul_impl.py
...s/_op_impl/_custom_op/matmul_cube_fracz_right_mul_impl.py
+2
-2
mindspore/ops/_op_impl/_custom_op/matmul_cube_impl.py
mindspore/ops/_op_impl/_custom_op/matmul_cube_impl.py
+10
-10
tests/st/ops/ascend/test_ops_infer.py
tests/st/ops/ascend/test_ops_infer.py
+5
-12
tests/st/ops/ascend/test_tbe_ops/test_mul.py
tests/st/ops/ascend/test_tbe_ops/test_mul.py
+5
-5
tests/st/ops/ascend/test_tbe_ops/test_npu_clear_float_status.py
...st/ops/ascend/test_tbe_ops/test_npu_clear_float_status.py
+3
-3
tests/st/ops/ascend/test_tbe_ops/test_npu_get_float_status.py
...s/st/ops/ascend/test_tbe_ops/test_npu_get_float_status.py
+3
-3
tests/st/ops/ascend/test_tbe_ops/test_pad.py
tests/st/ops/ascend/test_tbe_ops/test_pad.py
+2
-2
tests/st/ops/ascend/test_tbe_ops/test_realdiv.py
tests/st/ops/ascend/test_tbe_ops/test_realdiv.py
+5
-5
tests/st/ops/ascend/test_tbe_ops/test_reciprocal.py
tests/st/ops/ascend/test_tbe_ops/test_reciprocal.py
+3
-3
tests/st/ops/ascend/test_tbe_ops/test_scatter_nd.py
tests/st/ops/ascend/test_tbe_ops/test_scatter_nd.py
+5
-5
tests/st/ops/ascend/test_tbe_ops/test_softmax.py
tests/st/ops/ascend/test_tbe_ops/test_softmax.py
+3
-3
tests/st/ops/ascend/test_tbe_ops/test_split.py
tests/st/ops/ascend/test_tbe_ops/test_split.py
+3
-3
tests/st/ops/ascend/test_tbe_ops/test_sqrt.py
tests/st/ops/ascend/test_tbe_ops/test_sqrt.py
+3
-3
tests/st/ops/ascend/test_tbe_ops/test_square.py
tests/st/ops/ascend/test_tbe_ops/test_square.py
+3
-3
tests/st/ops/ascend/test_tbe_ops/test_sub.py
tests/st/ops/ascend/test_tbe_ops/test_sub.py
+5
-5
tests/st/ops/ascend/test_tbe_ops/test_tile.py
tests/st/ops/ascend/test_tbe_ops/test_tile.py
+3
-3
tests/st/ops/cpu/test_addn_op.py
tests/st/ops/cpu/test_addn_op.py
+1
-1
tests/st/ops/cpu/test_conv2d_backprop_input_op.py
tests/st/ops/cpu/test_conv2d_backprop_input_op.py
+1
-1
tests/ut/python/ops/test_control_ops.py
tests/ut/python/ops/test_control_ops.py
+7
-5
tests/ut/python/ops/test_nn_ops.py
tests/ut/python/ops/test_nn_ops.py
+7
-7
tests/ut/python/ops/test_ops_attr_infer.py
tests/ut/python/ops/test_ops_attr_infer.py
+42
-57
tests/ut/python/pynative_mode/test_framstruct.py
tests/ut/python/pynative_mode/test_framstruct.py
+1
-1
未找到文件。
mindspore/ops/_op_impl/_custom_op/batch_matmul_impl.py
浏览文件 @
d3dbb10b
...
...
@@ -164,9 +164,10 @@ def CusBatchMatMul(input_x1, input_x2, output, transpose_a=False, transpose_b=Tr
matmul_hybrid_f_t_local_UB
=
tik_instance
.
Tensor
(
dtype
,
[
64
],
name
=
"matmul_hybrid_f_t_local_UB"
,
scope
=
tik
.
scope_ubuf
)
matmul_hybrid_f_t_local_UB_dst_tmp
=
tik_instance
.
Tensor
(
dtype
,
[
64
],
name
=
"matmul_hybrid_f_t_local_UB_dst_tmp"
,
scope
=
tik
.
scope_ubuf
)
matmul_hybrid_f_t_local_UB_dst_tmp
=
tik_instance
.
Tensor
(
dtype
,
[
64
],
name
=
"matmul_hybrid_f_t_local_UB_dst_tmp"
,
scope
=
tik
.
scope_ubuf
)
tik_instance
.
vector_dup
(
64
,
matmul_hybrid_f_t_local_UB
,
0
,
1
,
1
,
8
)
tik_instance
.
data_move
(
input_2_local_UB
,
input2
[(
block_idx
//
6
)
*
16384
+
thread_idx2
*
8192
],
0
,
1
,
...
...
mindspore/ops/_op_impl/_custom_op/matmul_cube_dense_left_impl.py
浏览文件 @
d3dbb10b
...
...
@@ -127,7 +127,7 @@ def _shape_check(shape_a, shape_b, shape_bias, src_dtype, trans_a, trans_b):
if
n_shape
%
cce
.
BLOCK_IN
!=
0
and
n_shape
!=
1
:
raise
RuntimeError
(
"input shape N should be 1 or multiple of %d"
%
cce
.
BLOCK_IN
)
if
len
(
shape_bias
)
!=
0
:
if
shape_bias
:
if
len
(
shape_bias
)
==
1
:
if
is_gevm
or
is_gemv
:
if
shape_bias
[
0
]
!=
m_shape
*
n_shape
:
...
...
@@ -189,7 +189,7 @@ def check_supported(input_x1, input_x2, bias=None, output_y={}, trans_a=False, t
util
.
check_shape_size
(
shape_b
,
SHAPE_SIZE_LIMIT
)
try
:
trans_a_f
=
bool
(
1
-
trans_a
)
if
src_dtype
==
"float32"
or
src_dtype
==
"int32"
:
if
src_dtype
in
(
"float32"
,
"int32"
)
:
if
len
(
shape_a
)
!=
2
and
len
(
shape_b
)
!=
2
:
return
False
if
trans_b
:
...
...
@@ -239,6 +239,7 @@ def check_supported(input_x1, input_x2, bias=None, output_y={}, trans_a=False, t
return
False
except
RuntimeError
as
e
:
print
(
e
)
return
False
return
True
...
...
@@ -385,7 +386,7 @@ def CusMatMulCubeDenseLeft(input_x1, input_x2, bias=None, output_y={}, trans_a=F
tensor_b
=
tvm
.
placeholder
(
shape_b_temp
,
name
=
'tensor_b'
,
dtype
=
src_dtype
)
if
len
(
shape_bias
)
>
0
:
if
shape_bias
:
tensor_bias
=
tvm
.
placeholder
(
shape_bias
,
name
=
'tensor_bias'
,
dtype
=
dst_dtype
)
...
...
@@ -449,20 +450,20 @@ def CusMatMulCubeDenseLeft(input_x1, input_x2, bias=None, output_y={}, trans_a=F
resMatmul_local_UB
,
0
,
16
,
224
//
2
,
0
,
56
*
16
*
2
//
2
)
tik_instance
.
BuildCCE
(
kernel_name
=
kernel_name
,
inputs
=
[
input_x1
,
input_x2
],
outputs
=
[
resMatmul
])
return
tik_instance
else
:
print
(
"come into tbe, shape is error!"
)
result
=
te
.
lang
.
cce
.
matmul
(
tensor_a
,
tensor_b
,
trans_a
,
trans_b
,
format_a
=
format_a
,
format_b
=
format_b
,
dst_dtype
=
dst_dtype
,
tensor_bias
=
tensor_bias
)
with
tvm
.
target
.
cce
():
schedule
=
generic
.
auto_schedule
(
result
)
print
(
"come into tbe, shape is error!"
)
result
=
te
.
lang
.
cce
.
matmul
(
tensor_a
,
tensor_b
,
trans_a
,
trans_b
,
format_a
=
format_a
,
format_b
=
format_b
,
dst_dtype
=
dst_dtype
,
tensor_bias
=
tensor_bias
)
with
tvm
.
target
.
cce
():
schedule
=
generic
.
auto_schedule
(
result
)
tensor_list
=
[
tensor_a
,
tensor_b
,
result
]
if
len
(
shape_bias
)
>
0
:
tensor_list
=
[
tensor_a
,
tensor_b
,
tensor_bias
,
result
]
tensor_list
=
[
tensor_a
,
tensor_b
,
result
]
if
shape_bias
:
tensor_list
=
[
tensor_a
,
tensor_b
,
tensor_bias
,
result
]
config
=
{
"print_ir"
:
False
,
"name"
:
kernel_name
,
"tensor_list"
:
tensor_list
}
config
=
{
"print_ir"
:
False
,
"name"
:
kernel_name
,
"tensor_list"
:
tensor_list
}
te
.
lang
.
cce
.
cce_build_code
(
schedule
,
config
)
te
.
lang
.
cce
.
cce_build_code
(
schedule
,
config
)
mindspore/ops/_op_impl/_custom_op/matmul_cube_fracz_left_cast_impl.py
浏览文件 @
d3dbb10b
...
...
@@ -124,7 +124,7 @@ src_dtype: str
if
n_shape
%
cce
.
BLOCK_IN
!=
0
and
n_shape
!=
1
:
raise
RuntimeError
(
"input shape N should be 1 or multiple of %d"
%
cce
.
BLOCK_IN
)
if
len
(
shape_bias
)
:
if
shape_bias
:
if
len
(
shape_bias
)
==
1
:
if
is_gevm
or
is_gemv
:
if
shape_bias
[
0
]
!=
m_shape
*
n_shape
:
...
...
@@ -144,11 +144,10 @@ def _get_bias(shape_bias):
bias_length
=
shape_bias
[
0
]
if
bias_length
%
16
==
0
:
return
shape_bias
else
:
bias_length
=
(
bias_length
//
16
)
*
16
+
16
shape_bias
=
[]
shape_bias
.
append
(
bias_length
)
return
shape_bias
bias_length
=
(
bias_length
//
16
)
*
16
+
16
shape_bias
=
[]
shape_bias
.
append
(
bias_length
)
return
shape_bias
def
_get_input_shape
(
shape_x
):
...
...
@@ -184,7 +183,7 @@ def check_supported(input_x1, input_x2, bias=None, output_y={}, trans_a=False, t
util
.
check_shape_size
(
shape_b
,
SHAPE_SIZE_LIMIT
)
try
:
trans_a_f
=
bool
(
1
-
trans_a
)
if
src_dtype
==
"float32"
or
src_dtype
==
"int32"
:
if
src_dtype
in
(
"floate32"
,
"int32"
)
:
if
len
(
shape_a
)
!=
2
and
len
(
shape_b
)
!=
2
:
return
False
if
trans_b
:
...
...
@@ -234,6 +233,7 @@ def check_supported(input_x1, input_x2, bias=None, output_y={}, trans_a=False, t
return
False
except
RuntimeError
as
e
:
print
(
e
)
return
False
return
True
...
...
mindspore/ops/_op_impl/_custom_op/matmul_cube_fracz_right_mul_impl.py
浏览文件 @
d3dbb10b
...
...
@@ -80,8 +80,8 @@ def CusMatMulCubeFraczRightMul(input_x1, input_x2, input_x3, bias=None, output_y
((
32
,
128
,
16
,
16
),
'float16'
,
(
32
,
32
,
16
,
16
),
'float16'
,
(
1
,),
'float32'
),
((
64
,
32
,
16
,
16
),
'float16'
,
(
64
,
64
,
16
,
16
),
'float16'
,
(
1
,),
'float32'
),
((
16
,
64
,
16
,
16
),
'float16'
,
(
16
,
16
,
16
,
16
),
'float16'
,
(
1
,),
'float32'
)]
input_shape
=
(
tuple
(
input_x1_shape
),
input_x1_dtype
,
tuple
(
input_x2_shape
),
input_x2_dtype
,
tuple
(
input_x3_shape
),
input_x3_dtype
)
input_shape
=
(
tuple
(
input_x1_shape
),
input_x1_dtype
,
tuple
(
input_x2_shape
),
input_x2_dtype
,
tuple
(
input_x3_shape
),
input_x3_dtype
)
if
input_shape
not
in
Supported
:
raise
RuntimeError
(
"input_shape %s is not supported"
%
str
(
input_shape
))
...
...
mindspore/ops/_op_impl/_custom_op/matmul_cube_impl.py
浏览文件 @
d3dbb10b
...
...
@@ -129,7 +129,7 @@ def _shape_check(shape_a, shape_b, shape_bias, src_dtype, trans_a, trans_b):
if
n_shape
%
cce
.
BLOCK_IN
!=
0
and
n_shape
!=
1
:
raise
RuntimeError
(
"input shape N should be 1 or multiple of %d"
%
cce
.
BLOCK_IN
)
if
len
(
shape_bias
)
:
if
shape_bias
:
if
len
(
shape_bias
)
==
1
:
if
is_gevm
or
is_gemv
:
if
shape_bias
[
0
]
!=
m_shape
*
n_shape
:
...
...
@@ -149,11 +149,10 @@ def _get_bias(shape_bias):
bias_length
=
shape_bias
[
0
]
if
bias_length
%
16
==
0
:
return
shape_bias
else
:
bias_length
=
(
bias_length
//
16
)
*
16
+
16
shape_bias
=
[]
shape_bias
.
append
(
bias_length
)
return
shape_bias
bias_length
=
(
bias_length
//
16
)
*
16
+
16
shape_bias
=
[]
shape_bias
.
append
(
bias_length
)
return
shape_bias
def
_get_input_shape
(
shape_x
):
...
...
@@ -189,7 +188,7 @@ def check_supported(input_x1, input_x2, bias=None, output_y={}, trans_a=False, t
util
.
check_shape_size
(
shape_b
,
SHAPE_SIZE_LIMIT
)
try
:
trans_a_f
=
bool
(
1
-
trans_a
)
if
src_dtype
==
"float32"
or
src_dtype
==
"int32"
:
if
src_dtype
in
(
"float32"
,
"int32"
)
:
if
len
(
shape_a
)
!=
2
and
len
(
shape_b
)
!=
2
:
return
False
if
trans_b
:
...
...
@@ -239,6 +238,7 @@ def check_supported(input_x1, input_x2, bias=None, output_y={}, trans_a=False, t
return
False
except
RuntimeError
as
e
:
print
(
e
)
return
False
return
True
...
...
@@ -314,7 +314,7 @@ def CusMatMulCube(input_x1, input_x2, bias=None, output_y={}, trans_a=False, tra
src_dtype
=
input_x1
.
get
(
"dtype"
).
lower
()
dst_dtype
=
output_y
.
get
(
"dtype"
).
lower
()
if
src_dtype
==
"float32"
or
src_dtype
==
"int32"
:
if
src_dtype
in
(
"float32"
,
"int32"
)
:
matmul_vector_cce
(
shape_a
,
shape_b
,
src_dtype
,
trans_a
,
trans_b
,
shape_bias
,
kernel_name
)
return
_shape_check
(
shape_a
,
shape_b
,
shape_bias
,
src_dtype
,
trans_a
,
trans_b
)
...
...
@@ -377,7 +377,7 @@ def CusMatMulCube(input_x1, input_x2, bias=None, output_y={}, trans_a=False, tra
tensor_b
=
tvm
.
placeholder
(
shape_b_temp
,
name
=
'tensor_b'
,
dtype
=
src_dtype
)
if
len
(
shape_bias
)
>
0
:
if
shape_bias
:
tensor_bias
=
tvm
.
placeholder
(
shape_bias
,
name
=
'tensor_bias'
,
dtype
=
dst_dtype
)
result
=
te
.
lang
.
cce
.
matmul
(
tensor_a
,
tensor_b
,
trans_a
,
trans_b
,
format_a
=
format_a
,
...
...
@@ -387,7 +387,7 @@ def CusMatMulCube(input_x1, input_x2, bias=None, output_y={}, trans_a=False, tra
schedule
=
generic
.
auto_schedule
(
result
)
tensor_list
=
[
tensor_a
,
tensor_b
,
result
]
if
len
(
shape_bias
)
>
0
:
if
shape_bias
:
tensor_list
=
[
tensor_a
,
tensor_b
,
tensor_bias
,
result
]
config
=
{
"print_ir"
:
False
,
...
...
tests/st/ops/ascend/test_ops_infer.py
浏览文件 @
d3dbb10b
...
...
@@ -16,17 +16,10 @@
import
functools
import
numpy
as
np
import
mindspore.nn
as
nn
import
mindspore.context
as
context
import
mindspore.common.dtype
as
mstype
from
mindspore
import
Tensor
,
Parameter
from
mindspore.common.initializer
import
initializer
from
mindspore.ops
import
Primitive
from
mindspore.ops
import
composite
as
C
from
mindspore
import
Tensor
from
mindspore.ops
import
operations
as
P
from
mindspore.ops
import
functional
as
F
from
mindspore.ops
import
prim_attr_register
,
PrimitiveWithInfer
from
mindspore.ops.primitive
import
constexpr
from
mindspore
import
context
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
save_graphs
=
True
)
...
...
@@ -38,7 +31,7 @@ def test_cast_op_attr():
self
.
cast
=
P
.
Cast
()
def
construct
(
self
,
x
,
t
):
return
self
.
cast
(
x
,
t
)
class
CastTypeTest
(
nn
.
Cell
):
def
__init__
(
self
,
net
):
super
(
CastTypeTest
,
self
).
__init__
()
...
...
@@ -54,9 +47,9 @@ def test_cast_op_attr():
t5
=
cast_net
(
z
,
mstype
.
float16
)
return
(
t1
,
t2
,
t3
,
t4
,
t5
)
net
=
CastTypeTest
(
CastNet
())
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
int32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
int32
))
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
int32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
int32
))
out
=
net
(
t1
,
t2
,
t3
)
assert
out
[
0
].
asnumpy
().
dtype
==
np
.
float32
assert
out
[
1
].
asnumpy
().
dtype
==
np
.
int32
...
...
tests/st/ops/ascend/test_tbe_ops/test_mul.py
浏览文件 @
d3dbb10b
...
...
@@ -33,13 +33,13 @@ class Net(nn.Cell):
return
self
.
mul
(
x1
,
x2
)
x1
=
np
.
random
.
randn
(
3
,
4
).
astype
(
np
.
float32
)
x2
=
np
.
random
.
randn
(
3
,
4
).
astype
(
np
.
float32
)
arr_
x1
=
np
.
random
.
randn
(
3
,
4
).
astype
(
np
.
float32
)
arr_
x2
=
np
.
random
.
randn
(
3
,
4
).
astype
(
np
.
float32
)
def
test_net
():
mul
=
Net
()
output
=
mul
(
Tensor
(
x1
),
Tensor
(
x2
))
print
(
x1
)
print
(
x2
)
output
=
mul
(
Tensor
(
arr_x1
),
Tensor
(
arr_
x2
))
print
(
arr_
x1
)
print
(
arr_
x2
)
print
(
output
.
asnumpy
())
tests/st/ops/ascend/test_tbe_ops/test_npu_clear_float_status.py
浏览文件 @
d3dbb10b
...
...
@@ -33,11 +33,11 @@ class Net(nn.Cell):
return
self
.
npu_clear_float_status
(
x1
)
x1
=
np
.
random
.
randn
(
8
).
astype
(
np
.
float32
)
arr_
x1
=
np
.
random
.
randn
(
8
).
astype
(
np
.
float32
)
def
test_net
():
npu_clear_float_status
=
Net
()
output
=
npu_clear_float_status
(
Tensor
(
x1
))
print
(
x1
)
output
=
npu_clear_float_status
(
Tensor
(
arr_
x1
))
print
(
arr_
x1
)
print
(
output
.
asnumpy
())
tests/st/ops/ascend/test_tbe_ops/test_npu_get_float_status.py
浏览文件 @
d3dbb10b
...
...
@@ -33,11 +33,11 @@ class Net(nn.Cell):
return
self
.
npu_get_float_status
(
x1
)
x1
=
np
.
random
.
randn
(
8
).
astype
(
np
.
float32
)
arr_
x1
=
np
.
random
.
randn
(
8
).
astype
(
np
.
float32
)
def
test_net
():
npu_get_float_status
=
Net
()
output
=
npu_get_float_status
(
Tensor
(
x1
))
print
(
x1
)
output
=
npu_get_float_status
(
Tensor
(
arr_
x1
))
print
(
arr_
x1
)
print
(
output
.
asnumpy
())
tests/st/ops/ascend/test_tbe_ops/test_pad.py
浏览文件 @
d3dbb10b
...
...
@@ -34,11 +34,11 @@ class Net(nn.Cell):
return
x
x
=
np
.
random
.
random
(
size
=
(
2
,
2
)).
astype
(
np
.
float32
)
arr_
x
=
np
.
random
.
random
(
size
=
(
2
,
2
)).
astype
(
np
.
float32
)
def
test_net
():
pad
=
Net
()
output
=
pad
(
Tensor
(
x
))
output
=
pad
(
Tensor
(
arr_
x
))
print
(
"=================output===================="
)
print
(
output
.
asnumpy
())
tests/st/ops/ascend/test_tbe_ops/test_realdiv.py
浏览文件 @
d3dbb10b
...
...
@@ -33,13 +33,13 @@ class Net(nn.Cell):
return
self
.
realdiv
(
x1
,
x2
)
x1
=
np
.
random
.
randn
(
3
,
4
).
astype
(
np
.
float32
)
x2
=
np
.
random
.
randn
(
3
,
4
).
astype
(
np
.
float32
)
arr_
x1
=
np
.
random
.
randn
(
3
,
4
).
astype
(
np
.
float32
)
arr_
x2
=
np
.
random
.
randn
(
3
,
4
).
astype
(
np
.
float32
)
def
test_net
():
realdiv
=
Net
()
output
=
realdiv
(
Tensor
(
x1
),
Tensor
(
x2
))
print
(
x1
)
print
(
x2
)
output
=
realdiv
(
Tensor
(
arr_x1
),
Tensor
(
arr_
x2
))
print
(
arr_
x1
)
print
(
arr_
x2
)
print
(
output
.
asnumpy
())
tests/st/ops/ascend/test_tbe_ops/test_reciprocal.py
浏览文件 @
d3dbb10b
...
...
@@ -33,11 +33,11 @@ class Net(nn.Cell):
return
self
.
reciprocal
(
x1
)
x1
=
np
.
random
.
randn
(
3
,
4
).
astype
(
np
.
float32
)
arr_
x1
=
np
.
random
.
randn
(
3
,
4
).
astype
(
np
.
float32
)
def
test_net
():
reciprocal
=
Net
()
output
=
reciprocal
(
Tensor
(
x1
))
print
(
x1
)
output
=
reciprocal
(
Tensor
(
arr_
x1
))
print
(
arr_
x1
)
print
(
output
.
asnumpy
())
tests/st/ops/ascend/test_tbe_ops/test_scatter_nd.py
浏览文件 @
d3dbb10b
...
...
@@ -31,13 +31,13 @@ class Net(nn.Cell):
return
self
.
scatternd
(
indices
,
update
,
(
3
,
3
))
indices
=
np
.
array
([[
0
,
1
],
[
1
,
1
]]).
astype
(
np
.
int32
)
update
=
np
.
array
([
3.2
,
1.1
]).
astype
(
np
.
float32
)
arr_
indices
=
np
.
array
([[
0
,
1
],
[
1
,
1
]]).
astype
(
np
.
int32
)
arr_
update
=
np
.
array
([
3.2
,
1.1
]).
astype
(
np
.
float32
)
def
test_net
():
scatternd
=
Net
()
print
(
indices
)
print
(
update
)
output
=
scatternd
(
Tensor
(
indices
),
Tensor
(
update
))
print
(
arr_
indices
)
print
(
arr_
update
)
output
=
scatternd
(
Tensor
(
arr_indices
),
Tensor
(
arr_
update
))
print
(
output
.
asnumpy
())
tests/st/ops/ascend/test_tbe_ops/test_softmax.py
浏览文件 @
d3dbb10b
...
...
@@ -31,11 +31,11 @@ class Net(nn.Cell):
return
self
.
Softmax
(
x
)
x
=
np
.
array
([[
5
,
1
]]).
astype
(
np
.
float32
)
arr_
x
=
np
.
array
([[
5
,
1
]]).
astype
(
np
.
float32
)
def
test_net
():
softmax
=
Net
()
output
=
softmax
(
Tensor
(
x
))
print
(
x
)
output
=
softmax
(
Tensor
(
arr_
x
))
print
(
arr_
x
)
print
(
output
.
asnumpy
())
tests/st/ops/ascend/test_tbe_ops/test_split.py
浏览文件 @
d3dbb10b
...
...
@@ -31,13 +31,13 @@ class Net(nn.Cell):
return
self
.
split
(
x
)
x
=
np
.
random
.
randn
(
2
,
4
).
astype
(
np
.
float32
)
arr_
x
=
np
.
random
.
randn
(
2
,
4
).
astype
(
np
.
float32
)
def
test_net
():
split
=
Net
()
output
=
split
(
Tensor
(
x
))
output
=
split
(
Tensor
(
arr_
x
))
print
(
"====input========"
)
print
(
x
)
print
(
arr_
x
)
print
(
"====output======="
)
print
(
output
)
tests/st/ops/ascend/test_tbe_ops/test_sqrt.py
浏览文件 @
d3dbb10b
...
...
@@ -31,11 +31,11 @@ class Net(nn.Cell):
return
self
.
sqrt
(
x
)
x
=
np
.
array
([
1.0
,
4.0
,
9.0
]).
astype
(
np
.
float32
)
arr_
x
=
np
.
array
([
1.0
,
4.0
,
9.0
]).
astype
(
np
.
float32
)
def
test_net
():
sqrt
=
Net
()
output
=
sqrt
(
Tensor
(
x
))
print
(
x
)
output
=
sqrt
(
Tensor
(
arr_
x
))
print
(
arr_
x
)
print
(
output
.
asnumpy
())
tests/st/ops/ascend/test_tbe_ops/test_square.py
浏览文件 @
d3dbb10b
...
...
@@ -31,11 +31,11 @@ class Net(nn.Cell):
return
self
.
square
(
x
)
x
=
np
.
array
([
1.0
,
4.0
,
9.0
]).
astype
(
np
.
float32
)
arr_
x
=
np
.
array
([
1.0
,
4.0
,
9.0
]).
astype
(
np
.
float32
)
def
test_net
():
square
=
Net
()
output
=
square
(
Tensor
(
x
))
print
(
x
)
output
=
square
(
Tensor
(
arr_
x
))
print
(
arr_
x
)
print
(
output
.
asnumpy
())
tests/st/ops/ascend/test_tbe_ops/test_sub.py
浏览文件 @
d3dbb10b
...
...
@@ -31,13 +31,13 @@ class Net(nn.Cell):
return
self
.
sub
(
x
,
y
)
x
=
np
.
random
.
randn
(
1
,
3
,
3
,
4
).
astype
(
np
.
float32
)
y
=
np
.
random
.
randn
(
1
,
3
,
3
,
4
).
astype
(
np
.
float32
)
arr_
x
=
np
.
random
.
randn
(
1
,
3
,
3
,
4
).
astype
(
np
.
float32
)
arr_
y
=
np
.
random
.
randn
(
1
,
3
,
3
,
4
).
astype
(
np
.
float32
)
def
test_net
():
sub
=
Net
()
output
=
sub
(
Tensor
(
x
),
Tensor
(
y
))
print
(
x
)
print
(
y
)
output
=
sub
(
Tensor
(
arr_x
),
Tensor
(
arr_
y
))
print
(
arr_
x
)
print
(
arr_
y
)
print
(
output
.
asnumpy
())
tests/st/ops/ascend/test_tbe_ops/test_tile.py
浏览文件 @
d3dbb10b
...
...
@@ -31,11 +31,11 @@ class Net(nn.Cell):
return
self
.
tile
(
x
,
(
1
,
4
))
x
=
np
.
array
([[
0
],
[
1
],
[
2
],
[
3
]]).
astype
(
np
.
int32
)
arr_
x
=
np
.
array
([[
0
],
[
1
],
[
2
],
[
3
]]).
astype
(
np
.
int32
)
def
test_net
():
tile
=
Net
()
print
(
x
)
output
=
tile
(
Tensor
(
x
))
print
(
arr_
x
)
output
=
tile
(
Tensor
(
arr_
x
))
print
(
output
.
asnumpy
())
tests/st/ops/cpu/test_addn_op.py
浏览文件 @
d3dbb10b
...
...
@@ -68,7 +68,7 @@ def test_net_3Input():
addn
=
Net3I
()
output
=
addn
(
Tensor
(
x
,
mstype
.
float32
),
Tensor
(
y
,
mstype
.
float32
),
Tensor
(
z
,
mstype
.
float32
))
print
(
"output:
\n
"
,
output
)
expect_result
=
[[
0.
,
3.
,
6.
],
expect_result
=
[[
0.
,
3.
,
6.
],
[
9.
,
12.
,
15
]]
assert
(
output
.
asnumpy
()
==
expect_result
).
all
()
...
...
tests/st/ops/cpu/test_conv2d_backprop_input_op.py
浏览文件 @
d3dbb10b
...
...
@@ -66,7 +66,7 @@ class Net5(nn.Cell):
def
test_conv2d_backprop_input
():
conv2d_input
=
Net5
()
output
=
conv2d_input
()
print
(
"================================"
)
print
(
"================================"
)
# expect output:
# [[[[ -5, -4, 5, 12, 0, -8]
# [-15, -6, 17, 17, -2, -11]
...
...
tests/ut/python/ops/test_control_ops.py
浏览文件 @
d3dbb10b
...
...
@@ -20,7 +20,6 @@ import mindspore as ms
from
mindspore
import
Tensor
from
mindspore
import
context
from
mindspore
import
nn
from
mindspore.common.parameter
import
Parameter
,
ParameterTuple
from
mindspore.ops
import
composite
as
C
from
mindspore.ops
import
functional
as
F
from
mindspore.ops
import
operations
as
P
...
...
@@ -447,11 +446,14 @@ def test_index_to_switch_layer():
def
test_control_depend_check
():
with
pytest
.
raises
(
TypeError
)
as
e
:
depend
=
P
.
ControlDepend
(
0.0
)
P
.
ControlDepend
(
0.0
)
print
(
e
)
with
pytest
.
raises
(
ValueError
)
as
e
:
depend
=
P
.
ControlDepend
(
2
)
P
.
ControlDepend
(
2
)
print
(
e
)
with
pytest
.
raises
(
TypeError
)
as
e
:
depend
=
P
.
ControlDepend
((
2
,))
P
.
ControlDepend
((
2
,))
print
(
e
)
def
test_if_nested_compile
():
...
...
@@ -497,7 +499,7 @@ def test_if_inside_for():
c1
=
Tensor
(
1
,
dtype
=
ms
.
int32
)
c2
=
Tensor
(
1
,
dtype
=
ms
.
int32
)
net
=
Net
()
out
=
net
(
c1
,
c2
)
net
(
c1
,
c2
)
def
test_while_in_while
():
...
...
tests/ut/python/ops/test_nn_ops.py
浏览文件 @
d3dbb10b
...
...
@@ -31,7 +31,6 @@ from ....mindspore_test_framework.pipeline.forward.compile_forward \
import
pipeline_for_compile_forward_ge_graph_for_case_by_case_config
from
....mindspore_test_framework.pipeline.forward.verify_exception
\
import
pipeline_for_verify_exception_for_case_by_case_config
from
mindspore
import
context
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
save_graphs
=
True
)
def
conv3x3
(
in_channels
,
out_channels
,
stride
=
1
,
padding
=
1
):
...
...
@@ -382,17 +381,18 @@ def test_conv2d_same_primitive():
class
Conv2DSameNet
(
nn
.
Cell
):
def
__init__
(
self
):
super
(
Conv2DSameNet
,
self
).
__init__
()
self
.
conv1
=
nn
.
Conv2d
(
16
,
64
,
(
1
,
41
),
(
1
,
4
),
"same"
,
0
,
1
,
has_bias
=
True
)
self
.
conv2
=
nn
.
Conv2d
(
16
,
64
,
(
1
,
41
),
(
1
,
4
),
"same"
,
0
,
1
,
has_bias
=
True
)
self
.
conv1
=
nn
.
Conv2d
(
16
,
64
,
(
1
,
41
),
(
1
,
4
),
"same"
,
0
,
1
,
has_bias
=
True
)
self
.
conv2
=
nn
.
Conv2d
(
16
,
64
,
(
1
,
41
),
(
1
,
4
),
"same"
,
0
,
1
,
has_bias
=
True
)
def
construct
(
self
,
x
,
y
):
r1
=
self
.
conv1
(
x
)
r2
=
self
.
conv2
(
y
)
return
(
r1
,
r2
)
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
net
=
Conv2DSameNet
()
out
=
net
(
t1
,
t2
)
net
(
t1
,
t2
)
class
ComparisonNet
(
nn
.
Cell
):
def
__init__
(
self
):
""" ComparisonNet definition """
...
...
tests/ut/python/ops/test_ops_attr_infer.py
浏览文件 @
d3dbb10b
...
...
@@ -13,30 +13,14 @@
# limitations under the License.
# ============================================================================
""" test nn ops """
import
functools
import
numpy
as
np
import
mindspore
import
mindspore.nn
as
nn
import
mindspore.context
as
context
import
mindspore.common.dtype
as
mstype
from
mindspore
import
Tensor
,
Parameter
from
mindspore.common.initializer
import
initializer
from
mindspore.ops
import
Primitive
from
mindspore.ops
import
composite
as
C
from
mindspore.ops
import
operations
as
P
from
mindspore
import
Tensor
from
mindspore.ops
import
functional
as
F
from
mindspore.ops
import
prim_attr_register
,
PrimitiveWithInfer
from
mindspore.ops.primitive
import
constexpr
from
..ut_filter
import
non_graph_engine
from
....mindspore_test_framework.mindspore_test
import
mindspore_test
from
....mindspore_test_framework.pipeline.forward.compile_forward
\
import
pipeline_for_compile_forward_ge_graph_for_case_by_case_config
from
....mindspore_test_framework.pipeline.forward.verify_exception
\
import
pipeline_for_verify_exception_for_case_by_case_config
from
mindspore
import
context
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
save_graphs
=
True
)
class
FakeOp
(
PrimitiveWithInfer
):
...
...
@@ -57,16 +41,16 @@ def test_conv2d_same_primitive():
class
Conv2DSameNet
(
nn
.
Cell
):
def
__init__
(
self
):
super
(
Conv2DSameNet
,
self
).
__init__
()
self
.
conv1
=
nn
.
Conv2d
(
16
,
64
,
(
1
,
41
),
(
1
,
4
),
"same"
,
0
,
1
,
has_bias
=
True
)
self
.
conv2
=
nn
.
Conv2d
(
16
,
64
,
(
1
,
41
),
(
1
,
4
),
"same"
,
0
,
1
,
has_bias
=
True
)
self
.
conv1
=
nn
.
Conv2d
(
16
,
64
,
(
1
,
41
),
(
1
,
4
),
"same"
,
0
,
1
,
has_bias
=
True
)
self
.
conv2
=
nn
.
Conv2d
(
16
,
64
,
(
1
,
41
),
(
1
,
4
),
"same"
,
0
,
1
,
has_bias
=
True
)
def
construct
(
self
,
x
,
y
):
r1
=
self
.
conv1
(
x
)
r2
=
self
.
conv2
(
y
)
return
(
r1
,
r2
)
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
net
=
Conv2DSameNet
()
out
=
net
(
t1
,
t2
)
net
(
t1
,
t2
)
# test cell as high order argument
# The graph with free variables used as argument is not supported yet
...
...
@@ -87,10 +71,10 @@ def Xtest_conv2d_op_with_arg():
a
=
self
.
opnet
(
conv_op
,
x
)
b
=
self
.
opnet
(
conv_op
,
y
)
return
(
a
,
b
)
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
net
=
OpsNet
(
Conv2dNet
())
out
=
net
(
t1
,
t2
)
net
(
t1
,
t2
)
def
test_conv2d_op_with_arg
():
...
...
@@ -115,11 +99,10 @@ def test_conv2d_op_with_arg():
a
=
self
.
opnet
(
op
,
x
,
y
)
b
=
self
.
opnet
(
op
,
y
,
x
)
return
(
a
,
b
)
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
net
=
OpsNet
(
OpNet
())
out
=
net
(
t1
,
t2
)
net
(
t1
,
t2
)
def
test_conv2d_op_with_arg_same_input
():
...
...
@@ -144,10 +127,10 @@ def test_conv2d_op_with_arg_same_input():
a
=
self
.
opnet
(
op
,
x
,
x
)
b
=
self
.
opnet
(
op
,
y
,
x
)
return
(
a
,
b
)
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
net
=
OpsNet
(
OpNet
())
out
=
net
(
t1
,
t2
)
net
(
t1
,
t2
)
# test op with partial
def
test_op_as_partial
():
...
...
@@ -160,11 +143,11 @@ def test_op_as_partial():
a
=
partial_op
(
y
)
b
=
partial_op
(
z
)
return
a
,
b
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1234
]).
astype
(
np
.
float32
))
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1234
]).
astype
(
np
.
float32
))
net
=
OpAsPartial
()
out
=
net
(
t1
,
t2
,
t3
)
net
(
t1
,
t2
,
t3
)
# test op with partial
def
test_op_as_partial_inside
():
...
...
@@ -182,13 +165,14 @@ def test_op_as_partial_inside():
super
(
OuterNet
,
self
).
__init__
()
self
.
net
=
OpAsPartial
()
def
construct
(
self
,
x
,
y
,
z
):
a
,
b
=
self
.
net
(
x
,
y
,
z
)
a
,
b
=
self
.
net
(
x
,
y
,
z
)
return
a
,
b
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1234
]).
astype
(
np
.
float32
))
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1234
]).
astype
(
np
.
float32
))
net
=
OuterNet
()
out
=
net
(
t1
,
t2
,
t3
)
net
(
t1
,
t2
,
t3
)
# test op with partial case 2
def
test_op_as_partial_independent
():
...
...
@@ -202,11 +186,12 @@ def test_op_as_partial_independent():
partial_op2
=
F
.
partial
(
self
.
op
,
x
)
b
=
partial_op2
(
z
)
return
a
,
b
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1234
]).
astype
(
np
.
float32
))
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1234
]).
astype
(
np
.
float32
))
net
=
OpAsPartial
()
out
=
net
(
t1
,
t2
,
t3
)
net
(
t1
,
t2
,
t3
)
def
test_nest_partial
():
class
NestPartial
(
nn
.
Cell
):
...
...
@@ -221,11 +206,11 @@ def test_nest_partial():
partial_op4
=
F
.
partial
(
partial_op3
,
x
)
b
=
partial_op4
(
z
)
return
a
,
b
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1234
]).
astype
(
np
.
float32
))
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1234
]).
astype
(
np
.
float32
))
net
=
NestPartial
()
out
=
net
(
t1
,
t2
,
t3
)
net
(
t1
,
t2
,
t3
)
# high order argument
# op and op args as network arguments
...
...
@@ -245,11 +230,11 @@ def test_op_with_arg_as_input():
a
=
self
.
opnet
(
op
,
x
,
z
)
b
=
self
.
opnet
(
op
,
x
,
y
)
return
(
a
,
b
)
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1234
]).
astype
(
np
.
float32
))
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1234
]).
astype
(
np
.
float32
))
net
=
OpsNet
(
WithOpArgNet
())
out
=
net
(
t1
,
t2
,
t3
)
net
(
t1
,
t2
,
t3
)
# The partial application used as argument is not supported yet
# because of the limit of inference specialize system
...
...
@@ -269,8 +254,8 @@ def Xtest_partial_as_arg():
a
=
self
.
partial_net
(
partial_op
,
z
)
b
=
self
.
partial_net
(
partial_op
,
y
)
return
(
a
,
b
)
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1234
]).
astype
(
np
.
float32
))
t1
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1918
]).
astype
(
np
.
float32
))
t2
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
3840
]).
astype
(
np
.
float32
))
t3
=
Tensor
(
np
.
ones
([
1
,
16
,
1
,
1234
]).
astype
(
np
.
float32
))
net
=
OpsNet
(
PartialArgNet
())
out
=
net
(
t1
,
t2
,
t3
)
net
(
t1
,
t2
,
t3
)
tests/ut/python/pynative_mode/test_framstruct.py
浏览文件 @
d3dbb10b
...
...
@@ -982,7 +982,7 @@ def test_bprop_with_wrong_output_shape():
@
bprop_getters
.
register
(
BpropWithWrongOutputShape
)
def
get_bprop_with_wrong_output_shape
(
self
):
"""Generate bprop for BpropWithWrongOutputShape"""
ones
=
Tensor
(
np
.
ones
([
2
,
]).
astype
(
np
.
int32
))
ones
=
Tensor
(
np
.
ones
([
2
,]).
astype
(
np
.
int32
))
def
bprop
(
x
,
out
,
dout
):
return
(
ones
,)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录