Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
17535d85
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
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
BasedOnStyle: LLVM
Standard: Cpp11
IndentWidth: 4
NamespaceIndentation: All
...
.pre-commit-config.yaml
浏览文件 @
17535d85
...
...
@@ -20,15 +20,15 @@ repos:
-
id
:
trailing-whitespace
files
:
(src).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
-
repo
:
local
hooks
:
-
id
:
clang-format-with-version-check
name
:
clang-format
description
:
Format files with ClangFormat.
entry
:
bash ./tools/pre-commit.hooks/.clang_format.hook -i
language
:
system
files
:
(src).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
#
- repo: local
#
hooks:
#
- id: clang-format-with-version-check
#
name: clang-format
#
description: Format files with ClangFormat.
#
entry: bash ./tools/pre-commit.hooks/.clang_format.hook -i
#
language: system
#
files: (src).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
#
#- repo: local
# hooks:
# - id: copyright_checker
...
...
.travis.yml
浏览文件 @
17535d85
...
...
@@ -6,24 +6,45 @@ dist: trusty
os
:
-
linux
env
:
-
JOB=check_style
global
:
# CMake
-
CMAKE_URL=https://cmake.org/files/v3.11/cmake-3.11.1-Linux-x86_64.tar.gz
addons
:
apt
:
sources
:
-
llvm-toolchain-trusty-6.0
-
ubuntu-toolchain-r-test
packages
:
-
git
-
python
-
python-pip
-
python2.7-dev
-
clang-format-3.8
-
clang-6.0
-
libc6-i386
-
curl
compiler
:
-
clang
before_install
:
-
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
:
-
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' "$@"; }
echo "==============="
-
|
timeout 600 .travis/${JOB}.sh # 10min timeout
RESULT=$?; if [ $RESULT -eq 0 ] || [ $RESULT -eq 142 ]; then true; else exit 1; fi;
...
...
.travis/check_style.sh
浏览文件 @
17535d85
#!/bin/bash
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
exit
1
}
...
...
@@ -11,7 +11,7 @@ cd `dirname $0`
cd
..
export
PATH
=
/usr/bin:
$PATH
pre-commit
install
clang-format
--version
#
clang-format --version
if
!
pre-commit run
-a
;
then
ls
-lh
...
...
src/framework/block_desc.cpp
浏览文件 @
17535d85
...
...
@@ -19,32 +19,32 @@ SOFTWARE.
#include "block_desc.h"
namespace
paddle_mobile
{
namespace
framework
{
namespace
framework
{
std
::
vector
<
std
::
shared_ptr
<
VarDesc
>>
BlockDesc
::
Vars
()
const
{
std
::
vector
<
std
::
shared_ptr
<
VarDesc
>>
res
;
for
(
const
auto
&
p
:
vars_
)
{
res
.
push_back
(
p
.
second
);
}
return
res
;
}
std
::
vector
<
std
::
shared_ptr
<
VarDesc
>>
BlockDesc
::
Vars
()
const
{
std
::
vector
<
std
::
shared_ptr
<
VarDesc
>>
res
;
for
(
const
auto
&
p
:
vars_
)
{
res
.
push_back
(
p
.
second
);
}
return
res
;
}
std
::
vector
<
std
::
shared_ptr
<
OpDesc
>>
BlockDesc
::
Ops
()
const
{
std
::
vector
<
std
::
shared_ptr
<
OpDesc
>>
res
;
for
(
const
auto
&
op
:
ops_
)
{
res
.
push_back
(
op
);
}
return
res
;
}
std
::
vector
<
std
::
shared_ptr
<
OpDesc
>>
BlockDesc
::
Ops
()
const
{
std
::
vector
<
std
::
shared_ptr
<
OpDesc
>>
res
;
for
(
const
auto
&
op
:
ops_
)
{
res
.
push_back
(
op
);
}
return
res
;
}
BlockDesc
::
BlockDesc
(
const
proto
::
BlockDesc
&
desc
)
:
desc_
(
desc
)
{
for
(
const
proto
::
VarDesc
&
var_desc
:
desc_
.
vars
())
{
vars_
[
var_desc
.
name
()].
reset
(
new
VarDesc
(
var_desc
));
}
for
(
const
proto
::
OpDesc
&
op_desc
:
desc_
.
ops
())
{
ops_
.
emplace_back
(
new
framework
::
OpDesc
(
op_desc
));
}
}
BlockDesc
::
BlockDesc
(
const
proto
::
BlockDesc
&
desc
)
:
desc_
(
desc
)
{
for
(
const
proto
::
VarDesc
&
var_desc
:
desc_
.
vars
())
{
vars_
[
var_desc
.
name
()].
reset
(
new
VarDesc
(
var_desc
));
}
for
(
const
proto
::
OpDesc
&
op_desc
:
desc_
.
ops
())
{
ops_
.
emplace_back
(
new
framework
::
OpDesc
(
op_desc
));
}
}
}
// namespace framework
}
// namespace framework
}
// namespace paddle_mobile
src/platform/data_type.h
浏览文件 @
17535d85
...
...
@@ -19,107 +19,107 @@ limitations under the License. */
#include <typeindex>
namespace
paddle_mobile
{
namespace
framework
{
namespace
framework
{
inline
proto
::
VarType
::
Type
ToDataType
(
std
::
type_index
type
)
{
/*if (typeid(platform::float16).hash_code() == type.hash_code()) {
return proto::VarType::FP16;
} else */
if
(
typeid
(
const
float
).
hash_code
()
==
type
.
hash_code
())
{
// CPPLint complains Using C-style cast. Use
// static_cast<float>() instead
// One fix to this is to replace float with const float because
// typeid(T) == typeid(const T)
// http://en.cppreference.com/w/cpp/language/typeid
return
proto
::
VarType
::
FP32
;
}
else
if
(
typeid
(
const
double
).
hash_code
()
==
type
.
hash_code
())
{
return
proto
::
VarType
::
FP64
;
}
else
if
(
typeid
(
const
int
).
hash_code
()
==
type
.
hash_code
())
{
return
proto
::
VarType
::
INT32
;
}
else
if
(
typeid
(
const
int64_t
).
hash_code
()
==
type
.
hash_code
())
{
return
proto
::
VarType
::
INT64
;
}
else
if
(
typeid
(
const
bool
).
hash_code
()
==
type
.
hash_code
())
{
return
proto
::
VarType
::
BOOL
;
}
else
{
// PADDLE_THROW("Not supported");
// std::cout << "Not supported";
}
}
inline
proto
::
VarType
::
Type
ToDataType
(
std
::
type_index
type
)
{
/*if (typeid(platform::float16).hash_code() == type.hash_code()) {
return proto::VarType::FP16;
} else */
if
(
typeid
(
const
float
).
hash_code
()
==
type
.
hash_code
())
{
// CPPLint complains Using C-style cast. Use
// static_cast<float>() instead
// One fix to this is to replace float with const float because
// typeid(T) == typeid(const T)
// http://en.cppreference.com/w/cpp/language/typeid
return
proto
::
VarType
::
FP32
;
}
else
if
(
typeid
(
const
double
).
hash_code
()
==
type
.
hash_code
())
{
return
proto
::
VarType
::
FP64
;
}
else
if
(
typeid
(
const
int
).
hash_code
()
==
type
.
hash_code
())
{
return
proto
::
VarType
::
INT32
;
}
else
if
(
typeid
(
const
int64_t
).
hash_code
()
==
type
.
hash_code
())
{
return
proto
::
VarType
::
INT64
;
}
else
if
(
typeid
(
const
bool
).
hash_code
()
==
type
.
hash_code
())
{
return
proto
::
VarType
::
BOOL
;
}
else
{
// PADDLE_THROW("Not supported");
// std::cout << "Not supported";
}
}
inline
std
::
type_index
ToTypeIndex
(
proto
::
VarType
::
Type
type
)
{
switch
(
type
)
{
// case proto::VarType::FP16:
// return typeid(platform::float16);
case
proto
::
VarType
::
FP32
:
return
typeid
(
float
);
case
proto
::
VarType
::
FP64
:
return
typeid
(
double
);
case
proto
::
VarType
::
INT32
:
return
typeid
(
int
);
case
proto
::
VarType
::
INT64
:
return
typeid
(
int64_t
);
case
proto
::
VarType
::
BOOL
:
return
typeid
(
bool
);
default:
// PADDLE_THROW("Not support type %d", type);
printf
(
"Not support type %d"
,
type
);
}
}
inline
std
::
type_index
ToTypeIndex
(
proto
::
VarType
::
Type
type
)
{
switch
(
type
)
{
// case proto::VarType::FP16:
// return typeid(platform::float16);
case
proto
::
VarType
::
FP32
:
return
typeid
(
float
);
case
proto
::
VarType
::
FP64
:
return
typeid
(
double
);
case
proto
::
VarType
::
INT32
:
return
typeid
(
int
);
case
proto
::
VarType
::
INT64
:
return
typeid
(
int64_t
);
case
proto
::
VarType
::
BOOL
:
return
typeid
(
bool
);
default:
// PADDLE_THROW("Not support type %d", type);
printf
(
"Not support type %d"
,
type
);
}
}
template
<
typename
Visitor
>
inline
void
VisitDataType
(
proto
::
VarType
::
Type
type
,
Visitor
visitor
)
{
switch
(
type
)
{
// case proto::VarType::FP16:
// visitor.template operator()<platform::float16>();
// break;
case
proto
::
VarType
::
FP32
:
visitor
.
template
operator
()
<
float
>();
break
;
case
proto
::
VarType
::
FP64
:
visitor
.
template
operator
()
<
double
>();
break
;
case
proto
::
VarType
::
INT32
:
visitor
.
template
operator
()
<
int
>();
break
;
case
proto
::
VarType
::
INT64
:
visitor
.
template
operator
()
<
int64_t
>();
break
;
case
proto
::
VarType
::
BOOL
:
visitor
.
template
operator
()
<
bool
>();
break
;
default:
// PADDLE_THROW("Not supported");
printf
(
"Not supported"
);
}
}
template
<
typename
Visitor
>
inline
void
VisitDataType
(
proto
::
VarType
::
Type
type
,
Visitor
visitor
)
{
switch
(
type
)
{
// case proto::VarType::FP16:
// visitor.template operator()<platform::float16>();
// break;
case
proto
::
VarType
::
FP32
:
visitor
.
template
operator
()
<
float
>();
break
;
case
proto
::
VarType
::
FP64
:
visitor
.
template
operator
()
<
double
>();
break
;
case
proto
::
VarType
::
INT32
:
visitor
.
template
operator
()
<
int
>();
break
;
case
proto
::
VarType
::
INT64
:
visitor
.
template
operator
()
<
int64_t
>();
break
;
case
proto
::
VarType
::
BOOL
:
visitor
.
template
operator
()
<
bool
>();
break
;
default:
// PADDLE_THROW("Not supported");
printf
(
"Not supported"
);
}
}
inline
std
::
string
DataTypeToString
(
const
proto
::
VarType
::
Type
type
)
{
switch
(
type
)
{
case
proto
::
VarType
::
FP16
:
return
"float16"
;
case
proto
::
VarType
::
FP32
:
return
"float32"
;
case
proto
::
VarType
::
FP64
:
return
"float64"
;
case
proto
::
VarType
::
INT16
:
return
"int16"
;
case
proto
::
VarType
::
INT32
:
return
"int32"
;
case
proto
::
VarType
::
INT64
:
return
"int64"
;
case
proto
::
VarType
::
BOOL
:
return
"bool"
;
default:
// PADDLE_THROW("Not support type %d", type);
printf
(
"Not support type %d"
,
type
);
}
}
inline
std
::
string
DataTypeToString
(
const
proto
::
VarType
::
Type
type
)
{
switch
(
type
)
{
case
proto
::
VarType
::
FP16
:
return
"float16"
;
case
proto
::
VarType
::
FP32
:
return
"float32"
;
case
proto
::
VarType
::
FP64
:
return
"float64"
;
case
proto
::
VarType
::
INT16
:
return
"int16"
;
case
proto
::
VarType
::
INT32
:
return
"int32"
;
case
proto
::
VarType
::
INT64
:
return
"int64"
;
case
proto
::
VarType
::
BOOL
:
return
"bool"
;
default:
// PADDLE_THROW("Not support type %d", type);
printf
(
"Not support type %d"
,
type
);
}
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
proto
::
VarType
::
Type
&
type
)
{
out
<<
DataTypeToString
(
type
);
return
out
;
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
proto
::
VarType
::
Type
&
type
)
{
out
<<
DataTypeToString
(
type
);
return
out
;
}
}
// namespace framework
}
// namespace framework
}
// 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录