Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OAID
Tengine
提交
56879f2e
T
Tengine
项目概览
OAID
/
Tengine
11 个月 前同步成功
通知
53
Star
4429
Fork
1032
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Tengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
56879f2e
编写于
5月 25, 2021
作者:
B
BUG1989
提交者:
GitHub
5月 25, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix, interp, pad (#691)
上级
00dfa15c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
123 addition
and
54 deletion
+123
-54
source/device/cpu/op/interp/interp_ref.c
source/device/cpu/op/interp/interp_ref.c
+123
-49
source/device/cpu/op/pad/pad_ref.c
source/device/cpu/op/pad/pad_ref.c
+0
-5
未找到文件。
source/device/cpu/op/interp/interp_ref.c
浏览文件 @
56879f2e
...
...
@@ -165,43 +165,81 @@ void resize_bilinear_image(float* src, float* dst, float* alpha, int* xofs, floa
int
ref_interp_fp32
(
struct
tensor
*
input_tensor
,
struct
tensor
*
output_tensor
,
struct
interp_param
*
param
)
{
float
*
input
=
input_tensor
->
data
;
float
*
output
=
output_tensor
->
data
;
if
(
param
->
resize_type
==
1
)
{
float
*
input
=
input_tensor
->
data
;
float
*
output
=
output_tensor
->
data
;
int
batch
=
in
put_tensor
->
dims
[
0
];
int
channel
=
in
put_tensor
->
dims
[
1
];
int
in_h
=
in
put_tensor
->
dims
[
2
];
int
in_w
=
in
put_tensor
->
dims
[
3
];
int
out_h
=
out
put_tensor
->
dims
[
2
];
int
out_w
=
out
put_tensor
->
dims
[
3
];
int
batch
=
out
put_tensor
->
dims
[
0
];
int
channel
=
out
put_tensor
->
dims
[
1
];
int
output_h
=
out
put_tensor
->
dims
[
2
];
int
output_w
=
out
put_tensor
->
dims
[
3
];
int
input_h
=
in
put_tensor
->
dims
[
2
];
int
input_w
=
in
put_tensor
->
dims
[
3
];
int
in_channel_size
=
in_h
*
in_w
;
int
out_channel_size
=
out_h
*
out_w
;
for
(
int
n
=
0
;
n
<
batch
;
++
n
)
{
for
(
int
c
=
0
;
c
<
channel
;
c
++
)
{
for
(
int
h
=
0
;
h
<
output_h
;
h
++
)
{
for
(
int
w
=
0
;
w
<
output_w
;
w
++
)
{
int
in_w
=
w
/
param
->
width_scale
;
int
in_h
=
h
/
param
->
height_scale
;
int
out_idx
=
n
*
channel
*
output_h
*
output_w
+
c
*
output_h
*
output_w
+
h
*
output_w
+
w
;
int
in_idx
=
n
*
channel
*
input_h
*
input_w
+
c
*
input_w
*
input_h
+
in_h
*
input_w
+
in_w
;
output
[
out_idx
]
=
input
[
in_idx
];
}
}
}
}
}
else
if
(
param
->
resize_type
==
2
)
{
float
*
input
=
input_tensor
->
data
;
float
*
output
=
output_tensor
->
data
;
int
*
buf
=
sys_malloc
((
param
->
output_width
+
param
->
output_height
+
param
->
output_width
*
2
+
param
->
output_height
*
2
)
*
sizeof
(
float
));
int
batch
=
input_tensor
->
dims
[
0
];
int
channel
=
input_tensor
->
dims
[
1
];
int
in_h
=
input_tensor
->
dims
[
2
];
int
in_w
=
input_tensor
->
dims
[
3
];
int
out_h
=
output_tensor
->
dims
[
2
];
int
out_w
=
output_tensor
->
dims
[
3
];
if
(
buf
==
NULL
)
{
TLOG_ERR
(
"interp malloc failed!
\n
"
);
return
-
1
;
}
int
in_channel_size
=
in_h
*
in_w
;
int
out_channel_size
=
out_h
*
out_w
;
int
*
xofs
=
buf
;
//new int[ow];
int
*
yofs
=
buf
+
param
->
output_width
;
//new int[oh];
int
*
buf
=
sys_malloc
((
param
->
output_width
+
param
->
output_height
+
param
->
output_width
*
2
+
param
->
output_height
*
2
)
*
sizeof
(
float
));
float
*
alpha
=
(
float
*
)(
buf
+
param
->
output_width
+
param
->
output_height
);
//new float[ow * 2];
float
*
beta
=
(
float
*
)(
buf
+
param
->
output_width
+
param
->
output_height
+
param
->
output_width
*
2
);
//new float[oh * 2];
if
(
buf
==
NULL
)
{
TLOG_ERR
(
"interp malloc failed!
\n
"
);
return
-
1
;
}
int
*
xofs
=
buf
;
//new int[ow];
int
*
yofs
=
buf
+
param
->
output_width
;
//new int[oh];
float
*
alpha
=
(
float
*
)(
buf
+
param
->
output_width
+
param
->
output_height
);
//new float[ow * 2];
float
*
beta
=
(
float
*
)(
buf
+
param
->
output_width
+
param
->
output_height
+
param
->
output_width
*
2
);
//new float[oh * 2];
linear_coeffs
(
in_w
,
out_w
,
xofs
,
alpha
);
linear_coeffs
(
in_h
,
out_h
,
yofs
,
beta
);
linear_coeffs
(
in_w
,
out_w
,
xofs
,
alpha
);
linear_coeffs
(
in_h
,
out_h
,
yofs
,
beta
);
for
(
int
q
=
0
;
q
<
channel
;
++
q
)
{
resize_bilinear_image
(
input
+
in_channel_size
*
q
,
output
+
out_channel_size
*
q
,
alpha
,
xofs
,
beta
,
yofs
,
out_h
,
out_w
,
in_h
,
in_w
);
}
for
(
int
q
=
0
;
q
<
channel
;
++
q
)
sys_free
(
buf
);
}
else
{
resize_bilinear_image
(
input
+
in_channel_size
*
q
,
output
+
out_channel_size
*
q
,
alpha
,
xofs
,
beta
,
yofs
,
out_h
,
out_w
,
in_h
,
in_w
);
TLOG_ERR
(
"interp resize type %d not support!
\n
"
,
param
->
resize_type
);
return
-
1
;
}
sys_free
(
buf
);
return
0
;
}
...
...
@@ -227,36 +265,73 @@ int ref_interp_uint8(struct tensor* input_tensor, struct tensor* output_tensor,
}
/* process */
int
batch
=
input_tensor
->
dims
[
0
];
int
channel
=
input_tensor
->
dims
[
1
];
int
in_h
=
input_tensor
->
dims
[
2
];
int
in_w
=
input_tensor
->
dims
[
3
];
int
out_h
=
output_tensor
->
dims
[
2
];
int
out_w
=
output_tensor
->
dims
[
3
];
if
(
param
->
resize_type
==
1
)
{
int
batch
=
output_tensor
->
dims
[
0
];
int
channel
=
output_tensor
->
dims
[
1
];
int
output_h
=
output_tensor
->
dims
[
2
];
int
output_w
=
output_tensor
->
dims
[
3
];
int
input_h
=
input_tensor
->
dims
[
2
];
int
input_w
=
input_tensor
->
dims
[
3
];
for
(
int
n
=
0
;
n
<
batch
;
++
n
)
{
for
(
int
c
=
0
;
c
<
channel
;
c
++
)
{
for
(
int
h
=
0
;
h
<
output_h
;
h
++
)
{
for
(
int
w
=
0
;
w
<
output_w
;
w
++
)
{
int
in_w
=
w
/
param
->
width_scale
;
int
in_h
=
h
/
param
->
height_scale
;
int
out_idx
=
n
*
channel
*
output_h
*
output_w
+
c
*
output_h
*
output_w
+
h
*
output_w
+
w
;
int
in_idx
=
n
*
channel
*
input_h
*
input_w
+
c
*
input_w
*
input_h
+
in_h
*
input_w
+
in_w
;
output_fp32
[
out_idx
]
=
input_fp32
[
in_idx
];
}
}
}
}
}
else
if
(
param
->
resize_type
==
2
)
{
int
batch
=
input_tensor
->
dims
[
0
];
int
channel
=
input_tensor
->
dims
[
1
];
int
in_h
=
input_tensor
->
dims
[
2
];
int
in_w
=
input_tensor
->
dims
[
3
];
int
out_h
=
output_tensor
->
dims
[
2
];
int
out_w
=
output_tensor
->
dims
[
3
];
int
in_channel_size
=
in_h
*
in_w
;
int
out_channel_size
=
out_h
*
out_w
;
int
in_channel_size
=
in_h
*
in_w
;
int
out_channel_size
=
out_h
*
out_w
;
int
*
buf
=
sys_malloc
((
param
->
output_width
+
param
->
output_height
+
param
->
output_width
*
2
+
param
->
output_height
*
2
)
*
sizeof
(
float
));
int
*
buf
=
sys_malloc
((
param
->
output_width
+
param
->
output_height
+
param
->
output_width
*
2
+
param
->
output_height
*
2
)
*
sizeof
(
float
));
if
(
buf
==
NULL
)
{
TLOG_ERR
(
"interp malloc failed!
\n
"
);
return
-
1
;
}
if
(
buf
==
NULL
)
{
TLOG_ERR
(
"interp malloc failed!
\n
"
);
return
-
1
;
}
int
*
xofs
=
buf
;
//new int[ow];
int
*
yofs
=
buf
+
param
->
output_width
;
//new int[oh];
int
*
xofs
=
buf
;
//new int[ow];
int
*
yofs
=
buf
+
param
->
output_width
;
//new int[oh];
float
*
alpha
=
(
float
*
)(
buf
+
param
->
output_width
+
param
->
output_height
);
//new float[ow * 2];
float
*
beta
=
(
float
*
)(
buf
+
param
->
output_width
+
param
->
output_height
+
param
->
output_width
*
2
);
//new float[oh * 2];
float
*
alpha
=
(
float
*
)(
buf
+
param
->
output_width
+
param
->
output_height
);
//new float[ow * 2];
float
*
beta
=
(
float
*
)(
buf
+
param
->
output_width
+
param
->
output_height
+
param
->
output_width
*
2
);
//new float[oh * 2];
linear_coeffs
(
in_w
,
out_w
,
xofs
,
alpha
);
linear_coeffs
(
in_h
,
out_h
,
yofs
,
beta
);
linear_coeffs
(
in_w
,
out_w
,
xofs
,
alpha
);
linear_coeffs
(
in_h
,
out_h
,
yofs
,
beta
);
for
(
int
q
=
0
;
q
<
channel
;
++
q
)
for
(
int
q
=
0
;
q
<
channel
;
++
q
)
{
resize_bilinear_image
(
input_fp32
+
in_channel_size
*
q
,
output_fp32
+
out_channel_size
*
q
,
alpha
,
xofs
,
beta
,
yofs
,
out_h
,
out_w
,
in_h
,
in_w
);
}
sys_free
(
buf
);
}
else
{
resize_bilinear_image
(
input_fp32
+
in_channel_size
*
q
,
output_fp32
+
out_channel_size
*
q
,
alpha
,
xofs
,
beta
,
yofs
,
out_h
,
out_w
,
in_h
,
in_w
);
TLOG_ERR
(
"interp resize type %d not support!
\n
"
,
param
->
resize_type
);
return
-
1
;
}
/* quant */
...
...
@@ -270,7 +345,6 @@ int ref_interp_uint8(struct tensor* input_tensor, struct tensor* output_tensor,
output_uint8
[
i
]
=
udata
;
}
sys_free
(
buf
);
sys_free
(
input_fp32
);
sys_free
(
output_fp32
);
...
...
source/device/cpu/op/pad/pad_ref.c
浏览文件 @
56879f2e
...
...
@@ -80,13 +80,10 @@ static void ref_pad_fp32(float* input, float* output, int in_h, int in_w, int ou
}
else
{
// memcpy(outptr + left, ptr, in_w * sizeof(float));
// x += in_w;
for
(
x
=
0
;
x
<
in_w
;
x
++
)
{
outptr
[
left
+
x
]
=
ptr
[
x
];
}
x
++
;
}
for
(;
x
<
out_w
;
x
++
)
{
...
...
@@ -140,8 +137,6 @@ static void ref_pad_uint8(uint8_t* input, uint8_t* output, int in_h, int in_w, i
}
else
{
// memcpy(outptr + left, ptr, in_w * sizeof(float));
// x += in_w;
for
(;
x
<
in_w
;
x
++
)
{
outptr
[
left
+
x
]
=
ptr
[
x
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录