Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
7dceb8a0
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7dceb8a0
编写于
8月 26, 2018
作者:
D
dzhwinter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
check some operators
上级
26dbe35c
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
91 addition
and
89 deletion
+91
-89
paddle/fluid/inference/api/api_impl.cc
paddle/fluid/inference/api/api_impl.cc
+10
-13
paddle/fluid/operators/CMakeLists.txt
paddle/fluid/operators/CMakeLists.txt
+1
-1
paddle/fluid/operators/attention_lstm_op.cc
paddle/fluid/operators/attention_lstm_op.cc
+0
-1
paddle/fluid/operators/label_smooth_op.cc
paddle/fluid/operators/label_smooth_op.cc
+1
-1
paddle/fluid/operators/math/CMakeLists.txt
paddle/fluid/operators/math/CMakeLists.txt
+2
-0
paddle/fluid/operators/math/maxouting.h
paddle/fluid/operators/math/maxouting.h
+1
-2
paddle/fluid/operators/math/pooling.h
paddle/fluid/operators/math/pooling.h
+1
-4
paddle/fluid/operators/save_combine_op.cc
paddle/fluid/operators/save_combine_op.cc
+1
-31
paddle/fluid/operators/save_op.cc
paddle/fluid/operators/save_op.cc
+1
-31
paddle/fluid/platform/dynload/dynamic_loader.cc
paddle/fluid/platform/dynload/dynamic_loader.cc
+8
-3
paddle/fluid/platform/macros.h
paddle/fluid/platform/macros.h
+7
-0
paddle/fluid/platform/port.h
paddle/fluid/platform/port.h
+58
-2
未找到文件。
paddle/fluid/inference/api/api_impl.cc
浏览文件 @
7dceb8a0
...
@@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include <sys/time.h>
#include <algorithm>
#include <algorithm>
#include <chrono> // NOLINT
#include <map>
#include <map>
#include <set>
#include <set>
#include <sstream>
#include <sstream>
...
@@ -32,19 +32,16 @@ namespace {
...
@@ -32,19 +32,16 @@ namespace {
// Timer for timer
// Timer for timer
class
Timer
{
class
Timer
{
public:
public:
double
start
;
std
::
chrono
::
high_resolution_clock
::
time_point
start
;
double
startu
;
std
::
chrono
::
high_resolution_clock
::
time_point
startu
;
void
tic
()
{
struct
timeval
tp
;
void
tic
()
{
start
=
std
::
chrono
::
high_resolution_clock
::
now
();
}
gettimeofday
(
&
tp
,
NULL
);
start
=
tp
.
tv_sec
;
startu
=
tp
.
tv_usec
;
}
double
toc
()
{
double
toc
()
{
struct
timeval
tp
;
startu
=
std
::
chrono
::
high_resolution_clock
::
now
();
gettimeofday
(
&
tp
,
NULL
);
std
::
chrono
::
duration
<
double
>
time_span
=
double
used_time_ms
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
duration
<
double
>>
(
startu
-
(
tp
.
tv_sec
-
start
)
*
1000.0
+
(
tp
.
tv_usec
-
startu
)
/
1000.0
;
start
);
double
used_time_ms
=
static_cast
<
double
>
(
time_span
.
count
())
*
1000.0
;
return
used_time_ms
;
return
used_time_ms
;
}
}
};
};
...
...
paddle/fluid/operators/CMakeLists.txt
浏览文件 @
7dceb8a0
...
@@ -85,7 +85,7 @@ function(op_library TARGET)
...
@@ -85,7 +85,7 @@ function(op_library TARGET)
#remove windows unsupported op
#remove windows unsupported op
if
(
WIN32
)
if
(
WIN32
)
foreach
(
windows_unsupport_op
"nccl_op"
"gen_nccl_id_op"
"warpctc_op"
"hierarchical_sigmoid_op"
)
foreach
(
windows_unsupport_op
"nccl_op"
"gen_nccl_id_op"
"warpctc_op"
"hierarchical_sigmoid_op"
"crf_decoding_op"
)
if
(
"
${
TARGET
}
"
STREQUAL
"
${
windows_unsupport_op
}
"
)
if
(
"
${
TARGET
}
"
STREQUAL
"
${
windows_unsupport_op
}
"
)
return
()
return
()
endif
()
endif
()
...
...
paddle/fluid/operators/attention_lstm_op.cc
浏览文件 @
7dceb8a0
...
@@ -13,7 +13,6 @@ See the License for the specific language governing permissions and
...
@@ -13,7 +13,6 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/fluid/operators/attention_lstm_op.h"
#include "paddle/fluid/operators/attention_lstm_op.h"
#include <sys/time.h>
#include <string>
#include <string>
#include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/cpu_vec.h"
#include "paddle/fluid/operators/math/cpu_vec.h"
...
...
paddle/fluid/operators/label_smooth_op.cc
浏览文件 @
7dceb8a0
...
@@ -34,7 +34,7 @@ class LabelSmoothOp : public framework::OperatorWithKernel {
...
@@ -34,7 +34,7 @@ class LabelSmoothOp : public framework::OperatorWithKernel {
auto
in_dims
=
ctx
->
GetInputDim
(
"X"
);
auto
in_dims
=
ctx
->
GetInputDim
(
"X"
);
if
(
ctx
->
HasInput
(
"PriorDist"
))
{
if
(
ctx
->
HasInput
(
"PriorDist"
))
{
auto
noise_dims
=
ctx
->
GetInputDim
(
"PriorDist"
);
auto
noise_dims
=
ctx
->
GetInputDim
(
"PriorDist"
);
auto
noise_numel
=
paddle
::
framework
::
product
(
noise_dims
);
int64_t
noise_numel
=
paddle
::
framework
::
product
(
noise_dims
);
PADDLE_ENFORCE
(
PADDLE_ENFORCE
(
in_dims
[
1
]
==
noise_numel
,
in_dims
[
1
]
==
noise_numel
,
"The number of elements in Input(PriorDist) must be equal to the "
"The number of elements in Input(PriorDist) must be equal to the "
...
...
paddle/fluid/operators/math/CMakeLists.txt
浏览文件 @
7dceb8a0
if
(
NOT WIN32
)
add_subdirectory
(
detail
)
add_subdirectory
(
detail
)
endif
(
NOT WIN32
)
function
(
math_library TARGET
)
function
(
math_library TARGET
)
# math_library is a function to create math library.
# math_library is a function to create math library.
...
...
paddle/fluid/operators/math/maxouting.h
浏览文件 @
7dceb8a0
...
@@ -16,13 +16,12 @@ limitations under the License. */
...
@@ -16,13 +16,12 @@ limitations under the License. */
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/hostdevice.h"
#include "paddle/fluid/platform/hostdevice.h"
#include "paddle/fluid/platform/macros.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
namespace
math
{
namespace
math
{
#define FLT_MAX __FLT_MAX__
template
<
typename
DeviceContext
,
typename
T
>
template
<
typename
DeviceContext
,
typename
T
>
class
MaxOutFunctor
{
class
MaxOutFunctor
{
public:
public:
...
...
paddle/fluid/operators/math/pooling.h
浏览文件 @
7dceb8a0
...
@@ -18,15 +18,12 @@ limitations under the License. */
...
@@ -18,15 +18,12 @@ limitations under the License. */
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/hostdevice.h"
#include "paddle/fluid/platform/hostdevice.h"
#include "paddle/fluid/platform/macros.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
namespace
math
{
namespace
math
{
#define FLT_MAX \
__FLT_MAX__ // TODO(zcd) :It might need to be placed in another file, but I'm
// still wondering where to put it.
/*
/*
* \brief Extracting simple operations from pooling.
* \brief Extracting simple operations from pooling.
* Both MaxPool and AvgPool need "initial", "compute" and "finalize"
* Both MaxPool and AvgPool need "initial", "compute" and "finalize"
...
...
paddle/fluid/operators/save_combine_op.cc
浏览文件 @
7dceb8a0
...
@@ -13,7 +13,6 @@ See the License for the specific language governing permissions and
...
@@ -13,7 +13,6 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include <stdint.h>
#include <stdint.h>
#include <sys/stat.h>
#include <fstream>
#include <fstream>
#include <numeric>
#include <numeric>
#include <sstream>
#include <sstream>
...
@@ -23,40 +22,11 @@ limitations under the License. */
...
@@ -23,40 +22,11 @@ limitations under the License. */
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/port.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
// TODO(sidgoyal78): These function are needed by other files (save_op), move
// them to paddle::filesystem namespace. (as noted by yuyang18 in save_op).
constexpr
char
kSEP
=
'/'
;
static
bool
FileExists
(
const
std
::
string
&
filepath
)
{
struct
stat
buffer
;
return
(
stat
(
filepath
.
c_str
(),
&
buffer
)
==
0
);
}
static
std
::
string
DirName
(
const
std
::
string
&
filepath
)
{
auto
pos
=
filepath
.
rfind
(
kSEP
);
if
(
pos
==
std
::
string
::
npos
)
{
return
""
;
}
return
filepath
.
substr
(
0
,
pos
);
}
static
void
MkDir
(
const
char
*
path
)
{
if
(
mkdir
(
path
,
0755
))
{
PADDLE_ENFORCE_EQ
(
errno
,
EEXIST
,
"%s mkdir failed!"
,
path
);
}
}
static
void
MkDirRecursively
(
const
char
*
fullpath
)
{
if
(
*
fullpath
==
'\0'
)
return
;
// empty string
if
(
FileExists
(
fullpath
))
return
;
MkDirRecursively
(
DirName
(
fullpath
).
c_str
());
MkDir
(
fullpath
);
}
class
SaveCombineOp
:
public
framework
::
OperatorBase
{
class
SaveCombineOp
:
public
framework
::
OperatorBase
{
public:
public:
SaveCombineOp
(
const
std
::
string
&
type
,
SaveCombineOp
(
const
std
::
string
&
type
,
...
...
paddle/fluid/operators/save_op.cc
浏览文件 @
7dceb8a0
...
@@ -13,7 +13,6 @@ See the License for the specific language governing permissions and
...
@@ -13,7 +13,6 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include <stdint.h>
#include <stdint.h>
#include <sys/stat.h>
#include <fstream>
#include <fstream>
#include <numeric>
#include <numeric>
...
@@ -25,6 +24,7 @@ limitations under the License. */
...
@@ -25,6 +24,7 @@ limitations under the License. */
#include "paddle/fluid/framework/selected_rows.h"
#include "paddle/fluid/framework/selected_rows.h"
#include "paddle/fluid/framework/variable.h"
#include "paddle/fluid/framework/variable.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/port.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
@@ -33,36 +33,6 @@ namespace operators {
...
@@ -33,36 +33,6 @@ namespace operators {
// to directory specified.
// to directory specified.
constexpr
char
LOOKUP_TABLE_PATH
[]
=
"kLookupTablePath"
;
constexpr
char
LOOKUP_TABLE_PATH
[]
=
"kLookupTablePath"
;
// TODO(yuyang18): If the functions below are needed by other files, move them
// to paddle::filesystem namespace.
constexpr
char
kSEP
=
'/'
;
static
bool
FileExists
(
const
std
::
string
&
filepath
)
{
struct
stat
buffer
;
return
(
stat
(
filepath
.
c_str
(),
&
buffer
)
==
0
);
}
static
std
::
string
DirName
(
const
std
::
string
&
filepath
)
{
auto
pos
=
filepath
.
rfind
(
kSEP
);
if
(
pos
==
std
::
string
::
npos
)
{
return
""
;
}
return
filepath
.
substr
(
0
,
pos
);
}
static
void
MkDir
(
const
char
*
path
)
{
if
(
mkdir
(
path
,
0755
))
{
PADDLE_ENFORCE_EQ
(
errno
,
EEXIST
,
"%s mkdir failed!"
,
path
);
}
}
static
void
MkDirRecursively
(
const
char
*
fullpath
)
{
if
(
*
fullpath
==
'\0'
)
return
;
// empty string
if
(
FileExists
(
fullpath
))
return
;
MkDirRecursively
(
DirName
(
fullpath
).
c_str
());
MkDir
(
fullpath
);
}
class
SaveOp
:
public
framework
::
OperatorBase
{
class
SaveOp
:
public
framework
::
OperatorBase
{
public:
public:
SaveOp
(
const
std
::
string
&
type
,
const
framework
::
VariableNameMap
&
inputs
,
SaveOp
(
const
std
::
string
&
type
,
const
framework
::
VariableNameMap
&
inputs
,
...
...
paddle/fluid/platform/dynload/dynamic_loader.cc
浏览文件 @
7dceb8a0
...
@@ -117,10 +117,15 @@ static inline void* GetDsoHandleFromSearchPath(const std::string& search_root,
...
@@ -117,10 +117,15 @@ static inline void* GetDsoHandleFromSearchPath(const std::string& search_root,
// search xxx.so from custom path
// search xxx.so from custom path
dlPath
=
join
(
search_root
,
dso_name
);
dlPath
=
join
(
search_root
,
dso_name
);
dso_handle
=
dlopen
(
dlPath
.
c_str
(),
dynload_flags
);
dso_handle
=
dlopen
(
dlPath
.
c_str
(),
dynload_flags
);
#if !defined(_WIN32)
auto
errorno
=
dlerror
();
#else
auto
errorno
=
GetLastError
();
#endif // !_WIN32
// if not found, search from default path
// if not found, search from default path
if
(
nullptr
==
dso_handle
)
{
if
(
nullptr
==
dso_handle
)
{
LOG
(
WARNING
)
<<
"Failed to find dynamic library: "
<<
dlPath
<<
" ("
LOG
(
WARNING
)
<<
"Failed to find dynamic library: "
<<
dlPath
<<
" ("
<<
dlerror
()
<<
")"
;
<<
errorno
<<
")"
;
dlPath
=
dso_name
;
dlPath
=
dso_name
;
dso_handle
=
GetDsoHandleFromDefaultPath
(
dlPath
,
dynload_flags
);
dso_handle
=
GetDsoHandleFromDefaultPath
(
dlPath
,
dynload_flags
);
}
}
...
@@ -134,9 +139,9 @@ static inline void* GetDsoHandleFromSearchPath(const std::string& search_root,
...
@@ -134,9 +139,9 @@ static inline void* GetDsoHandleFromSearchPath(const std::string& search_root,
"using the DYLD_LIBRARY_PATH is impossible unless System "
"using the DYLD_LIBRARY_PATH is impossible unless System "
"Integrity Protection (SIP) is disabled."
;
"Integrity Protection (SIP) is disabled."
;
if
(
throw_on_error
)
{
if
(
throw_on_error
)
{
PADDLE_ENFORCE
(
nullptr
!=
dso_handle
,
error_msg
,
dlPath
,
dlerror
()
);
PADDLE_ENFORCE
(
nullptr
!=
dso_handle
,
error_msg
,
dlPath
,
errorno
);
}
else
if
(
nullptr
==
dso_handle
)
{
}
else
if
(
nullptr
==
dso_handle
)
{
LOG
(
WARNING
)
<<
string
::
Sprintf
(
error_msg
,
dlPath
,
dlerror
()
);
LOG
(
WARNING
)
<<
string
::
Sprintf
(
error_msg
,
dlPath
,
errorno
);
}
}
return
dso_handle
;
return
dso_handle
;
...
...
paddle/fluid/platform/macros.h
浏览文件 @
7dceb8a0
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#pragma once
#pragma once
#include <limits>
// Disable the copy and assignment operator for a class.
// Disable the copy and assignment operator for a class.
#ifndef DISABLE_COPY_AND_ASSIGN
#ifndef DISABLE_COPY_AND_ASSIGN
...
@@ -23,3 +24,9 @@ limitations under the License. */
...
@@ -23,3 +24,9 @@ limitations under the License. */
classname& operator=(const classname&) = delete; \
classname& operator=(const classname&) = delete; \
classname& operator=(classname&&) = delete
classname& operator=(classname&&) = delete
#endif
#endif
#if defined(__FLT_MAX__)
#define FLT_MAX __FLT_MAX__
#else
#define FLT_MAX std::numeric_limits<float>::max()
#endif // __FLT_MAX__
paddle/fluid/platform/port.h
浏览文件 @
7dceb8a0
...
@@ -37,14 +37,24 @@
...
@@ -37,14 +37,24 @@
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
#endif
#endif
static
void
*
dlsym
(
void
*
handle
,
const
char
*
symbol_name
)
{
static
void
*
dlsym
(
void
*
handle
,
const
char
*
symbol_name
)
{
FARPROC
found_symbol
;
FARPROC
found_symbol
;
found_symbol
=
GetProcAddress
((
HMODULE
)
handle
,
symbol_name
);
found_symbol
=
GetProcAddress
((
HMODULE
)
handle
,
symbol_name
);
if
(
found_symbol
==
NULL
)
{
if
(
found_symbol
==
NULL
)
{
throw
std
::
runtime_error
(
std
::
string
(
symbol_name
)
+
" not found."
);
throw
std
::
runtime_error
(
std
::
string
(
symbol_name
)
+
" not found."
);
}
}
return
reinterpret_cast
<
void
*>
(
found_symbol
);
return
reinterpret_cast
<
void
*>
(
found_symbol
);
}
static
void
*
dlopen
(
const
char
*
filename
,
int
flag
)
{
std
::
string
file_name
(
filename
);
std
::
replace
(
file_name
.
begin
(),
file_name
.
end
(),
'/'
,
'\\'
);
HMODULE
hModule
=
LoadLibrary
(
file_name
);
if
(
!
hModule
)
{
throw
std
::
runtime_error
(
file_name
+
" not found."
);
}
return
reinterpret_cast
<
void
*>
(
hModule
);
}
}
#endif // !_WIN32
#endif // !_WIN32
...
@@ -85,3 +95,49 @@ static bool PathExists(const std::string &path) {
...
@@ -85,3 +95,49 @@ static bool PathExists(const std::string &path) {
#endif // !_WIN32
#endif // !_WIN32
return
false
;
return
false
;
}
}
// TODO(yuyang18): If the functions below are needed by other files, move them
// to paddle::filesystem namespace.
#if !defined(_WIN32)
constexpr
char
kSEP
=
'/'
;
#else
constexpr
char
kSEP
=
'\\'
;
#endif // _WIN32
static
bool
FileExists
(
const
std
::
string
&
filepath
)
{
#if !defined(_WIN32)
struct
stat
buffer
;
return
(
stat
(
filepath
.
c_str
(),
&
buffer
)
==
0
);
#else
struct
_stat
buffer
;
return
(
_stat
(
filepath
.
c_str
(),
&
buffer
)
==
0
);
#endif // !_WIN32
}
static
std
::
string
DirName
(
const
std
::
string
&
filepath
)
{
auto
pos
=
filepath
.
rfind
(
kSEP
);
if
(
pos
==
std
::
string
::
npos
)
{
return
""
;
}
return
filepath
.
substr
(
0
,
pos
);
}
static
void
MkDir
(
const
char
*
path
)
{
#if !defined(_WIN32)
if
(
mkdir
(
path
,
0755
))
{
PADDLE_ENFORCE_EQ
(
errno
,
EEXIST
,
"%s mkdir failed!"
,
path
);
}
#else
CreateDirectory
(
path
,
NULL
);
auto
errorno
=
GetLastError
();
PADDLE_ENFORCE_EQ
(
errorno
,
ERROR_ALREADY_EXISTS
,
"%s mkdir failed!"
,
path
);
#endif // !_WIN32
}
static
void
MkDirRecursively
(
const
char
*
fullpath
)
{
if
(
*
fullpath
==
'\0'
)
return
;
// empty string
if
(
FileExists
(
fullpath
))
return
;
MkDirRecursively
(
DirName
(
fullpath
).
c_str
());
MkDir
(
fullpath
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录