Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
405e5de6
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
332
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
405e5de6
编写于
7月 07, 2020
作者:
C
cc
提交者:
GitHub
7月 07, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Check scale value in set scales, test=develop (#3885)
上级
79c54557
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
14 deletion
+18
-14
lite/core/op_lite.cc
lite/core/op_lite.cc
+11
-14
lite/utils/string.h
lite/utils/string.h
+7
-0
未找到文件。
lite/core/op_lite.cc
浏览文件 @
405e5de6
...
...
@@ -18,18 +18,11 @@
#include <utility>
#include <vector>
#include "lite/core/op_registry.h"
#include "lite/utils/string.h"
namespace
paddle
{
namespace
lite
{
static
std
::
string
int2string
(
int
index
)
{
const
int
BUFFER_LENGTH
=
30
;
char
buffer
[
BUFFER_LENGTH
];
int
num
=
snprintf
(
buffer
,
sizeof
(
buffer
),
"%d"
,
index
);
CHECK
(
num
>
0
&&
num
<
sizeof
(
buffer
));
return
std
::
string
(
buffer
);
}
bool
OpLite
::
InferShape
()
{
// if input_tensor_ptrs and output_tensor_ptrs are overloaded in param_
// InferShapeByMemoryInternal will be applied.
...
...
@@ -245,7 +238,7 @@ bool OpInfo::HasInputScale(const std::string &input_name) const {
int
index
;
if
(
GetInputArgname
(
input_name
,
&
argname
)
&&
GetInputIndex
(
input_name
,
&
index
))
{
return
HasAttr
(
argname
+
int2
string
(
index
)
+
"_scale"
);
return
HasAttr
(
argname
+
to_
string
(
index
)
+
"_scale"
);
}
else
{
return
false
;
}
...
...
@@ -256,7 +249,7 @@ bool OpInfo::HasOutputScale(const std::string &output_name) const {
int
index
;
if
(
GetOutputArgname
(
output_name
,
&
argname
)
&&
GetOutputIndex
(
output_name
,
&
index
))
{
return
HasAttr
(
argname
+
int2
string
(
index
)
+
"_scale"
);
return
HasAttr
(
argname
+
to_
string
(
index
)
+
"_scale"
);
}
else
{
return
false
;
}
...
...
@@ -268,7 +261,9 @@ void OpInfo::SetInputScale(const std::string &input_name,
int
index
;
CHECK
(
GetInputArgname
(
input_name
,
&
argname
));
CHECK
(
GetInputIndex
(
input_name
,
&
index
));
SetAttr
<
std
::
vector
<
float
>>
(
argname
+
int2string
(
index
)
+
"_scale"
,
CHECK
(
scale_value
.
size
()
>
0
)
<<
"Error in SetInputScale: the scales should not be empty"
;
SetAttr
<
std
::
vector
<
float
>>
(
argname
+
to_string
(
index
)
+
"_scale"
,
scale_value
);
}
...
...
@@ -278,7 +273,9 @@ void OpInfo::SetOutputScale(const std::string &output_name,
int
index
;
CHECK
(
GetOutputArgname
(
output_name
,
&
argname
));
CHECK
(
GetOutputIndex
(
output_name
,
&
index
));
SetAttr
<
std
::
vector
<
float
>>
(
argname
+
int2string
(
index
)
+
"_scale"
,
CHECK
(
scale_value
.
size
()
>
0
)
<<
"Error in SetOutputScale: the scales should not be empty"
;
SetAttr
<
std
::
vector
<
float
>>
(
argname
+
to_string
(
index
)
+
"_scale"
,
scale_value
);
}
...
...
@@ -287,7 +284,7 @@ std::vector<float> OpInfo::GetInputScale(const std::string &input_name) const {
int
index
;
CHECK
(
GetInputArgname
(
input_name
,
&
argname
));
CHECK
(
GetInputIndex
(
input_name
,
&
index
));
return
GetAttr
<
std
::
vector
<
float
>>
(
argname
+
int2
string
(
index
)
+
"_scale"
);
return
GetAttr
<
std
::
vector
<
float
>>
(
argname
+
to_
string
(
index
)
+
"_scale"
);
}
std
::
vector
<
float
>
OpInfo
::
GetOutputScale
(
...
...
@@ -296,7 +293,7 @@ std::vector<float> OpInfo::GetOutputScale(
int
index
;
CHECK
(
GetOutputArgname
(
output_name
,
&
argname
));
CHECK
(
GetOutputIndex
(
output_name
,
&
index
));
return
GetAttr
<
std
::
vector
<
float
>>
(
argname
+
int2
string
(
index
)
+
"_scale"
);
return
GetAttr
<
std
::
vector
<
float
>>
(
argname
+
to_
string
(
index
)
+
"_scale"
);
}
}
// namespace lite
...
...
lite/utils/string.h
浏览文件 @
405e5de6
...
...
@@ -60,6 +60,13 @@ static std::string to_string(const T& v) {
return
ss
.
str
();
}
static
std
::
string
to_string
(
int
index
)
{
const
int
BUFFER_LENGTH
=
15
;
char
buffer
[
BUFFER_LENGTH
];
snprintf
(
buffer
,
sizeof
(
buffer
),
"%d"
,
index
);
return
std
::
string
(
buffer
);
}
template
<
typename
T
>
std
::
string
Join
(
const
std
::
vector
<
T
>&
vec
,
const
std
::
string
&
delim
)
{
if
(
vec
.
empty
())
return
""
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录