Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
7797e55f
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7797e55f
编写于
8月 14, 2018
作者:
C
chenweihang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use paddle::platform::demangle
上级
21d5b942
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
4 addition
and
150 deletion
+4
-150
paddle/fluid/framework/CMakeLists.txt
paddle/fluid/framework/CMakeLists.txt
+0
-2
paddle/fluid/framework/attribute.h
paddle/fluid/framework/attribute.h
+4
-5
paddle/fluid/framework/attribute_type.h
paddle/fluid/framework/attribute_type.h
+0
-97
paddle/fluid/framework/attribute_type_test.cc
paddle/fluid/framework/attribute_type_test.cc
+0
-46
未找到文件。
paddle/fluid/framework/CMakeLists.txt
浏览文件 @
7797e55f
...
...
@@ -115,8 +115,6 @@ cc_test(cow_ptr_tests SRCS details/cow_ptr_test.cc)
# cc_test(channel_test SRCS channel_test.cc)
cc_test
(
tuple_test SRCS tuple_test.cc
)
cc_test
(
attribute_type_test SRCS attribute_type_test.cc
)
# disable test temporarily.
# TODO https://github.com/PaddlePaddle/Paddle/issues/11971
# cc_test(concurrency_test SRCS concurrency_test.cc DEPS go_op channel_close_op channel_create_op
...
...
paddle/fluid/framework/attribute.h
浏览文件 @
7797e55f
...
...
@@ -20,7 +20,6 @@ limitations under the License. */
#include <unordered_set>
#include <vector>
#include "paddle/fluid/framework/attribute_type.h"
#include "paddle/fluid/framework/framework.pb.h"
#include "paddle/fluid/framework/type_defs.h"
#include "paddle/fluid/platform/enforce.h"
...
...
@@ -129,8 +128,8 @@ struct ExtractAttribute {
attr_value
=
&
boost
::
get
<
T
>
(
attr
);
}
catch
(
boost
::
bad_get
&
bad_get
)
{
PADDLE_THROW
(
"Cannot get attribute %s by type %s, its type is %s"
,
attr_name_
,
paddle
::
framework
::
demangle
(
typeid
(
T
).
name
()),
paddle
::
framework
::
demangle
(
attr
.
type
().
name
()));
attr_name_
,
paddle
::
platform
::
demangle
(
typeid
(
T
).
name
()),
paddle
::
platform
::
demangle
(
attr
.
type
().
name
()));
}
return
attr_value
;
}
...
...
@@ -162,7 +161,7 @@ struct ExtractAttribute<bool> {
attr_value
=
&
boost
::
get
<
bool
>
(
attr
);
}
catch
(
boost
::
bad_get
&
bad_get
)
{
PADDLE_THROW
(
"Cannot get attribute %s by type bool, its type is %s"
,
attr_name_
,
paddle
::
framework
::
demangle
(
attr
.
type
().
name
()));
attr_name_
,
paddle
::
platform
::
demangle
(
attr
.
type
().
name
()));
}
return
attr_value
;
}
...
...
@@ -188,7 +187,7 @@ struct ExtractAttribute<int64_t> {
attr_value
=
&
boost
::
get
<
int64_t
>
(
attr
);
}
catch
(
boost
::
bad_get
&
bad_get
)
{
PADDLE_THROW
(
"Cannot get attribute %s by type int64_t, its type is %s"
,
attr_name_
,
paddle
::
framework
::
demangle
(
attr
.
type
().
name
()));
attr_name_
,
paddle
::
platform
::
demangle
(
attr
.
type
().
name
()));
}
return
attr_value
;
}
...
...
paddle/fluid/framework/attribute_type.h
已删除
100644 → 0
浏览文件 @
21d5b942
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <string>
// __has_include is currently supported by GCC and Clang. However GCC 4.9 may
// have issues and
// returns 1 for 'defined( __has_include )', while '__has_include' is actually
// not supported:
#if defined(__has_include) && (!defined(BOOST_GCC) || (__GNUC__ + 0) >= 5)
#if __has_include(<cxxabi.h>)
#define PADDLE_FRAMEWORK_HAS_CXXABI_H
#endif
#elif defined(__GLIBCXX__) || defined(__GLIBCPP__)
#define PADDLE_FRAMEWORK_HAS_CXXABI_H
#endif
#if defined(PADDLE_FRAMEWORK_HAS_CXXABI_H)
#include <cxxabi.h>
// For some archtectures (mips, mips64, x86, x86_64) cxxabi.h in Android NDK is
// implemented by gabi++ library
// which does not implement abi::__cxa_demangle(). We detect this implementation
// by checking the include guard here.
#if defined(__GABIXX_CXXABI_H__)
#undef PADDLE_FRAMEWORK_HAS_CXXABI_H
#else
#include <cstddef>
#include <cstdlib>
#endif
#endif
namespace
paddle
{
namespace
framework
{
inline
char
const
*
demangle_alloc
(
char
const
*
name
);
inline
void
demangle_free
(
char
const
*
name
);
class
scoped_demangled_name
{
private:
char
const
*
m_p
;
public:
explicit
scoped_demangled_name
(
char
const
*
name
)
:
m_p
(
demangle_alloc
(
name
))
{}
~
scoped_demangled_name
()
{
demangle_free
(
m_p
);
}
char
const
*
get
()
const
{
return
m_p
;
}
scoped_demangled_name
(
scoped_demangled_name
const
&
)
=
delete
;
scoped_demangled_name
&
operator
=
(
scoped_demangled_name
const
&
)
=
delete
;
};
#if defined(PADDLE_FRAMEWORK_HAS_CXXABI_H)
inline
char
const
*
demangle_alloc
(
char
const
*
name
)
{
int
status
=
0
;
std
::
size_t
size
=
0
;
return
abi
::
__cxa_demangle
(
name
,
NULL
,
&
size
,
&
status
);
}
inline
void
demangle_free
(
char
const
*
name
)
{
std
::
free
(
const_cast
<
char
*>
(
name
));
}
inline
std
::
string
demangle
(
char
const
*
name
)
{
scoped_demangled_name
demangled_name
(
name
);
char
const
*
p
=
demangled_name
.
get
();
if
(
!
p
)
p
=
name
;
return
p
;
}
#else
inline
char
const
*
demangle_alloc
(
char
const
*
name
)
{
return
name
;
}
inline
void
demangle_free
(
char
const
*
)
{}
inline
std
::
string
demangle
(
char
const
*
name
)
{
return
name
;
}
#endif
}
// namespace framework
}
// namespace paddle
paddle/fluid/framework/attribute_type_test.cc
已删除
100644 → 0
浏览文件 @
21d5b942
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */
#include <string>
#include <vector>
#include "gtest/gtest.h"
#include "paddle/fluid/framework/attribute_type.h"
TEST
(
Attribute
,
TypeName
)
{
bool
boolean
;
int
integer
;
float
ft
;
std
::
string
str
;
std
::
vector
<
bool
>
booleans
;
std
::
vector
<
int
>
integers
;
std
::
vector
<
std
::
string
>
strings
;
EXPECT_EQ
(
"bool"
,
paddle
::
framework
::
demangle
(
typeid
(
boolean
).
name
()));
EXPECT_EQ
(
"int"
,
paddle
::
framework
::
demangle
(
typeid
(
integer
).
name
()));
EXPECT_EQ
(
"float"
,
paddle
::
framework
::
demangle
(
typeid
(
ft
).
name
()));
EXPECT_EQ
(
"std::__cxx11::basic_string<char, std::char_traits<char>, "
"std::allocator<char> >"
,
paddle
::
framework
::
demangle
(
typeid
(
str
).
name
()));
EXPECT_EQ
(
"std::vector<bool, std::allocator<bool> >"
,
paddle
::
framework
::
demangle
(
typeid
(
booleans
).
name
()));
EXPECT_EQ
(
"std::vector<int, std::allocator<int> >"
,
paddle
::
framework
::
demangle
(
typeid
(
integers
).
name
()));
EXPECT_EQ
(
"std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, "
"std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, "
"std::char_traits<char>, std::allocator<char> > > >"
,
paddle
::
framework
::
demangle
(
typeid
(
strings
).
name
()));
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录