Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
akg
提交
403e8110
A
akg
项目概览
MindSpore
/
akg
通知
58
Star
7
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
akg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
403e8110
编写于
8月 04, 2020
作者:
L
lvwenyuan 00536823
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add env var to control whether dump gpu ir and cuda
上级
a8faeda6
变更
46
显示空白变更内容
内联
并排
Showing
46 changed file
with
118 addition
and
85 deletion
+118
-85
python/akg/composite/build_module.py
python/akg/composite/build_module.py
+2
-1
python/akg/ms/message.py
python/akg/ms/message.py
+4
-1
python/akg/ms/op_build.py
python/akg/ms/op_build.py
+1
-1
python/akg/ops/nn/maxpool.py
python/akg/ops/nn/maxpool.py
+1
-1
python/akg/ops/nn/maxpool_ad.py
python/akg/ops/nn/maxpool_ad.py
+2
-2
python/akg/utils/dump_cuda_meta.py
python/akg/utils/dump_cuda_meta.py
+13
-1
python/akg/utils/kernel_exec.py
python/akg/utils/kernel_exec.py
+44
-27
src/codegen/build_module.cc
src/codegen/build_module.cc
+2
-2
tests/common/test_op/add_a_conv.py
tests/common/test_op/add_a_conv.py
+1
-1
tests/common/test_op/add_b_conv.py
tests/common/test_op/add_b_conv.py
+1
-1
tests/common/test_op/col2im_compute.py
tests/common/test_op/col2im_compute.py
+1
-1
tests/common/test_op/gather.py
tests/common/test_op/gather.py
+1
-1
tests/common/test_op/im2col_compute.py
tests/common/test_op/im2col_compute.py
+1
-1
tests/common/test_op/reduce_max_ad.py
tests/common/test_op/reduce_max_ad.py
+1
-1
tests/common/test_op/reduce_min_ad.py
tests/common/test_op/reduce_min_ad.py
+1
-1
tests/common/test_op/vector_matmul.py
tests/common/test_op/vector_matmul.py
+1
-1
tests/common/test_run/IOU_for_train_run.py
tests/common/test_run/IOU_for_train_run.py
+1
-1
tests/common/test_run/avgpool_ad_run.py
tests/common/test_run/avgpool_ad_run.py
+2
-2
tests/common/test_run/bounding_box_encode_run.py
tests/common/test_run/bounding_box_encode_run.py
+2
-2
tests/common/test_run/conv_filter_ad_run.py
tests/common/test_run/conv_filter_ad_run.py
+1
-1
tests/common/test_run/conv_run_mansch.py
tests/common/test_run/conv_run_mansch.py
+1
-1
tests/common/test_run/distr_bernoulli_logprob_ad_run.py
tests/common/test_run/distr_bernoulli_logprob_ad_run.py
+1
-1
tests/common/test_run/distr_bernoulli_logprob_run.py
tests/common/test_run/distr_bernoulli_logprob_run.py
+1
-1
tests/common/test_run/distr_normal_diag_KLdiv_ad_run.py
tests/common/test_run/distr_normal_diag_KLdiv_ad_run.py
+1
-1
tests/common/test_run/distr_normal_diag_KLdiv_run.py
tests/common/test_run/distr_normal_diag_KLdiv_run.py
+1
-1
tests/common/test_run/distr_normal_diag_logprob_ad_run.py
tests/common/test_run/distr_normal_diag_logprob_ad_run.py
+1
-1
tests/common/test_run/distr_normal_diag_logprob_run.py
tests/common/test_run/distr_normal_diag_logprob_run.py
+1
-1
tests/common/test_run/distr_normal_diag_sample_ad_run.py
tests/common/test_run/distr_normal_diag_sample_ad_run.py
+1
-1
tests/common/test_run/distr_normal_diag_sample_run.py
tests/common/test_run/distr_normal_diag_sample_run.py
+1
-1
tests/common/test_run/distr_normal_prob_regr_train_run.py
tests/common/test_run/distr_normal_prob_regr_train_run.py
+1
-1
tests/common/test_run/dropout_run.py
tests/common/test_run/dropout_run.py
+1
-1
tests/common/test_run/kldiv_loss_grad_run.py
tests/common/test_run/kldiv_loss_grad_run.py
+2
-2
tests/common/test_run/l1_loss_grad_run.py
tests/common/test_run/l1_loss_grad_run.py
+2
-2
tests/common/test_run/matmul_run_mansch.py
tests/common/test_run/matmul_run_mansch.py
+1
-1
tests/common/test_run/maxpool_ad_run.py
tests/common/test_run/maxpool_ad_run.py
+3
-3
tests/common/test_run/maxpool_grad_run.py
tests/common/test_run/maxpool_grad_run.py
+2
-2
tests/common/test_run/maxpool_grad_with_argmax_run.py
tests/common/test_run/maxpool_grad_with_argmax_run.py
+2
-2
tests/common/test_run/nms_run.py
tests/common/test_run/nms_run.py
+1
-1
tests/common/test_run/roipool_run.py
tests/common/test_run/roipool_run.py
+1
-1
tests/common/test_run/smooth_l1_loss_grad_run.py
tests/common/test_run/smooth_l1_loss_grad_run.py
+2
-2
tests/common/test_run/square_difference_run.py
tests/common/test_run/square_difference_run.py
+1
-1
tests/common/test_run/strided_slice_grad_run.py
tests/common/test_run/strided_slice_grad_run.py
+1
-1
tests/common/test_run/truncatemod_run.py
tests/common/test_run/truncatemod_run.py
+2
-2
tests/common/test_run/vector_matmul_run.py
tests/common/test_run/vector_matmul_run.py
+1
-1
tests/common/test_run/winograd_ad_run.py
tests/common/test_run/winograd_ad_run.py
+2
-2
tests/operators/cube/quant_conv.py
tests/operators/cube/quant_conv.py
+1
-1
未找到文件。
python/akg/composite/build_module.py
浏览文件 @
403e8110
...
...
@@ -176,7 +176,8 @@ def build_cuda(outputs, args, sch_name, kernel_name):
}
with
tvm
.
target
.
cuda
()
as
cuda
:
s
=
scheduler
[
sch_name
](
outputs
)
with
tvm
.
build_config
(
dump_pass_ir
=
True
):
dump_ir
=
os
.
getenv
(
'MS_AKG_DUMP_IR'
)
==
"on"
with
tvm
.
build_config
(
dump_pass_ir
=
dump_ir
):
mod
=
tvm
.
build
(
s
,
args
,
cuda
,
name
=
kernel_name
)
dump_cuda_meta
.
dump
(
mod
,
kernel_name
,
s
,
list
(
args
))
return
mod
python/akg/ms/message.py
浏览文件 @
403e8110
...
...
@@ -82,7 +82,10 @@ def compilewithjson_to_func(json_str):
if
kernel_info
[
'attr'
]:
for
ext_arg
in
kernel_info
[
'attr'
]:
op_attrs
.
append
(
ext_arg
[
'value'
])
mod
=
utils
.
op_build
(
op_func
,
input_shapes
,
input_types
,
op_attrs
,
kernel_info
[
'op'
])
dump_ir
=
os
.
getenv
(
'MS_AKG_DUMP_IR'
)
==
"on"
dump_code
=
os
.
getenv
(
'MS_AKG_DUMP_CODE'
)
==
"on"
mod
=
utils
.
op_build
(
op_func
,
input_shapes
,
input_types
,
op_attrs
,
kernel_info
[
'op'
],
dump_ir
=
dump_ir
,
dump_code
=
dump_code
)
return
True
else
:
op_func
=
getattr
(
cce
,
op_name
,
None
)
...
...
python/akg/ms/op_build.py
浏览文件 @
403e8110
...
...
@@ -31,7 +31,7 @@ from akg.utils import validation_check as vc_util
BINDS
=
"binds"
MS_AKG_DUMP_IR
=
"MS_AKG_DUMP_IR"
MS_AKG_DUMP_C
CE
=
"MS_AKG_DUMP_CC
E"
MS_AKG_DUMP_C
ODE
=
"MS_AKG_DUMP_COD
E"
MS_DAVINCI_KERNEL_PATH
=
"./kernel_meta/"
...
...
python/akg/ops/nn/maxpool.py
浏览文件 @
403e8110
...
...
@@ -294,7 +294,7 @@ def maxpool_manual_schedule(shape, kernel, stride, padding, dtype, attrs=None, p
mod
=
akg
.
build
(
s
,
[
data
,
res
],
"cce"
,
name
=
"maxpool_manual_schedule"
,
attrs
=
attrs
,
polyhedral
=
polyhedral
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
kernel_name
=
"maxpool_ad_manual_schedule"
utils
.
create_c
c
e
(
kernel_name
,
'./'
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
'./'
,
source_code
)
return
mod
def
pad_strategy_check
(
strategy
):
...
...
python/akg/ops/nn/maxpool_ad.py
浏览文件 @
403e8110
...
...
@@ -387,7 +387,7 @@ def maxpool_ad_manual_schedule_all_max(shape, kernel, stride, pad, dtype, polyhe
attrs
=
attrs
,
polyhedral
=
polyhedral
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
kernel_name
=
"maxpool_ad_manual_schedule_all_max"
utils
.
create_c
c
e
(
kernel_name
,
'./'
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
'./'
,
source_code
)
return
mod
...
...
@@ -489,5 +489,5 @@ def maxpool_ad_manual_schedule_no_overlap_all_max(shape, kernel, stride, pad, dt
name
=
"maxpool_ad_manual_schedule_no_overlap_all_max"
,
attrs
=
attrs
,
polyhedral
=
polyhedral
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
kernel_name
=
"maxpool_ad_manual_schedule_no_overlap_all_max"
utils
.
create_c
c
e
(
kernel_name
,
'./'
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
'./'
,
source_code
)
return
mod
python/akg/utils/dump_cuda_meta.py
浏览文件 @
403e8110
...
...
@@ -64,6 +64,18 @@ def save_gpu_params(s, args, kernel_info):
ptx_code
=
kernel_info
[
0
]
file_name
=
kernel_info
[
1
]
kernel_name
=
kernel_info
[
2
]
dump_ir
=
os
.
getenv
(
'MS_AKG_DUMP_IR'
)
==
"on"
if
dump_ir
:
schedule_path
=
os
.
path
.
realpath
(
kernel_name
)
all_passes
=
os
.
listdir
(
schedule_path
)
for
cur_pass
in
all_passes
:
if
cur_pass
.
startswith
(
"00_"
):
with
open
(
schedule_path
+
'/'
+
cur_pass
,
"r"
)
as
file
:
ir
=
file
.
read
()
break
else
:
ir
=
str
(
akg
.
tvm
.
lower
(
s
,
args
,
simple_mode
=
True
))
file_path
=
os
.
path
.
realpath
(
file_name
)
if
os
.
path
.
exists
(
file_path
):
...
...
python/akg/utils/kernel_exec.py
浏览文件 @
403e8110
...
...
@@ -67,23 +67,35 @@ def func_time_required(func_name):
return
wrapper
def
create_c
ce
(
kernel_name
,
cce_path
=
None
,
code
=
None
):
def
create_c
ode
(
kernel_name
,
code_path
=
None
,
code
=
None
,
code_type
=
"CCE"
):
"""
Create cce file.
Create cce
or cuda
file.
Args:
kernel_name: cce file name.
cce_path: cce file path.
code: cce code.
kernel_name: file name.
code_path: file path.
code: code.
code_type: code type.
"""
if
cce_path
:
if
len
(
cce_path
)
>
4
and
cce_path
[
-
4
:].
lower
()
==
".cce"
:
real_path
=
cce_path
if
code_type
==
"CCE"
:
postfix
=
".cce"
elif
code_type
==
"CUDA"
:
postfix
=
".cu"
else
:
if
cce_path
[
-
1
]
==
r
"/"
:
real_path
=
cce_path
+
kernel_name
+
".cce"
logging
.
info
(
"the target code type %s is not supported."
,
code_type
)
if
not
code_path
:
code_path
=
"./"
if
code_type
==
"CCE"
and
len
(
code_path
)
>
4
and
code_path
[
-
4
:].
lower
()
==
postfix
:
real_path
=
code_path
elif
code_type
==
"CUDA"
and
len
(
code_path
)
>
3
and
code_path
[
-
3
:].
lower
()
==
postfix
:
real_path
=
code_path
else
:
if
code_path
[
-
1
]
==
r
"/"
:
real_path
=
code_path
+
kernel_name
+
postfix
else
:
real_path
=
cce_path
+
r
"/"
+
kernel_name
+
".cce"
real_path
=
code_path
+
r
"/"
+
kernel_name
+
postfix
dir_path
=
r
"/"
.
join
(
real_path
.
split
(
r
"/"
)[:
-
1
])
if
not
os
.
path
.
isdir
(
dir_path
):
os
.
makedirs
(
dir_path
)
...
...
@@ -92,6 +104,7 @@ def create_cce(kernel_name, cce_path=None, code=None):
ss
.
write
(
code
)
def
gen_name_kernel
(
kernel
,
dtype
,
shapes
):
"""generate kernel name."""
def
_flat_array
(
srclist
,
dstlist
):
...
...
@@ -538,7 +551,7 @@ def gen_kernel_name(input_shapes, input_types, op_attrs=None, kernel_name=""):
@
func_time_required
def
op_build_test
(
op_func
,
input_shapes
,
input_types
,
op_attrs
=
None
,
kernel_name
=
""
,
attrs
=
None
,
log_cce
=
False
,
dump_ir
=
True
,
dump_c
c
e
=
True
,
attrs
=
None
,
log_cce
=
False
,
dump_ir
=
True
,
dump_c
od
e
=
True
,
polyhedral
=
True
,
tuning
=
False
):
"""
Return module from op_build with given inputs, distinguish tuning mode.
...
...
@@ -552,7 +565,7 @@ def op_build_test(op_func, input_shapes, input_types, op_attrs=None, kernel_name
attrs (dict): tiling parameter.
log_cce (bool): False by default.
dump_ir (bool): True by default.
dump_c
c
e (bool): False by default.
dump_c
od
e (bool): False by default.
polyhedral (bool): True by default.
tuning (bool): False by default.
...
...
@@ -565,7 +578,7 @@ def op_build_test(op_func, input_shapes, input_types, op_attrs=None, kernel_name
kernel_name
=
gen_kernel_name
(
input_shapes
,
input_types
,
op_attrs
,
kernel_name
)
logging
.
debug
(
'kernel_name---------- %s'
,
str
(
kernel_name
))
mod
=
op_build
(
op_func
,
input_shapes
,
input_types
,
op_attrs
,
kernel_name
,
attrs
,
log_cce
,
dump_ir
,
dump_c
c
e
,
attrs
,
log_cce
,
dump_ir
,
dump_c
od
e
,
polyhedral
,
tuning
)
return
mod
...
...
@@ -593,7 +606,7 @@ def recursive_copy(obj):
def
op_build
(
op_func
,
input_shapes
,
input_types
,
op_attrs
=
None
,
kernel_name
=
""
,
attrs
=
None
,
log_cce
=
False
,
dump_ir
=
True
,
dump_c
c
e
=
True
,
attrs
=
None
,
log_cce
=
False
,
dump_ir
=
True
,
dump_c
od
e
=
True
,
polyhedral
=
True
,
tuning
=
False
):
"""
Return module built from op_func with given inputs.
...
...
@@ -607,7 +620,7 @@ def op_build(op_func, input_shapes, input_types, op_attrs=None, kernel_name="",
attrs (dict): tiling parameter.
log_cce (bool): False by default.
dump_ir (bool): True by default.
dump_c
c
e (bool): False by default.
dump_c
od
e (bool): False by default.
polyhedral (bool): True by default.
tuning (bool): False by default.
...
...
@@ -730,9 +743,13 @@ def op_build(op_func, input_shapes, input_types, op_attrs=None, kernel_name="",
kernel_name
=
kernel_name
if
kernel_name
!=
""
else
sch_tmpl
[
'op_name'
]
with
akg
.
tvm
.
target
.
cuda
()
as
target
:
s
=
sch_tmpl
[
'schedule'
](
sch_tmpl
[
'output'
])
with
akg
.
build_config
(
dump_pass_ir
=
True
):
mod
=
akg
.
build
(
s
,
op_var
,
"cuda"
,
shape_var
,
name
=
kernel_name
,
attrs
=
attrs
,
polyhedral
=
polyhedral
,
binds
=
binds
)
with
akg
.
tvm
.
build_config
(
dump_pass_ir
=
dump_ir
):
mod
=
akg
.
build
(
s
,
op_var
,
"cuda"
,
shape_var
,
name
=
kernel_name
,
attrs
=
attrs
,
polyhedral
=
polyhedral
,
binds
=
binds
)
dump_cuda_meta
.
dump
(
mod
,
kernel_name
,
s
,
op_var
)
if
dump_code
:
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
create_code
(
kernel_name
,
"./"
,
source_code
,
"CUDA"
)
return
mod
if
isinstance
(
output
,
(
list
,
tuple
)):
...
...
@@ -781,9 +798,9 @@ def op_build(op_func, input_shapes, input_types, op_attrs=None, kernel_name="",
if
log_cce
:
logging
.
debug
(
"#################cce code####################"
)
logging
.
debug
(
source_code
)
if
dump_c
c
e
:
c
c
e_path
=
"./"
create_c
ce
(
kernel_name
,
cc
e_path
,
source_code
)
if
dump_c
od
e
:
c
od
e_path
=
"./"
create_c
ode
(
kernel_name
,
cod
e_path
,
source_code
)
return
mod
...
...
src/codegen/build_module.cc
浏览文件 @
403e8110
...
...
@@ -1110,8 +1110,8 @@ air::runtime::Module BuildToModule(const NodeRef &ref, const std::string &target
mhost
.
Import
(
mdev
);
}
const
char
*
akg_dump_c
ce
=
getenv
(
"MS_AKG_DUMP_CC
E"
);
if
(
akg_dump_c
c
e
!=
nullptr
)
{
const
char
*
akg_dump_c
ode
=
getenv
(
"MS_AKG_DUMP_COD
E"
);
if
(
akg_dump_c
od
e
!=
nullptr
)
{
auto
mod0
=
mhost
->
imports
()[
0
];
CHECK
(
mod0
.
defined
());
...
...
tests/common/test_op/add_a_conv.py
浏览文件 @
403e8110
...
...
@@ -207,7 +207,7 @@ def add_a_conv(fmap_shape, filter_shape, pad_, stride_, dilation_,
mod
=
akg
.
build
(
s
,
[
a_value
,
b_value
,
conv
],
"cce"
,
name
=
kernel_name
,
attrs
=
attrs
,
polyhedral
=
True
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
cce_path
=
'.'
utils
.
create_c
c
e
(
kernel_name
,
cce_path
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
cce_path
,
source_code
)
return
mod
...
...
tests/common/test_op/add_b_conv.py
浏览文件 @
403e8110
...
...
@@ -201,7 +201,7 @@ def add_b_conv(fmap_shape, filter_shape, pad_, stride_, dilation_,
mod
=
akg
.
build
(
s
,
[
a_value
,
b_value
,
conv
],
"cce"
,
name
=
kernel_name
,
attrs
=
attrs
,
polyhedral
=
True
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
cce_path
=
'.'
utils
.
create_c
c
e
(
kernel_name
,
cce_path
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
cce_path
,
source_code
)
return
mod
...
...
tests/common/test_op/col2im_compute.py
浏览文件 @
403e8110
...
...
@@ -64,5 +64,5 @@ def col2im_manual_schedule(shape, kernel, stride, pad, dtype, output_H_W, polyhe
mod
=
akg
.
build
(
s
,
[
data
,
res
],
"cce"
,
name
=
"col2im_manual_schedule"
,
attrs
=
attrs
,
polyhedral
=
polyhedral
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
kernel_name
=
"col2im_manual_schedule"
utils
.
create_c
c
e
(
kernel_name
,
"./"
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
"./"
,
source_code
)
return
mod
tests/common/test_op/gather.py
浏览文件 @
403e8110
...
...
@@ -115,6 +115,6 @@ def gather(params_shape, indices_shape, params_dtype, indices_dtype, axis, kerne
mod
=
akg
.
build
(
s
,
[
xx
,
yy
,
res
],
"cce"
,
name
=
kernel_name
,
attrs
=
attrs
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
utils
.
create_c
c
e
(
kernel_name
,
cce_path
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
cce_path
,
source_code
)
return
mod
tests/common/test_op/im2col_compute.py
浏览文件 @
403e8110
...
...
@@ -109,5 +109,5 @@ def im2col_manual_schedule(shape, kernel, stride, pad, dtype, polyhedral=True, a
attrs
=
attrs
,
polyhedral
=
polyhedral
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
kernel_name
=
"im2col_manual_schedule"
utils
.
create_c
c
e
(
kernel_name
,
'./'
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
'./'
,
source_code
)
return
mod
tests/common/test_op/reduce_max_ad.py
浏览文件 @
403e8110
...
...
@@ -200,5 +200,5 @@ def reduce_max_ad_optimized_manual_schedule(input_shape, dtype, axis, keepdims,
name
=
"reduce_max_ad_manual_schedule"
,
attrs
=
attrs
,
polyhedral
=
polyhedral
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
kernel_name
=
"reduce_max_ad_manual_schedule"
utils
.
create_c
c
e
(
kernel_name
,
'./'
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
'./'
,
source_code
)
return
mod
tests/common/test_op/reduce_min_ad.py
浏览文件 @
403e8110
...
...
@@ -159,5 +159,5 @@ def reduce_min_ad_optimized_manual_schedule(input_shape, dtype, axis, keepdims,
attrs
=
attrs
,
polyhedral
=
polyhedral
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
kernel_name
=
"reduce_min_ad_manual_schedule"
utils
.
create_c
c
e
(
kernel_name
,
'./'
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
'./'
,
source_code
)
return
mod
tests/common/test_op/vector_matmul.py
浏览文件 @
403e8110
...
...
@@ -105,5 +105,5 @@ def vector_matmul(data_m, data_n, data_k, trans_a, trans_b, dtype, kernel_name,
with
akg
.
build_config
(
add_lower_pass
=
cce
.
debug_mode
(
0
),
dump_pass_ir
=
True
):
mod
=
akg
.
build
(
forward_s
,
op_vars
,
"cce"
,
name
=
kernel_name
,
attrs
=
attrs
,
polyhedral
=
True
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
utils
.
create_c
c
e
(
kernel_name
,
"./"
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
"./"
,
source_code
)
return
mod
,
output_shape
tests/common/test_run/IOU_for_train_run.py
浏览文件 @
403e8110
...
...
@@ -81,7 +81,7 @@ def iou_for_train_run(shape_tensor,
output
=
utils
.
mod_launch
(
mod
,
(
anchor
,
ground_truth
,
output
),
expect
=
expect
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
utils
.
create_c
c
e
(
kernel_name
,
"./"
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
"./"
,
source_code
)
return
input
,
output
,
expect
,
compare_tensor
(
output
,
expect
,
rtol
=
5e-03
,
equal_nan
=
True
)
...
...
tests/common/test_run/avgpool_ad_run.py
浏览文件 @
403e8110
...
...
@@ -41,7 +41,7 @@ def avgpool_ad_run(shape, kernel, stride, pad, dtype, polyhedral=False, attrs=No
input
=
random_gaussian
(
shape
,
miu
=
1
,
sigma
=
0.1
).
astype
(
support_list
[
dtype
])
y
=
avgpool_run
.
benchmark
(
input
,
kernel
,
stride
,
pad
)
mod
=
utils
.
op_build_test
(
avgpool
,
[
y
.
shape
,
shape
],
[
dtype
,
dtype
],
op_attrs
=
[
kernel
,
stride
,
pad
],
kernel_name
=
kernel_name
,
attrs
=
attrs
,
log_cce
=
True
,
dump_c
c
e
=
True
,
tuning
=
t
)
kernel_name
=
kernel_name
,
attrs
=
attrs
,
log_cce
=
True
,
dump_c
od
e
=
True
,
tuning
=
t
)
if
t
:
expect
,
head
,
output
=
gen_data
(
dtype
,
input
,
kernel
,
pad
,
stride
,
support_list
,
y
)
return
mod
,
expect
,
(
head
,
input
,
output
)
...
...
@@ -51,7 +51,7 @@ def avgpool_ad_run(shape, kernel, stride, pad, dtype, polyhedral=False, attrs=No
input
=
random_gaussian
(
shape
,
miu
=
1
,
sigma
=
0.1
).
astype
(
support_list
[
dtype
])
y
=
avgpool_run
.
benchmark
(
input
,
kernel
,
stride
,
pad
)
mod
=
utils
.
op_build_test
(
avgpool
,
[
y
.
shape
,
shape
],
[
dtype
,
dtype
],
op_attrs
=
[
kernel
,
stride
,
pad
],
kernel_name
=
kernel_name
,
attrs
=
attrs
,
log_cce
=
True
,
dump_c
c
e
=
True
)
kernel_name
=
kernel_name
,
attrs
=
attrs
,
log_cce
=
True
,
dump_c
od
e
=
True
)
expect
,
head
,
output
=
gen_data
(
dtype
,
input
,
kernel
,
pad
,
stride
,
support_list
,
y
)
output
=
utils
.
mod_launch
(
mod
,
[
head
,
input
,
output
],
expect
=
expect
)
...
...
tests/common/test_run/bounding_box_encode_run.py
浏览文件 @
403e8110
...
...
@@ -197,7 +197,7 @@ def bounding_box_encode_run(anchor_box_shape, groundtruth_box_shape, anchor_samp
mod
=
utils
.
op_build_test
(
bounding_box_encode
.
bouding_box_encode
,
[
anchor_box_shape
,
groundtruth_box_shape
,
anchor_samples_shape
],
[
dtype
,
dtype
,
"int32"
],
op_attrs
,
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
c
e
=
True
,
tuning
=
t
)
op_attrs
,
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
od
e
=
True
,
tuning
=
t
)
if
t
:
anchor_box_data
,
anchor_samples_data
,
expect
,
groundtruth_box_data
,
output_data
=
gen_data
(
anchor_box_shape
,
anchor_samples_shape
,
...
...
@@ -211,7 +211,7 @@ def bounding_box_encode_run(anchor_box_shape, groundtruth_box_shape, anchor_samp
mod
=
utils
.
op_build_test
(
bounding_box_encode
.
bouding_box_encode
,
[
anchor_box_shape
,
groundtruth_box_shape
,
anchor_samples_shape
],
[
dtype
,
dtype
,
"int32"
],
op_attrs
,
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
c
e
=
True
)
op_attrs
,
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
od
e
=
True
)
anchor_box_data
,
anchor_samples_data
,
expect
,
groundtruth_box_data
,
output_data
=
gen_data
(
anchor_box_shape
,
anchor_samples_shape
,
dtype
,
epsilon
,
...
...
tests/common/test_run/conv_filter_ad_run.py
浏览文件 @
403e8110
...
...
@@ -192,7 +192,7 @@ def conv_filter_ad_run(fmap_shape, filter_shape, pad_, stride_, dilation_, attr
return
np_input
,
out_data
,
expect
,
True
mod
=
utils
.
op_build_test
(
conv_filter_ad
.
conv_filter_ad
,
[
dw_input_shapes
],
[
conv_dtype
],
op_attrs
=
[
fmap_shape
,
filter_shape
,
pad_
,
stride_
,
dilation_
],
kernel_name
=
'conv_filter_ad'
,
attrs
=
attrs
,
dump_c
c
e
=
True
)
op_attrs
=
[
fmap_shape
,
filter_shape
,
pad_
,
stride_
,
dilation_
],
kernel_name
=
'conv_filter_ad'
,
attrs
=
attrs
,
dump_c
od
e
=
True
)
args
=
(
dy_data
,
dx_data
,
out_data
)
out_data
=
utils
.
mod_launch
(
mod
,
args
,
expect
=
expect
)
rtol
,
atol
=
get_rtol_atol
(
"conv_filter_ad"
,
conv_dtype
)
...
...
tests/common/test_run/conv_run_mansch.py
浏览文件 @
403e8110
...
...
@@ -34,7 +34,7 @@ def conv_run_mansch(FMap_shape, Filter_shape, Pad, Stride, Dilation=None, use_bi
use_bias
=
use_bias
,
fp32_mad
=
fp32_mad
,
kernel_name
=
"conv_mansch"
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
utils
.
create_c
c
e
(
"conv_mansch"
,
"."
,
source_code
)
utils
.
create_c
od
e
(
"conv_mansch"
,
"."
,
source_code
)
A
,
B
,
bias_data
,
expect
=
gen_data
(
FMap_shape
,
Filter_shape
,
Pad
,
Stride
,
Dilation
,
use_bias
)
expect
=
expect
.
reshape
((
expect
.
shape
[
0
],
expect
.
shape
[
1
],
expect
.
shape
[
2
]
*
expect
.
shape
[
3
],
expect
.
shape
[
4
]))
# output on conv2d is in 4d format
...
...
tests/common/test_run/distr_bernoulli_logprob_ad_run.py
浏览文件 @
403e8110
...
...
@@ -26,7 +26,7 @@ def logprob_ad_run(shape, dtype, kernel_name="", attrs=None):
mod
=
utils
.
op_build_test
(
distr_bernoulli_logprob_ad
.
bernoulli_logprob_ad
,
[
head
.
shape
,
x
.
shape
,
probs
.
shape
],
[
dtype
,
dtype
,
dtype
],
kernel_name
=
kernel_name
,
op_attrs
=
None
,
attrs
=
None
,
log_cce
=
True
,
dump_c
c
e
=
True
,
polyhedral
=
True
)
op_attrs
=
None
,
attrs
=
None
,
log_cce
=
True
,
dump_c
od
e
=
True
,
polyhedral
=
True
)
outputs
=
utils
.
mod_launch
(
mod
,
[
head
,
x
,
probs
,
*
outputs
],
outputs
=
tuple
(
range
(
-
len
(
outputs
),
0
)),
expect
=
expects
)
outputs
=
list
(
outputs
)
...
...
tests/common/test_run/distr_bernoulli_logprob_run.py
浏览文件 @
403e8110
...
...
@@ -29,7 +29,7 @@ def log_prob_run(shape, dtype, kernelname="", attrs = None):
mod
=
utils
.
op_build_test
(
log_prob_op
,
[
x
.
shape
,
probs
.
shape
],
[
dtype
,
dtype
],
kernel_name
=
kernelname
,
op_attrs
=
[],
attrs
=
None
,
log_cce
=
True
,
dump_c
c
e
=
True
,
polyhedral
=
True
)
op_attrs
=
[],
attrs
=
None
,
log_cce
=
True
,
dump_c
od
e
=
True
,
polyhedral
=
True
)
output
=
utils
.
mod_launch
(
mod
,
[
x
,
probs
,
output
],
expect
=
expect
)
return
(
x
,
probs
),
output
,
expect
,
compare_tensor
(
output
,
expect
,
rtol
=
1e-03
,
atol
=
1e-03
,
equal_nan
=
True
)
...
...
tests/common/test_run/distr_normal_diag_KLdiv_ad_run.py
浏览文件 @
403e8110
...
...
@@ -25,7 +25,7 @@ def KLdiv_ad_run(shape, dtype, kernel_name="", attrs=None):
mod
=
utils
.
op_build_test
(
distr_normal_diag_KLdiv_ad
.
normal_diag_KLdiv_ad
,
[
head
.
shape
,
mean
.
shape
,
scale
.
shape
],
[
dtype
,
dtype
,
dtype
],
kernel_name
=
kernel_name
,
op_attrs
=
None
,
attrs
=
None
,
log_cce
=
True
,
dump_c
c
e
=
True
,
polyhedral
=
True
)
op_attrs
=
None
,
attrs
=
None
,
log_cce
=
True
,
dump_c
od
e
=
True
,
polyhedral
=
True
)
outputs
=
utils
.
mod_launch
(
mod
,
[
head
,
mean
,
scale
,
*
outputs
],
outputs
=
tuple
(
range
(
-
len
(
outputs
),
0
)),
expect
=
expects
)
outputs
=
list
(
outputs
)
...
...
tests/common/test_run/distr_normal_diag_KLdiv_run.py
浏览文件 @
403e8110
...
...
@@ -27,7 +27,7 @@ def KLdiv_run(shape, dtype, kernelname="", attrs = None):
mod
=
utils
.
op_build_test
(
KLdiv_op
,
[
mean
.
shape
,
scale
.
shape
],
[
dtype
,
dtype
],
kernel_name
=
kernelname
,
op_attrs
=
[],
attrs
=
None
,
log_cce
=
True
,
dump_c
c
e
=
True
,
polyhedral
=
True
)
op_attrs
=
[],
attrs
=
None
,
log_cce
=
True
,
dump_c
od
e
=
True
,
polyhedral
=
True
)
output
=
utils
.
mod_launch
(
mod
,
[
mean
,
scale
,
output
],
expect
=
expect
)
return
(
mean
,
scale
),
output
,
expect
,
compare_tensor
(
output
,
expect
,
rtol
=
5e-03
,
equal_nan
=
True
)
...
...
tests/common/test_run/distr_normal_diag_logprob_ad_run.py
浏览文件 @
403e8110
...
...
@@ -30,7 +30,7 @@ def logprob_ad_run(shape, dtype, kernel_name="", attrs=None):
op_attrs
=
None
,
attrs
=
None
,
log_cce
=
True
,
dump_c
c
e
=
True
,
dump_c
od
e
=
True
,
polyhedral
=
True
,
)
outputs
=
utils
.
mod_launch
(
...
...
tests/common/test_run/distr_normal_diag_logprob_run.py
浏览文件 @
403e8110
...
...
@@ -28,7 +28,7 @@ def logprob_run(shape, dtype, kernelname="", attrs = None):
mod
=
utils
.
op_build_test
(
logprob_op
,
[
x
.
shape
,
mean
.
shape
,
scale
.
shape
],
[
dtype
,
dtype
,
dtype
],
kernel_name
=
kernelname
,
op_attrs
=
[],
attrs
=
None
,
log_cce
=
True
,
dump_c
c
e
=
True
,
polyhedral
=
True
)
op_attrs
=
[],
attrs
=
None
,
log_cce
=
True
,
dump_c
od
e
=
True
,
polyhedral
=
True
)
output
=
utils
.
mod_launch
(
mod
,
[
x
,
mean
,
scale
,
output
],
expect
=
expect
)
return
(
x
,
mean
,
scale
),
output
,
expect
,
compare_tensor
(
output
,
expect
,
rtol
=
5e-03
,
equal_nan
=
True
)
...
...
tests/common/test_run/distr_normal_diag_sample_ad_run.py
浏览文件 @
403e8110
...
...
@@ -24,7 +24,7 @@ def sample_ad_run(shape, dtype, kernel_name="", attrs=None):
mod
=
utils
.
op_build_test
(
distr_normal_diag_sample_ad
.
normal_diag_sample_ad
,
[
head
.
shape
,
mean
.
shape
,
scale
.
shape
,
eps
.
shape
],
[
dtype
,
dtype
,
dtype
,
dtype
],
kernel_name
=
kernel_name
,
op_attrs
=
None
,
attrs
=
None
,
log_cce
=
True
,
dump_c
c
e
=
True
,
polyhedral
=
True
)
op_attrs
=
None
,
attrs
=
None
,
log_cce
=
True
,
dump_c
od
e
=
True
,
polyhedral
=
True
)
outputs
=
utils
.
mod_launch
(
mod
,
[
head
,
mean
,
scale
,
eps
,
*
outputs
],
outputs
=
tuple
(
range
(
-
len
(
outputs
),
0
)),
expect
=
expects
)
outputs
=
list
(
outputs
)
...
...
tests/common/test_run/distr_normal_diag_sample_run.py
浏览文件 @
403e8110
...
...
@@ -26,7 +26,7 @@ def sample_run(shape, dtype, kernel_name="", attrs=None):
mod
=
utils
.
op_build_test
(
sample_op
,
[
mean
.
shape
,
scale
.
shape
,
eps
.
shape
],
[
dtype
,
dtype
,
dtype
],
kernel_name
=
kernel_name
,
op_attrs
=
None
,
attrs
=
None
,
log_cce
=
True
,
dump_c
c
e
=
True
,
polyhedral
=
True
)
op_attrs
=
None
,
attrs
=
None
,
log_cce
=
True
,
dump_c
od
e
=
True
,
polyhedral
=
True
)
output
=
utils
.
mod_launch
(
mod
,
[
mean
,
scale
,
eps
,
output
],
expect
=
expect
)
return
(
mean
,
scale
,
eps
),
output
,
expect
,
compare_tensor
(
output
,
expect
,
rtol
=
5e-03
,
atol
=
0.1
,
equal_nan
=
True
)
...
...
tests/common/test_run/distr_normal_prob_regr_train_run.py
浏览文件 @
403e8110
...
...
@@ -25,7 +25,7 @@ def prob_regression_run(shape, dtype, kernel_name, attrs):
mod
=
utils
.
op_build_test
(
distr_normal_prob_regr_train
.
prob_regression_train
,
[
x
.
shape
,
w
.
shape
,
y
.
shape
],
[
dtype
,
dtype
,
dtype
],
kernel_name
=
kernel_name
,
op_attrs
=
[],
attrs
=
None
,
log_cce
=
True
,
dump_c
c
e
=
True
,
polyhedral
=
True
)
op_attrs
=
[],
attrs
=
None
,
log_cce
=
True
,
dump_c
od
e
=
True
,
polyhedral
=
True
)
output
=
utils
.
mod_launch
(
mod
,
[
x
,
w
,
y
,
output
],
expect
=
expect
)
return
(
x
,
w
,
y
),
output
,
expect
,
compare_tensor
(
output
,
expect
,
rtol
=
5e-03
,
equal_nan
=
True
)
...
...
tests/common/test_run/dropout_run.py
浏览文件 @
403e8110
...
...
@@ -83,7 +83,7 @@ def dropout_execute(shape_tensor, keep_prob, dtype, kernel_name, attrs=None):
output
=
utils
.
mod_launch
(
mod
,
(
input
,
mask
,
output
),
expect
=
expect
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
utils
.
create_c
c
e
(
kernel_name
,
"./"
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
"./"
,
source_code
)
rtol
,
atol
=
get_rtol_atol
(
"dropout"
,
dtype
)
return
(
input
,
mask
),
output
,
expect
,
compare_tensor
(
output
,
expect
,
rtol
=
rtol
,
atol
=
atol
,
equal_nan
=
True
)
...
...
tests/common/test_run/kldiv_loss_grad_run.py
浏览文件 @
403e8110
...
...
@@ -28,7 +28,7 @@ def kldiv_loss_grad_run(shape, dtype, kernel_name="kldiv_loss_grad", attrs=None)
t
=
attrs
.
get
(
"tuning"
,
False
)
kernel_name
=
attrs
.
get
(
"kernel_name"
,
False
)
mod
=
utils
.
op_build_test
(
kldiv_loss_grad
.
kldiv_loss_grad
,
[
shape
,
shape
,
shape
],
[
dtype
,
dtype
,
dtype
],
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
c
e
=
True
,
tuning
=
t
)
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
od
e
=
True
,
tuning
=
t
)
if
t
:
cur_deriv
,
output
,
pre_deriv
,
prediction
,
target
=
gen_data
(
attrs
,
dtype
,
shape
)
return
mod
,
cur_deriv
,
(
pre_deriv
,
prediction
,
target
,
output
)
...
...
@@ -36,7 +36,7 @@ def kldiv_loss_grad_run(shape, dtype, kernel_name="kldiv_loss_grad", attrs=None)
return
mod
else
:
mod
=
utils
.
op_build_test
(
kldiv_loss_grad
.
kldiv_loss_grad
,
[
shape
,
shape
,
shape
],
[
dtype
,
dtype
,
dtype
],
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
c
e
=
True
)
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
od
e
=
True
)
cur_deriv
,
output
,
pre_deriv
,
prediction
,
target
=
gen_data
(
attrs
,
dtype
,
shape
)
output
=
utils
.
mod_launch
(
mod
,
(
pre_deriv
,
prediction
,
target
,
output
),
expect
=
cur_deriv
)
return
(
pre_deriv
,
prediction
,
target
),
output
,
cur_deriv
,
compare_tensor
(
output
,
cur_deriv
,
rtol
=
0.005
,
...
...
tests/common/test_run/l1_loss_grad_run.py
浏览文件 @
403e8110
...
...
@@ -28,7 +28,7 @@ def l1_loss_grad_run(shape, dtype, kernel_name="l1_loss_grad", attrs=None):
t
=
attrs
.
get
(
"tuning"
,
False
)
kernel_name
=
attrs
.
get
(
"kernel_name"
,
False
)
mod
=
utils
.
op_build_test
(
l1_loss_grad
.
l1_loss_grad
,
[
shape
,
shape
,
shape
],
[
dtype
,
dtype
,
dtype
],
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
c
e
=
True
,
tuning
=
t
)
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
od
e
=
True
,
tuning
=
t
)
if
t
:
dloss
,
expect
,
output
,
prediction
,
target
=
gen_data
(
dtype
,
shape
)
return
mod
,
expect
,
(
dloss
,
prediction
,
target
,
output
)
...
...
@@ -36,7 +36,7 @@ def l1_loss_grad_run(shape, dtype, kernel_name="l1_loss_grad", attrs=None):
return
mod
else
:
mod
=
utils
.
op_build_test
(
l1_loss_grad
.
l1_loss_grad
,
[
shape
,
shape
,
shape
],
[
dtype
,
dtype
,
dtype
],
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
c
e
=
True
)
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
od
e
=
True
)
dloss
,
expect
,
output
,
prediction
,
target
=
gen_data
(
dtype
,
shape
)
output
=
utils
.
mod_launch
(
mod
,
(
dloss
,
prediction
,
target
,
output
),
expect
=
expect
)
return
(
dloss
,
prediction
,
target
),
output
,
expect
,
compare_tensor
(
output
,
expect
,
rtol
=
0.001
,
atol
=
0.001
)
...
...
tests/common/test_run/matmul_run_mansch.py
浏览文件 @
403e8110
...
...
@@ -45,7 +45,7 @@ def matmul_run_mansch(MatrixShape, l1_tiling, l0_tiling, kernel_name, attrs=None
# launch the kernel
mod
=
matmul_mansch
.
gemm_dsl
(
MatrixShape
,
l1_tiling
,
l0_tiling
,
kernel_name
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
utils
.
create_c
c
e
(
kernel_name
,
"."
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
"."
,
source_code
)
res
=
utils
.
mod_launch
(
mod
,
[
A
,
B
,
out_data
])
# transform numpy data to compute benchMark
...
...
tests/common/test_run/maxpool_ad_run.py
浏览文件 @
403e8110
...
...
@@ -44,14 +44,14 @@ def maxpool_ad_run(shape, kernel, stride, pad, dtype, optimized, polyhedral=Fals
else
:
mod
=
utils
.
op_build_test
(
maxpool_ad_no_custom_diff_poly_all_max
,
[
head
.
shape
,
shape
],
[
dtype
,
dtype
],
kernel_name
=
"maxpool_ad_no_custom_diff_poly_all_max"
,
op_attrs
=
[
kernel
,
stride
,
pad
],
attrs
=
attrs
,
log_cce
=
False
,
dump_c
c
e
=
True
,
polyhedral
=
polyhedral
)
op_attrs
=
[
kernel
,
stride
,
pad
],
attrs
=
attrs
,
log_cce
=
False
,
dump_c
od
e
=
True
,
polyhedral
=
polyhedral
)
output
=
utils
.
mod_launch
(
mod
,
[
head
,
input
,
output
],
expect
=
expect
)
else
:
if
optimized
:
if
first_max
:
mod
=
utils
.
op_build_test
(
maxpool_ad
,
[
head
.
shape
,
shape
,
forward
.
shape
,
mask
.
shape
],
[
dtype
,
dtype
,
dtype
,
dtype
],
kernel_name
=
"maxpool_ad_first_max"
,
op_attrs
=
[
kernel
,
stride
,
pad
],
attrs
=
attrs
,
log_cce
=
False
,
dump_c
c
e
=
True
,
polyhedral
=
polyhedral
)
op_attrs
=
[
kernel
,
stride
,
pad
],
attrs
=
attrs
,
log_cce
=
False
,
dump_c
od
e
=
True
,
polyhedral
=
polyhedral
)
output
=
utils
.
mod_launch
(
mod
,
[
head
,
input
,
forward
,
mask
,
output
],
expect
=
expect
)
else
:
mod
=
maxpool_ad_manual_schedule_all_max
(
shape
,
kernel
,
stride
,
pad
,
dtype
,
attrs
=
attrs
,
polyhedral
=
polyhedral
)
...
...
@@ -62,7 +62,7 @@ def maxpool_ad_run(shape, kernel, stride, pad, dtype, optimized, polyhedral=Fals
else
:
mod
=
utils
.
op_build_test
(
maxpool_ad_no_custom_diff_manual_schedule_all_max
,
[
head
.
shape
,
shape
],
[
dtype
,
dtype
],
kernel_name
=
"maxpool_ad_no_custom_diff_manual_schedule_all_max"
,
op_attrs
=
[
kernel
,
stride
,
pad
],
attrs
=
attrs
,
log_cce
=
False
,
dump_c
c
e
=
True
,
polyhedral
=
polyhedral
)
op_attrs
=
[
kernel
,
stride
,
pad
],
attrs
=
attrs
,
log_cce
=
False
,
dump_c
od
e
=
True
,
polyhedral
=
polyhedral
)
output
=
utils
.
mod_launch
(
mod
,
[
head
,
input
,
output
],
expect
=
expect
)
if
'tuning'
in
attrs
.
keys
():
...
...
tests/common/test_run/maxpool_grad_run.py
浏览文件 @
403e8110
...
...
@@ -100,7 +100,7 @@ def maxpool_grad_run(shape, kernel, stride, pad, dtype, attrs):
mod
=
utils
.
op_build_test
(
maxpool_grad
.
maxpool_grad
,
[
shape
,
y_shape
,
y_shape
],
[
dtype
,
dtype
,
dtype
],
op_attrs
=
[
kernel
,
stride
,
pad
],
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
c
e
=
True
,
tuning
=
t
)
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
od
e
=
True
,
tuning
=
t
)
if
t
:
dy
,
expect
,
output
,
x
,
y
=
\
gen_data
(
dtype
,
kernel
,
pad
,
shape
,
stride
,
y_shape
)
...
...
@@ -111,7 +111,7 @@ def maxpool_grad_run(shape, kernel, stride, pad, dtype, attrs):
mod
=
utils
.
op_build_test
(
maxpool_grad
.
maxpool_grad
,
[
shape
,
y_shape
,
y_shape
],
[
dtype
,
dtype
,
dtype
],
op_attrs
=
[
kernel
,
stride
,
pad
],
kernel_name
=
'maxpool_grad'
,
attrs
=
attrs
,
dump_c
c
e
=
True
)
kernel_name
=
'maxpool_grad'
,
attrs
=
attrs
,
dump_c
od
e
=
True
)
dy
,
expect
,
output
,
x
,
y
=
\
gen_data
(
dtype
,
kernel
,
pad
,
shape
,
stride
,
y_shape
)
output
=
utils
.
mod_launch
(
mod
,
(
x
,
y
,
dy
,
output
),
expect
=
expect
)
...
...
tests/common/test_run/maxpool_grad_with_argmax_run.py
浏览文件 @
403e8110
...
...
@@ -31,7 +31,7 @@ def maxpool_grad_with_argmax_run(shape, kernel, stride, pad, dtype, polyhedral=F
mod
=
utils
.
op_build_test
(
maxpool_grad_with_argmax
,
[
head
.
shape
,
mask
.
shape
],
[
dtype
,
dtype
],
kernel_name
=
"maxpool_grad_with_argmax"
,
op_attrs
=
[
shape
,
kernel
,
stride
,
pad
],
attrs
=
attrs
,
log_cce
=
False
,
dump_c
c
e
=
True
,
polyhedral
=
polyhedral
)
log_cce
=
False
,
dump_c
od
e
=
True
,
polyhedral
=
polyhedral
)
if
t
:
return
mod
,
expect
,
(
head
,
mask
,
output
)
else
:
...
...
@@ -43,7 +43,7 @@ def maxpool_grad_with_argmax_run(shape, kernel, stride, pad, dtype, polyhedral=F
mod
=
utils
.
op_build_test
(
maxpool_grad_with_argmax
,
[
head
.
shape
,
mask
.
shape
],
[
dtype
,
dtype
],
kernel_name
=
"maxpool_grad_with_argmax"
,
op_attrs
=
[
shape
,
kernel
,
stride
,
pad
],
attrs
=
attrs
,
log_cce
=
False
,
dump_c
c
e
=
True
,
polyhedral
=
polyhedral
)
log_cce
=
False
,
dump_c
od
e
=
True
,
polyhedral
=
polyhedral
)
output
=
utils
.
mod_launch
(
mod
,
[
head
,
mask
,
output
],
expect
=
expect
)
rtol
,
atol
=
get_rtol_atol
(
"maxpool_grad_with_argmax"
,
dtype
)
...
...
tests/common/test_run/nms_run.py
浏览文件 @
403e8110
...
...
@@ -94,6 +94,6 @@ def nms_run(shape_tensor, thres, dtype, kernel_name, attrs):
output
=
utils
.
mod_launch
(
mod
,
(
anchor
,
output
),
expect
=
expect
)
output
=
np
.
frombuffer
(
output
.
tobytes
(),
np
.
uint16
).
reshape
(
out_shape
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
utils
.
create_c
c
e
(
kernel_name
,
"./"
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
"./"
,
source_code
)
expect
=
np
.
frombuffer
(
expect
.
tobytes
(),
np
.
uint16
).
reshape
(
out_shape
)
return
anchor
,
output
,
expect
,
np
.
all
(
output
==
expect
)
tests/common/test_run/roipool_run.py
浏览文件 @
403e8110
...
...
@@ -32,7 +32,7 @@ def roipool_run(shape, roibox, pooled_shape, dtype, attrs, cce_path="./"):
expect
=
roipool_expect
(
input1
,
shape
,
roibox
,
pooled_shape
)
# source_code = mod.imported_modules[0].get_source()
# utils.create_c
c
e(kernel_name, cce_path, source_code)
# utils.create_c
od
e(kernel_name, cce_path, source_code)
output
=
np
.
full
(
output_shape
,
np
.
nan
,
dtype
)
output
=
utils
.
mod_launch
(
mod
,
(
input1
,
output
),
expect
=
expect
)
...
...
tests/common/test_run/smooth_l1_loss_grad_run.py
浏览文件 @
403e8110
...
...
@@ -37,7 +37,7 @@ def smooth_l1_loss_grad_run(shape, dtype, attrs=None, kernel_name="smooth_l1_los
kernel_name
=
attrs
.
get
(
"kernel_name"
,
False
)
mod
=
utils
.
op_build_test
(
smooth_l1_loss_grad
.
smooth_l1_loss_grad
,
[
sample_shape
,
shape
,
shape
,
sample_shape
],
[
dtype
,
dtype
,
dtype
,
anchor_samples_dtype
],
op_attrs
=
[
sigma
,
anchor_sample_correct
],
attrs
=
attrs
,
kernel_name
=
kernel_name
,
dump_c
c
e
=
True
,
tuning
=
t
)
attrs
=
attrs
,
kernel_name
=
kernel_name
,
dump_c
od
e
=
True
,
tuning
=
t
)
if
t
:
anchor_samples
,
dloss
,
expect
,
output
,
prediction
,
prediction_
,
target
,
target_
=
gen_data
(
anchor_sample_correct
,
anchor_samples_dtype
,
dtype
,
sample_shape
,
shape
,
sigma
)
...
...
@@ -50,7 +50,7 @@ def smooth_l1_loss_grad_run(shape, dtype, attrs=None, kernel_name="smooth_l1_los
mod
=
utils
.
op_build_test
(
smooth_l1_loss_grad
.
smooth_l1_loss_grad
,
[
sample_shape
,
shape
,
shape
,
sample_shape
],
[
dtype
,
dtype
,
dtype
,
anchor_samples_dtype
],
op_attrs
=
[
sigma
,
anchor_sample_correct
],
attrs
=
attrs
,
kernel_name
=
kernel_name
,
dump_c
c
e
=
True
)
attrs
=
attrs
,
kernel_name
=
kernel_name
,
dump_c
od
e
=
True
)
output
=
utils
.
mod_launch
(
mod
,
(
dloss
,
prediction
,
target
,
anchor_samples
,
output
),
expect
=
expect
)
return
(
dloss
,
prediction
,
target
,
anchor_samples
),
output
,
expect
,
compare_tensor
(
output
,
expect
,
atol
=
5e-3
,
rtol
=
5e-3
)
...
...
tests/common/test_run/square_difference_run.py
浏览文件 @
403e8110
...
...
@@ -35,7 +35,7 @@ def square_difference_run(shape1, shape2, dtype, kernel_name, attrs, cce_path=".
input_types
=
[
dtype
,
dtype
],
kernel_name
=
kernel_name
,
attrs
=
attrs
)
expect
,
input1
,
input2
,
output
=
gen_data
(
dtype
,
shape1
,
shape2
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
utils
.
create_c
c
e
(
kernel_name
,
cce_path
,
source_code
)
utils
.
create_c
od
e
(
kernel_name
,
cce_path
,
source_code
)
output
=
utils
.
mod_launch
(
mod
,
(
input1
,
input2
,
output
),
expect
=
expect
)
return
(
input1
,
input2
),
output
,
expect
,
compare_tensor
(
output
,
expect
,
rtol
=
5e-03
,
equal_nan
=
True
)
...
...
tests/common/test_run/strided_slice_grad_run.py
浏览文件 @
403e8110
...
...
@@ -81,7 +81,7 @@ def gen_data(begin, begin_mask, dtype, ellipsis_mask, end, end_mask, grad_shape,
# source_code = mod.imported_modules[0].get_source()
# print(source_code)
# kernel_name = "cce_strided_slice_grad_fp16"
# utils.create_c
c
e(kernel_name, './', source_code)
# utils.create_c
od
e(kernel_name, './', source_code)
out_shape
=
input_shape
output
=
np
.
full
(
out_shape
,
0
,
dtype
)
return
expect
,
grad
,
output
...
...
tests/common/test_run/truncatemod_run.py
浏览文件 @
403e8110
...
...
@@ -26,7 +26,7 @@ def truncatemod_run(shape1, shape2, dtype, attrs):
t
=
attrs
.
get
(
"tuning"
,
False
)
kernel_name
=
attrs
.
get
(
"kernel_name"
,
False
)
mod
=
utils
.
op_build_test
(
truncatemod
.
truncatemod
,
[
shape1
,
shape2
],
[
dtype
,
dtype
],
kernel_name
=
kernel_name
,
attrs
=
attrs
,
dump_c
c
e
=
True
,
tuning
=
t
)
attrs
=
attrs
,
dump_c
od
e
=
True
,
tuning
=
t
)
if
t
:
expect
,
input1
,
input2
,
output
=
gen_data
(
dtype
,
shape1
,
shape2
)
return
mod
,
expect
,
(
input1
,
input2
,
output
)
...
...
@@ -35,7 +35,7 @@ def truncatemod_run(shape1, shape2, dtype, attrs):
else
:
expect
,
input1
,
input2
,
output
=
gen_data
(
dtype
,
shape1
,
shape2
)
mod
=
utils
.
op_build_test
(
truncatemod
.
truncatemod
,
[
shape1
,
shape2
],
[
dtype
,
dtype
],
kernel_name
=
"truncatemod"
,
attrs
=
attrs
,
dump_c
c
e
=
True
)
attrs
=
attrs
,
dump_c
od
e
=
True
)
output
=
utils
.
mod_launch
(
mod
,
(
input1
,
input2
,
output
),
expect
=
expect
)
rtol
,
atol
=
get_rtol_atol
(
"truncatemod"
,
dtype
)
res
=
compare_tensor
(
output
,
expect
,
rtol
=
rtol
,
atol
=
atol
,
equal_nan
=
True
)
...
...
tests/common/test_run/vector_matmul_run.py
浏览文件 @
403e8110
...
...
@@ -145,7 +145,7 @@ def vector_matmul_run(case_index, m, n, k, trans_a, trans_b, read_data, dump_dat
# k = (k+15)//16*16
mod
,
out_shape
=
vector_matmul
.
vector_matmul
(
m
,
n
,
k
,
trans_a
,
trans_b
,
dtype
,
kernel_name
,
attrs
)
utils
.
create_c
c
e
(
kernel_name
,
"./"
,
mod
.
imported_modules
[
0
].
get_source
())
utils
.
create_c
od
e
(
kernel_name
,
"./"
,
mod
.
imported_modules
[
0
].
get_source
())
# Generate data
m_a
,
m_b
,
bench_mark
=
vector_matmul_data
(
case_index
,
m
,
n
,
k
,
trans_a
,
trans_b
,
read_data
,
dump_data
,
dtype
)
...
...
tests/common/test_run/winograd_ad_run.py
浏览文件 @
403e8110
...
...
@@ -35,7 +35,7 @@ def winograd_ad_run(filter_shape, tile, dtype, attrs):
t
=
attrs
.
get
(
"tuning"
,
False
)
kernel_name
=
attrs
.
get
(
"kernel_name"
,
False
)
mod
=
utils
.
op_build_test
(
winograd_ad
,
[
head_np
.
shape
,
filter_shape
],
[
dtype
,
dtype
],
kernel_name
=
kernel_name
,
attrs
=
attrs
,
log_cce
=
True
,
dump_c
c
e
=
True
,
tuning
=
t
)
attrs
=
attrs
,
log_cce
=
True
,
dump_c
od
e
=
True
,
tuning
=
t
)
if
t
:
expect
,
input_np
,
output
=
gen_data
(
filter_shape
,
RANGEFILL
,
dtype
)
return
mod
,
expect
,
(
head_np
,
input_np
,
output
)
...
...
@@ -45,7 +45,7 @@ def winograd_ad_run(filter_shape, tile, dtype, attrs):
# scenario 1:
expect
,
input_np
,
output
=
gen_data
(
filter_shape
,
RANGEFILL
,
dtype
)
mod
=
utils
.
op_build_test
(
winograd_ad
,
[
head_np
.
shape
,
filter_shape
],
[
dtype
,
dtype
],
kernel_name
=
"winograd_ad"
,
attrs
=
attrs
,
log_cce
=
True
,
dump_c
c
e
=
True
)
attrs
=
attrs
,
log_cce
=
True
,
dump_c
od
e
=
True
)
output
=
utils
.
mod_launch
(
mod
,
[
head_np
,
input_np
,
output
],
expect
=
expect
)
if
not
compare_tensor
(
output
,
expect
,
atol
=
0.1
):
return
[
head_np
,
input_np
],
output
,
expect
,
compare_tensor
(
output
,
expect
,
rtol
=
5e-03
,
atol
=
5e-03
,
...
...
tests/operators/cube/quant_conv.py
浏览文件 @
403e8110
...
...
@@ -403,7 +403,7 @@ def test_CCE_Conv(fmap_shape, filter_shape, pad_, stride_,
mod
=
akg
.
build
(
s
,
[
A
,
B
,
ScaleQ
,
OffsetQ
,
out
],
"cce"
,
name
=
kernel_name
,
attrs
=
attrs
,
attrs
=
{
"dim"
:
info
},
polyhedral
=
True
)
source_code
=
mod
.
imported_modules
[
0
].
get_source
()
# print(source_code)
# utils.create_c
c
e(kernel_name, cce_path, source_code)
# utils.create_c
od
e(kernel_name, cce_path, source_code)
if
run_cce
:
run_conv
(
mod
,
fmap_shape
,
filter_shape
,
pad_
[
0
],
stride_
[
0
],
use_bias
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录