Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
项目经理老王
Mace
提交
eef28c62
Mace
项目概览
项目经理老王
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mace
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
eef28c62
编写于
9月 07, 2018
作者:
赵
赵奇可
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix resize bicubic code format
上级
ea7dcb3c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
19 deletion
+19
-19
mace/kernels/resize_bicubic.h
mace/kernels/resize_bicubic.h
+19
-19
未找到文件。
mace/kernels/resize_bicubic.h
浏览文件 @
eef28c62
...
...
@@ -32,11 +32,11 @@ namespace kernels {
static
const
int64_t
kTableSize
=
(
1
<<
10
);
inline
const
float
*
InitCoeffsTable
()
{
inline
const
float
*
InitCoeffsTable
()
{
// Allocate and initialize coefficients table using Bicubic
// convolution algorithm.
// https://en.wikipedia.org/wiki/Bicubic_interpolation
float
*
coeffs_tab
=
new
float
[(
kTableSize
+
1
)
*
2
];
float
*
coeffs_tab
=
new
float
[(
kTableSize
+
1
)
*
2
];
static
const
double
A
=
-
0.75
;
for
(
int
i
=
0
;
i
<=
kTableSize
;
++
i
)
{
float
x
=
i
*
1.0
/
kTableSize
;
...
...
@@ -47,9 +47,9 @@ inline const float* InitCoeffsTable() {
return
coeffs_tab
;
}
inline
const
float
*
GetCoeffsTable
()
{
inline
const
float
*
GetCoeffsTable
()
{
// Static so that we initialize it on first use
static
const
float
*
coeffs_tab
=
InitCoeffsTable
();
static
const
float
*
coeffs_tab
=
InitCoeffsTable
();
return
coeffs_tab
;
}
...
...
@@ -58,12 +58,12 @@ inline int64_t Bound(int64_t val, int64_t limit) {
}
inline
void
GetWeightsAndIndices
(
float
scale
,
int64_t
out_loc
,
int64_t
limit
,
std
::
vector
<
float
>
*
weights
,
std
::
vector
<
int64_t
>
*
indices
)
{
std
::
vector
<
float
>
*
weights
,
std
::
vector
<
int64_t
>
*
indices
)
{
const
int64_t
in_loc
=
scale
*
out_loc
;
const
float
delta
=
scale
*
out_loc
-
in_loc
;
const
int64_t
offset
=
lrintf
(
delta
*
kTableSize
);
const
float
*
coeffs_tab
=
GetCoeffsTable
();
const
float
*
coeffs_tab
=
GetCoeffsTable
();
*
weights
=
{
coeffs_tab
[
offset
*
2
+
1
],
coeffs_tab
[
offset
*
2
],
coeffs_tab
[(
kTableSize
-
offset
)
*
2
],
coeffs_tab
[(
kTableSize
-
offset
)
*
2
+
1
]};
...
...
@@ -71,8 +71,8 @@ inline void GetWeightsAndIndices(float scale, int64_t out_loc, int64_t limit,
Bound
(
in_loc
+
1
,
limit
),
Bound
(
in_loc
+
2
,
limit
)};
}
inline
float
Interpolate1D
(
const
std
::
vector
<
float
>
&
weights
,
const
std
::
vector
<
float
>
&
values
)
{
inline
float
Interpolate1D
(
const
std
::
vector
<
float
>
&
weights
,
const
std
::
vector
<
float
>
&
values
)
{
return
values
[
0
]
*
weights
[
0
]
+
values
[
1
]
*
weights
[
1
]
+
values
[
2
]
*
weights
[
2
]
+
values
[
3
]
*
weights
[
3
];
}
...
...
@@ -86,15 +86,15 @@ inline float CalculateResizeScale(index_t in_size,
}
inline
void
ResizeImage
(
const
float
*
images
,
const
index_t
batch_size
,
const
index_t
in_height
,
const
index_t
in_width
,
const
index_t
out_height
,
const
index_t
out_width
,
const
index_t
channels
,
const
float
height_scale
,
const
float
width_scale
,
float
*
output
)
{
const
index_t
batch_size
,
const
index_t
in_height
,
const
index_t
in_width
,
const
index_t
out_height
,
const
index_t
out_width
,
const
index_t
channels
,
const
float
height_scale
,
const
float
width_scale
,
float
*
output
)
{
#pragma omp parallel for collapse(2)
for
(
index_t
b
=
0
;
b
<
batch_size
;
++
b
)
{
for
(
index_t
y
=
0
;
y
<
out_height
;
++
y
)
{
...
...
@@ -138,7 +138,7 @@ inline void ResizeImage(const float *images,
struct
ResizeBicubicFunctorBase
{
ResizeBicubicFunctorBase
(
const
std
::
vector
<
index_t
>
&
size
,
bool
align_corners
)
bool
align_corners
)
:
align_corners_
(
align_corners
)
{
MACE_CHECK
(
size
.
size
()
==
2
);
out_height_
=
size
[
0
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录