Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
17535d85
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
338
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看板
提交
17535d85
编写于
5月 17, 2018
作者:
朔-望
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix code style to llvm, namespace donot indent
上级
5d7a4caa
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
157 addition
and
152 deletion
+157
-152
.clang-format
.clang-format
+0
-1
.pre-commit-config.yaml
.pre-commit-config.yaml
+9
-9
.travis.yml
.travis.yml
+25
-4
.travis/check_style.sh
.travis/check_style.sh
+2
-2
src/framework/block_desc.cpp
src/framework/block_desc.cpp
+24
-24
src/platform/data_type.h
src/platform/data_type.h
+97
-97
tools/pre-commit.hooks/clang-format.bash
tools/pre-commit.hooks/clang-format.bash
+0
-15
未找到文件。
.clang-format
浏览文件 @
17535d85
...
@@ -3,5 +3,4 @@ Language: Cpp
...
@@ -3,5 +3,4 @@ Language: Cpp
BasedOnStyle: LLVM
BasedOnStyle: LLVM
Standard: Cpp11
Standard: Cpp11
IndentWidth: 4
IndentWidth: 4
NamespaceIndentation: All
...
...
.pre-commit-config.yaml
浏览文件 @
17535d85
...
@@ -20,15 +20,15 @@ repos:
...
@@ -20,15 +20,15 @@ repos:
-
id
:
trailing-whitespace
-
id
:
trailing-whitespace
files
:
(src).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
files
:
(src).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
-
repo
:
local
#
- repo: local
hooks
:
#
hooks:
-
id
:
clang-format-with-version-check
#
- id: clang-format-with-version-check
name
:
clang-format
#
name: clang-format
description
:
Format files with ClangFormat.
#
description: Format files with ClangFormat.
entry
:
bash ./tools/pre-commit.hooks/.clang_format.hook -i
#
entry: bash ./tools/pre-commit.hooks/.clang_format.hook -i
language
:
system
#
language: system
files
:
(src).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
#
files: (src).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
#
#- repo: local
#- repo: local
# hooks:
# hooks:
# - id: copyright_checker
# - id: copyright_checker
...
...
.travis.yml
浏览文件 @
17535d85
...
@@ -6,24 +6,45 @@ dist: trusty
...
@@ -6,24 +6,45 @@ dist: trusty
os
:
os
:
-
linux
-
linux
env
:
env
:
-
JOB=check_style
global
:
# CMake
-
CMAKE_URL=https://cmake.org/files/v3.11/cmake-3.11.1-Linux-x86_64.tar.gz
addons
:
addons
:
apt
:
apt
:
sources
:
-
llvm-toolchain-trusty-6.0
-
ubuntu-toolchain-r-test
packages
:
packages
:
-
git
-
git
-
python
-
python
-
python-pip
-
python-pip
-
python2.7-dev
-
python2.7-dev
-
clang-format-3.8
-
clang-6.0
-
libc6-i386
-
curl
compiler
:
-
clang
before_install
:
before_install
:
-
sudo pip install -U virtualenv pre-commit pip
-
sudo pip install -U virtualenv pre-commit pip
# Download and install recent cmake
-
|
if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
CMAKE_URL=${CMAKE_URL}
mkdir -p ${DEPS_DIR}/cmake
travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C ${DEPS_DIR}/cmake
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
fi
install
:
-
if [ "$CXX" = "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi
-
if [ "$CXX" = "clang++" ]; then export CXX="clang++-6.0" CC="clang-6.0"; fi
script
:
script
:
-
if [[ "$JOB" == "check_style" ]]; then sudo ln -s /usr/bin/clang-format-3.8 /usr/bin/clang-format; fi
-
|
-
|
function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
echo "==============="
-
|
-
|
timeout 600 .travis/${JOB}.sh # 10min timeout
timeout 600 .travis/${JOB}.sh # 10min timeout
RESULT=$?; if [ $RESULT -eq 0 ] || [ $RESULT -eq 142 ]; then true; else exit 1; fi;
RESULT=$?; if [ $RESULT -eq 0 ] || [ $RESULT -eq 142 ]; then true; else exit 1; fi;
...
...
.travis/check_style.sh
浏览文件 @
17535d85
#!/bin/bash
#!/bin/bash
function
abort
(){
function
abort
(){
echo
"Your change doesn't follow Paddle
Padd
le's code style"
1>&2
echo
"Your change doesn't follow Paddle
-Moib
le's code style"
1>&2
echo
"Please use pre-commit to auto-format your code."
1>&2
echo
"Please use pre-commit to auto-format your code."
1>&2
exit
1
exit
1
}
}
...
@@ -11,7 +11,7 @@ cd `dirname $0`
...
@@ -11,7 +11,7 @@ cd `dirname $0`
cd
..
cd
..
export
PATH
=
/usr/bin:
$PATH
export
PATH
=
/usr/bin:
$PATH
pre-commit
install
pre-commit
install
clang-format
--version
#
clang-format --version
if
!
pre-commit run
-a
;
then
if
!
pre-commit run
-a
;
then
ls
-lh
ls
-lh
...
...
src/framework/block_desc.cpp
浏览文件 @
17535d85
...
@@ -19,32 +19,32 @@ SOFTWARE.
...
@@ -19,32 +19,32 @@ SOFTWARE.
#include "block_desc.h"
#include "block_desc.h"
namespace
paddle_mobile
{
namespace
paddle_mobile
{
namespace
framework
{
namespace
framework
{
std
::
vector
<
std
::
shared_ptr
<
VarDesc
>>
BlockDesc
::
Vars
()
const
{
std
::
vector
<
std
::
shared_ptr
<
VarDesc
>>
BlockDesc
::
Vars
()
const
{
std
::
vector
<
std
::
shared_ptr
<
VarDesc
>>
res
;
std
::
vector
<
std
::
shared_ptr
<
VarDesc
>>
res
;
for
(
const
auto
&
p
:
vars_
)
{
for
(
const
auto
&
p
:
vars_
)
{
res
.
push_back
(
p
.
second
);
res
.
push_back
(
p
.
second
);
}
}
return
res
;
return
res
;
}
}
std
::
vector
<
std
::
shared_ptr
<
OpDesc
>>
BlockDesc
::
Ops
()
const
{
std
::
vector
<
std
::
shared_ptr
<
OpDesc
>>
BlockDesc
::
Ops
()
const
{
std
::
vector
<
std
::
shared_ptr
<
OpDesc
>>
res
;
std
::
vector
<
std
::
shared_ptr
<
OpDesc
>>
res
;
for
(
const
auto
&
op
:
ops_
)
{
for
(
const
auto
&
op
:
ops_
)
{
res
.
push_back
(
op
);
res
.
push_back
(
op
);
}
}
return
res
;
return
res
;
}
}
BlockDesc
::
BlockDesc
(
const
proto
::
BlockDesc
&
desc
)
:
desc_
(
desc
)
{
BlockDesc
::
BlockDesc
(
const
proto
::
BlockDesc
&
desc
)
:
desc_
(
desc
)
{
for
(
const
proto
::
VarDesc
&
var_desc
:
desc_
.
vars
())
{
for
(
const
proto
::
VarDesc
&
var_desc
:
desc_
.
vars
())
{
vars_
[
var_desc
.
name
()].
reset
(
new
VarDesc
(
var_desc
));
vars_
[
var_desc
.
name
()].
reset
(
new
VarDesc
(
var_desc
));
}
}
for
(
const
proto
::
OpDesc
&
op_desc
:
desc_
.
ops
())
{
for
(
const
proto
::
OpDesc
&
op_desc
:
desc_
.
ops
())
{
ops_
.
emplace_back
(
new
framework
::
OpDesc
(
op_desc
));
ops_
.
emplace_back
(
new
framework
::
OpDesc
(
op_desc
));
}
}
}
}
}
// namespace framework
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace paddle_mobile
src/platform/data_type.h
浏览文件 @
17535d85
...
@@ -19,107 +19,107 @@ limitations under the License. */
...
@@ -19,107 +19,107 @@ limitations under the License. */
#include <typeindex>
#include <typeindex>
namespace
paddle_mobile
{
namespace
paddle_mobile
{
namespace
framework
{
namespace
framework
{
inline
proto
::
VarType
::
Type
ToDataType
(
std
::
type_index
type
)
{
inline
proto
::
VarType
::
Type
ToDataType
(
std
::
type_index
type
)
{
/*if (typeid(platform::float16).hash_code() == type.hash_code()) {
/*if (typeid(platform::float16).hash_code() == type.hash_code()) {
return proto::VarType::FP16;
return proto::VarType::FP16;
} else */
} else */
if
(
typeid
(
const
float
).
hash_code
()
==
type
.
hash_code
())
{
if
(
typeid
(
const
float
).
hash_code
()
==
type
.
hash_code
())
{
// CPPLint complains Using C-style cast. Use
// CPPLint complains Using C-style cast. Use
// static_cast<float>() instead
// static_cast<float>() instead
// One fix to this is to replace float with const float because
// One fix to this is to replace float with const float because
// typeid(T) == typeid(const T)
// typeid(T) == typeid(const T)
// http://en.cppreference.com/w/cpp/language/typeid
// http://en.cppreference.com/w/cpp/language/typeid
return
proto
::
VarType
::
FP32
;
return
proto
::
VarType
::
FP32
;
}
else
if
(
typeid
(
const
double
).
hash_code
()
==
type
.
hash_code
())
{
}
else
if
(
typeid
(
const
double
).
hash_code
()
==
type
.
hash_code
())
{
return
proto
::
VarType
::
FP64
;
return
proto
::
VarType
::
FP64
;
}
else
if
(
typeid
(
const
int
).
hash_code
()
==
type
.
hash_code
())
{
}
else
if
(
typeid
(
const
int
).
hash_code
()
==
type
.
hash_code
())
{
return
proto
::
VarType
::
INT32
;
return
proto
::
VarType
::
INT32
;
}
else
if
(
typeid
(
const
int64_t
).
hash_code
()
==
type
.
hash_code
())
{
}
else
if
(
typeid
(
const
int64_t
).
hash_code
()
==
type
.
hash_code
())
{
return
proto
::
VarType
::
INT64
;
return
proto
::
VarType
::
INT64
;
}
else
if
(
typeid
(
const
bool
).
hash_code
()
==
type
.
hash_code
())
{
}
else
if
(
typeid
(
const
bool
).
hash_code
()
==
type
.
hash_code
())
{
return
proto
::
VarType
::
BOOL
;
return
proto
::
VarType
::
BOOL
;
}
else
{
}
else
{
// PADDLE_THROW("Not supported");
// PADDLE_THROW("Not supported");
// std::cout << "Not supported";
// std::cout << "Not supported";
}
}
}
}
inline
std
::
type_index
ToTypeIndex
(
proto
::
VarType
::
Type
type
)
{
inline
std
::
type_index
ToTypeIndex
(
proto
::
VarType
::
Type
type
)
{
switch
(
type
)
{
switch
(
type
)
{
// case proto::VarType::FP16:
// case proto::VarType::FP16:
// return typeid(platform::float16);
// return typeid(platform::float16);
case
proto
::
VarType
::
FP32
:
case
proto
::
VarType
::
FP32
:
return
typeid
(
float
);
return
typeid
(
float
);
case
proto
::
VarType
::
FP64
:
case
proto
::
VarType
::
FP64
:
return
typeid
(
double
);
return
typeid
(
double
);
case
proto
::
VarType
::
INT32
:
case
proto
::
VarType
::
INT32
:
return
typeid
(
int
);
return
typeid
(
int
);
case
proto
::
VarType
::
INT64
:
case
proto
::
VarType
::
INT64
:
return
typeid
(
int64_t
);
return
typeid
(
int64_t
);
case
proto
::
VarType
::
BOOL
:
case
proto
::
VarType
::
BOOL
:
return
typeid
(
bool
);
return
typeid
(
bool
);
default:
default:
// PADDLE_THROW("Not support type %d", type);
// PADDLE_THROW("Not support type %d", type);
printf
(
"Not support type %d"
,
type
);
printf
(
"Not support type %d"
,
type
);
}
}
}
}
template
<
typename
Visitor
>
template
<
typename
Visitor
>
inline
void
VisitDataType
(
proto
::
VarType
::
Type
type
,
Visitor
visitor
)
{
inline
void
VisitDataType
(
proto
::
VarType
::
Type
type
,
Visitor
visitor
)
{
switch
(
type
)
{
switch
(
type
)
{
// case proto::VarType::FP16:
// case proto::VarType::FP16:
// visitor.template operator()<platform::float16>();
// visitor.template operator()<platform::float16>();
// break;
// break;
case
proto
::
VarType
::
FP32
:
case
proto
::
VarType
::
FP32
:
visitor
.
template
operator
()
<
float
>();
visitor
.
template
operator
()
<
float
>();
break
;
break
;
case
proto
::
VarType
::
FP64
:
case
proto
::
VarType
::
FP64
:
visitor
.
template
operator
()
<
double
>();
visitor
.
template
operator
()
<
double
>();
break
;
break
;
case
proto
::
VarType
::
INT32
:
case
proto
::
VarType
::
INT32
:
visitor
.
template
operator
()
<
int
>();
visitor
.
template
operator
()
<
int
>();
break
;
break
;
case
proto
::
VarType
::
INT64
:
case
proto
::
VarType
::
INT64
:
visitor
.
template
operator
()
<
int64_t
>();
visitor
.
template
operator
()
<
int64_t
>();
break
;
break
;
case
proto
::
VarType
::
BOOL
:
case
proto
::
VarType
::
BOOL
:
visitor
.
template
operator
()
<
bool
>();
visitor
.
template
operator
()
<
bool
>();
break
;
break
;
default:
default:
// PADDLE_THROW("Not supported");
// PADDLE_THROW("Not supported");
printf
(
"Not supported"
);
printf
(
"Not supported"
);
}
}
}
}
inline
std
::
string
DataTypeToString
(
const
proto
::
VarType
::
Type
type
)
{
inline
std
::
string
DataTypeToString
(
const
proto
::
VarType
::
Type
type
)
{
switch
(
type
)
{
switch
(
type
)
{
case
proto
::
VarType
::
FP16
:
case
proto
::
VarType
::
FP16
:
return
"float16"
;
return
"float16"
;
case
proto
::
VarType
::
FP32
:
case
proto
::
VarType
::
FP32
:
return
"float32"
;
return
"float32"
;
case
proto
::
VarType
::
FP64
:
case
proto
::
VarType
::
FP64
:
return
"float64"
;
return
"float64"
;
case
proto
::
VarType
::
INT16
:
case
proto
::
VarType
::
INT16
:
return
"int16"
;
return
"int16"
;
case
proto
::
VarType
::
INT32
:
case
proto
::
VarType
::
INT32
:
return
"int32"
;
return
"int32"
;
case
proto
::
VarType
::
INT64
:
case
proto
::
VarType
::
INT64
:
return
"int64"
;
return
"int64"
;
case
proto
::
VarType
::
BOOL
:
case
proto
::
VarType
::
BOOL
:
return
"bool"
;
return
"bool"
;
default:
default:
// PADDLE_THROW("Not support type %d", type);
// PADDLE_THROW("Not support type %d", type);
printf
(
"Not support type %d"
,
type
);
printf
(
"Not support type %d"
,
type
);
}
}
}
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
proto
::
VarType
::
Type
&
type
)
{
const
proto
::
VarType
::
Type
&
type
)
{
out
<<
DataTypeToString
(
type
);
out
<<
DataTypeToString
(
type
);
return
out
;
return
out
;
}
}
}
// namespace framework
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace paddle_mobile
tools/pre-commit.hooks/clang-format.bash
已删除
100755 → 0
浏览文件 @
5d7a4caa
#!/bin/bash
set
-e
readonly
VERSION
=
"version 3."
version
=
$(
clang-format
-version
)
if
!
[[
$version
==
*
"
$VERSION
"
*
]]
;
then
echo
"clang-format version check failed."
echo
"a version contains '
$VERSION
' is needed, but get '
$version
'"
echo
"you can install the right version, and make an soft-link to '
\$
PATH' env"
exit
-1
fi
clang-format
$@
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录