Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
6237f6f5
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6237f6f5
编写于
5月 03, 2017
作者:
L
liaogang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
revert clang-format
上级
b13871c3
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
129 addition
and
136 deletion
+129
-136
paddle/cuda/src/hl_cuda_device.cc
paddle/cuda/src/hl_cuda_device.cc
+13
-13
paddle/function/BufferArgTest.cpp
paddle/function/BufferArgTest.cpp
+1
-1
paddle/function/CosSimOp.cpp
paddle/function/CosSimOp.cpp
+6
-6
paddle/function/FunctionTest.cpp
paddle/function/FunctionTest.cpp
+1
-1
paddle/function/TensorShapeTest.cpp
paddle/function/TensorShapeTest.cpp
+1
-1
paddle/function/TensorTypeTest.cpp
paddle/function/TensorTypeTest.cpp
+1
-1
paddle/gserver/dataproviders/PyDataProvider.cpp
paddle/gserver/dataproviders/PyDataProvider.cpp
+2
-2
paddle/gserver/evaluators/Evaluator.cpp
paddle/gserver/evaluators/Evaluator.cpp
+3
-3
paddle/gserver/layers/Layer.cpp
paddle/gserver/layers/Layer.cpp
+2
-3
paddle/gserver/tests/test_RecurrentLayer.cpp
paddle/gserver/tests/test_RecurrentLayer.cpp
+19
-20
paddle/math/MatrixBitCode.cpp
paddle/math/MatrixBitCode.cpp
+14
-16
paddle/math/tests/TensorCheck.h
paddle/math/tests/TensorCheck.h
+2
-2
paddle/math/tests/test_SIMDFunctions.cpp
paddle/math/tests/test_SIMDFunctions.cpp
+9
-9
paddle/parameter/Argument.cpp
paddle/parameter/Argument.cpp
+24
-26
paddle/parameter/AverageOptimizer.cpp
paddle/parameter/AverageOptimizer.cpp
+2
-3
paddle/parameter/Parameter.cpp
paddle/parameter/Parameter.cpp
+2
-2
paddle/pserver/LightNetwork.cpp
paddle/pserver/LightNetwork.cpp
+2
-2
paddle/pserver/ParameterClient2.cpp
paddle/pserver/ParameterClient2.cpp
+6
-6
paddle/pserver/ParameterServer2.cpp
paddle/pserver/ParameterServer2.cpp
+2
-2
paddle/pserver/ParameterServer2.h
paddle/pserver/ParameterServer2.h
+4
-4
paddle/pserver/ProtoServer.cpp
paddle/pserver/ProtoServer.cpp
+2
-2
paddle/trainer/TrainerInternal.cpp
paddle/trainer/TrainerInternal.cpp
+1
-1
paddle/utils/BarrierStat.h
paddle/utils/BarrierStat.h
+8
-8
paddle/utils/ClassRegistrar.h
paddle/utils/ClassRegistrar.h
+2
-2
未找到文件。
paddle/cuda/src/hl_cuda_device.cc
浏览文件 @
6237f6f5
...
@@ -97,11 +97,11 @@ int g_cuda_lib_version = 0;
...
@@ -97,11 +97,11 @@ int g_cuda_lib_version = 0;
* Check build-in cuda function using glog and it **does not**
* Check build-in cuda function using glog and it **does not**
* support << operator for more details error info.
* support << operator for more details error info.
*/
*/
#define CHECK_CUDA(cudaFunc) \
#define CHECK_CUDA(cudaFunc)
\
do { \
do {
\
cudaError_t cudaStat = cudaFunc; \
cudaError_t cudaStat = cudaFunc;
\
CHECK_EQ(cudaSuccess, cudaStat)
\
CHECK_EQ(cudaSuccess, cudaStat)
<< "Cuda Error: "
\
<< "Cuda Error: "
<< cudaGetErrorString(cudaStat); \
<< cudaGetErrorString(cudaStat); \
} while (0)
} while (0)
/**
/**
...
@@ -468,8 +468,8 @@ void hl_specify_devices_start(int *device, int number) {
...
@@ -468,8 +468,8 @@ void hl_specify_devices_start(int *device, int number) {
CHECK
(
tmp
)
<<
"[Start failed] System memory is not enough."
;
CHECK
(
tmp
)
<<
"[Start failed] System memory is not enough."
;
g_device
=
(
hl_device_prop
*
)
tmp
;
g_device
=
(
hl_device_prop
*
)
tmp
;
device_prop
=
(
hl_device_prop
)(
(
char
*
)
tmp
+
g_system_device_num
*
device_prop
=
(
hl_device_prop
)(
sizeof
(
hl_device_prop
*
));
(
char
*
)
tmp
+
g_system_device_num
*
sizeof
(
hl_device_prop
*
));
memset
(
g_device
,
0
,
g_system_device_num
*
sizeof
(
hl_device_prop
*
));
memset
(
g_device
,
0
,
g_system_device_num
*
sizeof
(
hl_device_prop
*
));
int
num
=
0
;
int
num
=
0
;
for
(
int
i
=
0
;
i
<
number
;
i
++
)
{
for
(
int
i
=
0
;
i
<
number
;
i
++
)
{
...
@@ -558,8 +558,8 @@ bool hl_get_sync_flag() { return g_sync_flag; }
...
@@ -558,8 +558,8 @@ bool hl_get_sync_flag() { return g_sync_flag; }
void
hl_stream_synchronize
(
hl_stream_t
stream
)
{
void
hl_stream_synchronize
(
hl_stream_t
stream
)
{
cudaStream_t
cu_stream
;
cudaStream_t
cu_stream
;
CHECK_LT
(
stream
,
HPPL_STREAM_END
)
CHECK_LT
(
stream
,
HPPL_STREAM_END
)
<<
__func__
<<
__func__
<<
": the parameter stream is error."
;
<<
": the parameter stream is error."
;
cu_stream
=
t_resource
.
stream
[
stream
];
cu_stream
=
t_resource
.
stream
[
stream
];
CHECK_CUDA
(
cudaStreamSynchronize
(
cu_stream
));
CHECK_CUDA
(
cudaStreamSynchronize
(
cu_stream
));
...
@@ -589,8 +589,8 @@ void hl_stream_record_event(hl_stream_t stream, hl_event_t event) {
...
@@ -589,8 +589,8 @@ void hl_stream_record_event(hl_stream_t stream, hl_event_t event) {
cudaStream_t
cu_stream
;
cudaStream_t
cu_stream
;
CHECK_NOTNULL
(
event
);
CHECK_NOTNULL
(
event
);
CHECK_LT
(
stream
,
HPPL_STREAM_END
)
CHECK_LT
(
stream
,
HPPL_STREAM_END
)
<<
__func__
<<
__func__
<<
": the parameter stream is error."
;
<<
": the parameter stream is error."
;
cu_stream
=
t_resource
.
stream
[
stream
];
cu_stream
=
t_resource
.
stream
[
stream
];
CHECK_CUDA
(
cudaEventRecord
(
event
->
cu_event
,
cu_stream
));
CHECK_CUDA
(
cudaEventRecord
(
event
->
cu_event
,
cu_stream
));
...
@@ -600,8 +600,8 @@ void hl_stream_wait_event(hl_stream_t stream, hl_event_t event) {
...
@@ -600,8 +600,8 @@ void hl_stream_wait_event(hl_stream_t stream, hl_event_t event) {
cudaStream_t
cu_stream
;
cudaStream_t
cu_stream
;
CHECK_NOTNULL
(
event
);
CHECK_NOTNULL
(
event
);
CHECK_LT
(
stream
,
HPPL_STREAM_END
)
CHECK_LT
(
stream
,
HPPL_STREAM_END
)
<<
__func__
<<
__func__
<<
": the parameter stream is error."
;
<<
": the parameter stream is error."
;
cu_stream
=
t_resource
.
stream
[
stream
];
cu_stream
=
t_resource
.
stream
[
stream
];
CHECK_CUDA
(
cudaStreamWaitEvent
(
cu_stream
,
event
->
cu_event
,
0
));
CHECK_CUDA
(
cudaStreamWaitEvent
(
cu_stream
,
event
->
cu_event
,
0
));
...
...
paddle/function/BufferArgTest.cpp
浏览文件 @
6237f6f5
...
@@ -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 <gtest/gtest.h>
#include "BufferArg.h"
#include "BufferArg.h"
#include <gtest/gtest.h>
#include "paddle/math/MemoryHandle.h"
#include "paddle/math/MemoryHandle.h"
namespace
paddle
{
namespace
paddle
{
...
...
paddle/function/CosSimOp.cpp
浏览文件 @
6237f6f5
...
@@ -165,12 +165,12 @@ void CosSimBackward<DEVICE_TYPE_CPU>(const CpuMatrix& out_grad,
...
@@ -165,12 +165,12 @@ void CosSimBackward<DEVICE_TYPE_CPU>(const CpuMatrix& out_grad,
real
reciprocal_square_sum_x
=
1.0
f
/
square_sum_x
;
real
reciprocal_square_sum_x
=
1.0
f
/
square_sum_x
;
real
reciprocal_square_sum_y
=
1.0
f
/
square_sum_y
;
real
reciprocal_square_sum_y
=
1.0
f
/
square_sum_y
;
for
(
size_t
j
=
0
;
j
<
dim
;
++
j
)
{
for
(
size_t
j
=
0
;
j
<
dim
;
++
j
)
{
prev_grad_x
[
j
]
+=
out
[
i
]
*
grad
[
i
]
*
prev_grad_x
[
j
]
+=
(
prev_out_y
[
j
]
*
reciprocal_xy
-
out
[
i
]
*
grad
[
i
]
*
(
prev_out_y
[
j
]
*
reciprocal_xy
-
prev_out_x
[
j
]
*
reciprocal_square_sum_x
);
prev_out_x
[
j
]
*
reciprocal_square_sum_x
);
prev_grad_y
[
j
]
+=
out
[
i
]
*
grad
[
i
]
*
prev_grad_y
[
j
]
+=
(
prev_out_x
[
j
]
*
reciprocal_xy
-
out
[
i
]
*
grad
[
i
]
*
(
prev_out_x
[
j
]
*
reciprocal_xy
-
prev_out_y
[
j
]
*
reciprocal_square_sum_y
);
prev_out_y
[
j
]
*
reciprocal_square_sum_y
);
}
}
}
}
}
}
...
...
paddle/function/FunctionTest.cpp
浏览文件 @
6237f6f5
...
@@ -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 <gtest/gtest.h>
#include "Function.h"
#include "Function.h"
#include <gtest/gtest.h>
#include "paddle/math/SparseMatrix.h"
#include "paddle/math/SparseMatrix.h"
namespace
paddle
{
namespace
paddle
{
...
...
paddle/function/TensorShapeTest.cpp
浏览文件 @
6237f6f5
...
@@ -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 <gtest/gtest.h>
#include "TensorShape.h"
#include "TensorShape.h"
#include <gtest/gtest.h>
namespace
paddle
{
namespace
paddle
{
...
...
paddle/function/TensorTypeTest.cpp
浏览文件 @
6237f6f5
...
@@ -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 <gtest/gtest.h>
#include "TensorType.h"
#include "TensorType.h"
#include <gtest/gtest.h>
namespace
paddle
{
namespace
paddle
{
...
...
paddle/gserver/dataproviders/PyDataProvider.cpp
浏览文件 @
6237f6f5
...
@@ -194,8 +194,8 @@ void PyDataProvider::fillSlotsByStr(const std::string& samples) {
...
@@ -194,8 +194,8 @@ void PyDataProvider::fillSlotsByStr(const std::string& samples) {
auto
&
slot
=
slots_
[
j
];
auto
&
slot
=
slots_
[
j
];
CHECK
(
SlotDef
::
INDEX
>=
slot
.
type
||
SlotDef
::
STRING
==
slot
.
type
)
CHECK
(
SlotDef
::
INDEX
>=
slot
.
type
||
SlotDef
::
STRING
==
slot
.
type
)
<<
" Slot type:"
<<
slot
.
type
<<
" is out of range."
;
<<
" Slot type:"
<<
slot
.
type
<<
" is out of range."
;
CHECK_GE
(
slot
.
type
,
SlotDef
::
VECTOR_DENSE
)
CHECK_GE
(
slot
.
type
,
SlotDef
::
VECTOR_DENSE
)
<<
" Slot type:"
<<
slot
.
type
<<
" Slot type:"
<<
slot
.
type
<<
" is out of range."
;
<<
" is out of range."
;
switch
(
slot
.
type
)
{
switch
(
slot
.
type
)
{
case
SlotDef
::
VECTOR_DENSE
:
case
SlotDef
::
VECTOR_DENSE
:
fillDenseSlot
(
slot
,
data
,
dataEnd
);
fillDenseSlot
(
slot
,
data
,
dataEnd
);
...
...
paddle/gserver/evaluators/Evaluator.cpp
浏览文件 @
6237f6f5
...
@@ -446,9 +446,9 @@ real AucEvaluator::evalImp(std::vector<Argument>& arguments) {
...
@@ -446,9 +446,9 @@ real AucEvaluator::evalImp(std::vector<Argument>& arguments) {
for
(
size_t
i
=
0
;
i
<
insNum
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
insNum
;
++
i
)
{
real
value
=
outputD
[
pos
];
real
value
=
outputD
[
pos
];
uint32_t
binIdx
=
static_cast
<
uint32_t
>
(
value
*
kBinNum_
);
uint32_t
binIdx
=
static_cast
<
uint32_t
>
(
value
*
kBinNum_
);
CHECK
(
binIdx
<=
kBinNum_
)
CHECK
(
binIdx
<=
kBinNum_
)
<<
"bin index ["
<<
binIdx
<<
"bin index ["
<<
binIdx
<<
"] out of range, predict value["
<<
value
<<
"] out of range, predict value["
<<
value
<<
"]"
;
<<
"]"
;
real
w
=
supportWeight
?
weightD
[
i
]
:
1.0
;
real
w
=
supportWeight
?
weightD
[
i
]
:
1.0
;
if
(
labelD
[
i
]
==
kNegativeLabel_
)
{
if
(
labelD
[
i
]
==
kNegativeLabel_
)
{
statNeg_
[
binIdx
]
+=
w
;
statNeg_
[
binIdx
]
+=
w
;
...
...
paddle/gserver/layers/Layer.cpp
浏览文件 @
6237f6f5
...
@@ -263,9 +263,8 @@ void Layer::zeroGrad() {
...
@@ -263,9 +263,8 @@ void Layer::zeroGrad() {
}
}
void
Layer
::
initNeedFlags
()
{
void
Layer
::
initNeedFlags
()
{
auto
initFlag
=
[
this
](
bool
&
flag
,
auto
initFlag
=
[
this
](
bool
(
Layer
::*
flagQueryFunc
)()
const
,
bool
&
flag
,
bool
(
Layer
::*
flagQueryFunc
)()
const
,
ParameterType
type
)
{
ParameterType
type
)
{
flag
=
false
;
flag
=
false
;
if
(
biasParameter_
&&
biasParameter_
->
hasType
(
type
))
{
if
(
biasParameter_
&&
biasParameter_
->
hasType
(
type
))
{
flag
=
true
;
flag
=
true
;
...
...
paddle/gserver/tests/test_RecurrentLayer.cpp
浏览文件 @
6237f6f5
...
@@ -292,27 +292,26 @@ void checkRecurrentLayer(LayerConfig layerConfig,
...
@@ -292,27 +292,26 @@ void checkRecurrentLayer(LayerConfig layerConfig,
TestRecurrentLayer
<
T
>
testGpu
(
layerConfig
,
true
,
gpuBatch
);
TestRecurrentLayer
<
T
>
testGpu
(
layerConfig
,
true
,
gpuBatch
);
testCpu
.
init
(
batchSize
);
testCpu
.
init
(
batchSize
);
testGpu
.
init
(
batchSize
);
testGpu
.
init
(
batchSize
);
auto
checkError
=
auto
checkError
=
[](
[](
MatrixPtr
cpu
,
MatrixPtr
gpu
,
int
numSequences
,
const
char
*
str
)
{
MatrixPtr
cpu
,
MatrixPtr
gpu
,
int
numSequences
,
const
char
*
str
)
{
CpuMatrix
check
(
gpu
->
getHeight
(),
gpu
->
getWidth
());
CpuMatrix
check
(
gpu
->
getHeight
(),
gpu
->
getWidth
());
check
.
copyFrom
(
*
gpu
);
check
.
copyFrom
(
*
gpu
);
int
height
=
cpu
->
getHeight
();
int
height
=
cpu
->
getHeight
();
int
width
=
cpu
->
getWidth
();
int
width
=
cpu
->
getWidth
();
const
real
*
data1
=
cpu
->
getData
();
const
real
*
data1
=
cpu
->
getData
();
const
real
*
data2
=
check
.
getData
();
const
real
*
data2
=
check
.
getData
();
int
count
=
0
;
int
count
=
0
;
for
(
int
i
=
0
;
i
<
height
;
i
++
)
{
for
(
int
i
=
0
;
i
<
height
;
i
++
)
{
for
(
int
j
=
0
;
j
<
width
;
j
++
)
{
for
(
int
j
=
0
;
j
<
width
;
j
++
)
{
if
(
fabs
(
data1
[
i
*
width
+
j
]
-
data2
[
i
*
width
+
j
])
/
if
(
fabs
(
data1
[
i
*
width
+
j
]
-
data2
[
i
*
width
+
j
])
/
numSequences
>
numSequences
>
1e-4
)
{
1e-4
)
{
count
++
;
count
++
;
}
}
}
}
EXPECT_EQ
(
count
,
0
)
<<
"["
<<
str
<<
"]"
}
<<
"There are "
<<
count
<<
" different element."
;
}
};
EXPECT_EQ
(
count
,
0
)
<<
"["
<<
str
<<
"]"
<<
"There are "
<<
count
<<
" different element."
;
};
T
*
cpuLayer
=
dynamic_cast
<
T
*>
(
testCpu
.
testLayer_
.
get
());
T
*
cpuLayer
=
dynamic_cast
<
T
*>
(
testCpu
.
testLayer_
.
get
());
T
*
gpuLayer
=
dynamic_cast
<
T
*>
(
testGpu
.
testLayer_
.
get
());
T
*
gpuLayer
=
dynamic_cast
<
T
*>
(
testGpu
.
testLayer_
.
get
());
...
...
paddle/math/MatrixBitCode.cpp
浏览文件 @
6237f6f5
...
@@ -174,10 +174,8 @@ void CpuMatrix::mulByBitCode(size_t numClasses,
...
@@ -174,10 +174,8 @@ void CpuMatrix::mulByBitCode(size_t numClasses,
const
IVector
&
codes
,
const
IVector
&
codes
,
const
Matrix
&
weight
,
const
Matrix
&
weight
,
const
Matrix
&
input
)
{
const
Matrix
&
input
)
{
auto
op
=
[](
real
&
t
,
auto
op
=
[](
const
real
*
weightRow
,
real
&
t
,
const
real
*
weightRow
,
const
real
*
inputRow
,
size_t
inputDim
)
{
const
real
*
inputRow
,
size_t
inputDim
)
{
real
sum
=
0
;
real
sum
=
0
;
for
(
size_t
k
=
0
;
k
<
inputDim
;
++
k
)
{
for
(
size_t
k
=
0
;
k
<
inputDim
;
++
k
)
{
sum
+=
weightRow
[
k
]
*
inputRow
[
k
];
sum
+=
weightRow
[
k
]
*
inputRow
[
k
];
...
@@ -195,12 +193,12 @@ void CpuMatrix::mulByBitCodeBackwardWeight(size_t numClasses,
...
@@ -195,12 +193,12 @@ void CpuMatrix::mulByBitCodeBackwardWeight(size_t numClasses,
const
IVector
&
codes
,
const
IVector
&
codes
,
Matrix
&
weight
,
Matrix
&
weight
,
const
Matrix
&
input
)
{
const
Matrix
&
input
)
{
auto
op
=
auto
op
=
[](
[](
const
real
t
,
real
*
weightRow
,
const
real
*
inputRow
,
size_t
inputDim
)
{
const
real
t
,
real
*
weightRow
,
const
real
*
inputRow
,
size_t
inputDim
)
{
for
(
size_t
k
=
0
;
k
<
inputDim
;
++
k
)
{
for
(
size_t
k
=
0
;
k
<
inputDim
;
++
k
)
{
weightRow
[
k
]
+=
t
*
inputRow
[
k
];
weightRow
[
k
]
+=
t
*
inputRow
[
k
];
}
}
};
};
mulByBitCodeT
(
op
,
SimpleCodeTable
(
numClasses
),
codes
,
*
this
,
weight
,
input
);
mulByBitCodeT
(
op
,
SimpleCodeTable
(
numClasses
),
codes
,
*
this
,
weight
,
input
);
}
}
...
@@ -212,12 +210,12 @@ void CpuMatrix::mulByBitCodeBackwardError(size_t numClasses,
...
@@ -212,12 +210,12 @@ void CpuMatrix::mulByBitCodeBackwardError(size_t numClasses,
const
IVector
&
codes
,
const
IVector
&
codes
,
const
Matrix
&
weight
,
const
Matrix
&
weight
,
Matrix
&
input
)
{
Matrix
&
input
)
{
auto
op
=
auto
op
=
[](
[](
const
real
t
,
const
real
*
weightRow
,
real
*
inputRow
,
size_t
inputDim
)
{
const
real
t
,
const
real
*
weightRow
,
real
*
inputRow
,
size_t
inputDim
)
{
for
(
size_t
k
=
0
;
k
<
inputDim
;
++
k
)
{
for
(
size_t
k
=
0
;
k
<
inputDim
;
++
k
)
{
inputRow
[
k
]
+=
t
*
weightRow
[
k
];
inputRow
[
k
]
+=
t
*
weightRow
[
k
];
}
}
};
};
mulByBitCodeT
(
op
,
SimpleCodeTable
(
numClasses
),
codes
,
*
this
,
weight
,
input
);
mulByBitCodeT
(
op
,
SimpleCodeTable
(
numClasses
),
codes
,
*
this
,
weight
,
input
);
}
}
...
...
paddle/math/tests/TensorCheck.h
浏览文件 @
6237f6f5
...
@@ -183,8 +183,8 @@ void TensorCheck(AssertEq compare,
...
@@ -183,8 +183,8 @@ void TensorCheck(AssertEq compare,
template
<
typename
AssertEq
>
template
<
typename
AssertEq
>
void
TensorCheck
(
AssertEq
compare
,
real
args1
,
real
args2
)
{
void
TensorCheck
(
AssertEq
compare
,
real
args1
,
real
args2
)
{
EXPECT_EQ
(
compare
(
args1
,
args2
),
true
)
EXPECT_EQ
(
compare
(
args1
,
args2
),
true
)
<<
"[Test error] args1 = "
<<
args1
<<
"[Test error] args1 = "
<<
args1
<<
", args2 = "
<<
args2
;
<<
", args2 = "
<<
args2
;
}
}
template
<
typename
AssertEq
>
template
<
typename
AssertEq
>
...
...
paddle/math/tests/test_SIMDFunctions.cpp
浏览文件 @
6237f6f5
...
@@ -126,15 +126,15 @@ TEST(SIMDFunction, decayL1_WithLR) {
...
@@ -126,15 +126,15 @@ TEST(SIMDFunction, decayL1_WithLR) {
typedef
std
::
function
<
void
(
float
*
,
float
*
,
float
*
,
float
,
size_t
)
>
typedef
std
::
function
<
void
(
float
*
,
float
*
,
float
*
,
float
,
size_t
)
>
DecayL1MethodType
;
DecayL1MethodType
;
DecayL1MethodType
naive
=
DecayL1MethodType
naive
=
[](
[](
float
*
d
,
float
*
s
,
float
*
lr
,
float
l
,
size_t
len
)
{
float
*
d
,
float
*
s
,
float
*
lr
,
float
l
,
size_t
len
)
{
paddle
::
simd
::
naive
::
decayL1
<
float
>
(
d
,
s
,
lr
,
l
,
len
);
paddle
::
simd
::
naive
::
decayL1
<
float
>
(
d
,
s
,
lr
,
l
,
len
);
};
};
DecayL1MethodType
simd
=
DecayL1MethodType
simd
=
[](
[](
float
*
d
,
float
*
s
,
float
*
lr
,
float
l
,
size_t
len
)
{
float
*
d
,
float
*
s
,
float
*
lr
,
float
l
,
size_t
len
)
{
paddle
::
simd
::
decayL1
<
float
>
(
d
,
s
,
lr
,
l
,
len
);
paddle
::
simd
::
decayL1
<
float
>
(
d
,
s
,
lr
,
l
,
len
);
};
};
naive
(
dest
.
get
(),
src
.
get
(),
lr
.
get
(),
lambda
,
VECTOR_LEN
);
naive
(
dest
.
get
(),
src
.
get
(),
lr
.
get
(),
lambda
,
VECTOR_LEN
);
simd
(
simd_dest
.
get
(),
src
.
get
(),
lr
.
get
(),
lambda
,
VECTOR_LEN
);
simd
(
simd_dest
.
get
(),
src
.
get
(),
lr
.
get
(),
lambda
,
VECTOR_LEN
);
...
...
paddle/parameter/Argument.cpp
浏览文件 @
6237f6f5
...
@@ -379,7 +379,7 @@ void Argument::concat(const std::vector<Argument>& args,
...
@@ -379,7 +379,7 @@ void Argument::concat(const std::vector<Argument>& args,
}
}
auto
copyArg
=
[
batchSize
,
stream
](
auto
copyArg
=
[
batchSize
,
stream
](
MatrixPtr
&
dst
,
MatrixPtr
src
,
int
startRow
,
bool
useGpu
)
{
MatrixPtr
&
dst
,
MatrixPtr
src
,
int
startRow
,
bool
useGpu
)
{
if
(
!
src
)
{
if
(
!
src
)
{
dst
.
reset
();
dst
.
reset
();
return
;
return
;
...
@@ -395,31 +395,29 @@ void Argument::concat(const std::vector<Argument>& args,
...
@@ -395,31 +395,29 @@ void Argument::concat(const std::vector<Argument>& args,
tmpMatrix
->
copyFrom
(
*
src
,
stream
);
tmpMatrix
->
copyFrom
(
*
src
,
stream
);
};
};
auto
copyIds
=
auto
copyIds
=
[
batchSize
,
stream
](
[
batchSize
,
stream
](
IVectorPtr
&
dst
,
const
IVectorPtr
&
src
,
int
startRow
,
bool
useGpu
)
{
IVectorPtr
&
dst
,
const
IVectorPtr
&
src
,
int
startRow
,
bool
useGpu
)
{
if
(
!
src
)
{
if
(
!
src
)
{
dst
.
reset
();
dst
.
reset
();
return
;
return
;
}
}
IVector
::
resizeOrCreate
(
dst
,
batchSize
,
useGpu
);
IVector
::
resizeOrCreate
(
dst
,
batchSize
,
useGpu
);
dst
->
subVec
(
startRow
,
src
->
getSize
())
->
copyFrom
(
*
src
,
stream
);
dst
->
subVec
(
startRow
,
src
->
getSize
())
->
copyFrom
(
*
src
,
stream
);
};
};
auto
copyStrs
=
[
batchSize
,
stream
](
auto
copyStrs
=
SVectorPtr
&
dst
,
const
SVectorPtr
&
src
,
int
startRow
,
bool
useGpu
)
{
[
batchSize
,
stream
](
if
(
!
src
)
{
SVectorPtr
&
dst
,
const
SVectorPtr
&
src
,
int
startRow
,
bool
useGpu
)
{
dst
.
reset
();
if
(
!
src
)
{
return
;
dst
.
reset
();
}
return
;
if
(
!
dst
)
{
}
dst
=
std
::
make_shared
<
std
::
vector
<
std
::
string
>>
(
batchSize
);
if
(
!
dst
)
{
}
else
{
dst
=
std
::
make_shared
<
std
::
vector
<
std
::
string
>>
(
batchSize
);
dst
->
resize
(
batchSize
);
}
else
{
}
dst
->
resize
(
batchSize
);
std
::
copy
(
src
->
begin
(),
src
->
end
(),
dst
->
begin
()
+
startRow
);
}
};
std
::
copy
(
src
->
begin
(),
src
->
end
(),
dst
->
begin
()
+
startRow
);
};
auto
copySequencePos
=
[](
ICpuGpuVectorPtr
&
dstSeq
,
auto
copySequencePos
=
[](
ICpuGpuVectorPtr
&
dstSeq
,
const
ICpuGpuVectorPtr
&
srcSeq
,
const
ICpuGpuVectorPtr
&
srcSeq
,
...
...
paddle/parameter/AverageOptimizer.cpp
浏览文件 @
6237f6f5
...
@@ -155,9 +155,8 @@ ParameterOptimizer::TraverseCallback AverageOptimizer::restore() {
...
@@ -155,9 +155,8 @@ ParameterOptimizer::TraverseCallback AverageOptimizer::restore() {
return
nullptr
;
return
nullptr
;
}
}
return
[](
const
VectorPtr
vecs
[],
return
[](
const
ParameterConfig
&
config
,
const
VectorPtr
vecs
[],
const
ParameterConfig
&
config
,
size_t
sparseId
)
{
size_t
sparseId
)
{
vecs
[
PARAMETER_VALUE
]
->
copyFrom
(
*
vecs
[
PARAMETER_GRADIENT
]);
vecs
[
PARAMETER_VALUE
]
->
copyFrom
(
*
vecs
[
PARAMETER_GRADIENT
]);
vecs
[
PARAMETER_GRADIENT
]
->
zeroMem
();
vecs
[
PARAMETER_GRADIENT
]
->
zeroMem
();
};
};
...
...
paddle/parameter/Parameter.cpp
浏览文件 @
6237f6f5
...
@@ -352,8 +352,8 @@ bool Parameter::load(std::istream& s) {
...
@@ -352,8 +352,8 @@ bool Parameter::load(std::istream& s) {
Header
header
;
Header
header
;
CHECK
(
s
.
read
(
reinterpret_cast
<
char
*>
(
&
header
),
sizeof
(
header
)))
CHECK
(
s
.
read
(
reinterpret_cast
<
char
*>
(
&
header
),
sizeof
(
header
)))
<<
"Fail to read parameter "
<<
getName
();
<<
"Fail to read parameter "
<<
getName
();
CHECK_EQ
(
header
.
version
,
kFormatVersion
)
CHECK_EQ
(
header
.
version
,
kFormatVersion
)
<<
"Incorrect format version: "
<<
"Incorrect format version: "
<<
header
.
version
;
<<
header
.
version
;
CHECK_EQ
(
header
.
size
,
getSize
())
CHECK_EQ
(
header
.
size
,
getSize
())
<<
"The size ("
<<
header
.
size
<<
") in the file does not match the size "
<<
"The size ("
<<
header
.
size
<<
") in the file does not match the size "
<<
"("
<<
getSize
()
<<
") of the parameter: "
<<
getName
();
<<
"("
<<
getSize
()
<<
") of the parameter: "
<<
getName
();
...
...
paddle/pserver/LightNetwork.cpp
浏览文件 @
6237f6f5
...
@@ -359,8 +359,8 @@ void SocketClient::TcpClient(const std::string &serverAddr, int serverPort) {
...
@@ -359,8 +359,8 @@ void SocketClient::TcpClient(const std::string &serverAddr, int serverPort) {
#if defined(__OSX__) || defined(__APPLE__)
#if defined(__OSX__) || defined(__APPLE__)
server
=
getipnodebyname
(
serverAddr
.
c_str
(),
AF_INET
,
AI_DEFAULT
,
&
errRet
);
server
=
getipnodebyname
(
serverAddr
.
c_str
(),
AF_INET
,
AI_DEFAULT
,
&
errRet
);
CHECK_NE
(
HOST_NOT_FOUND
,
errRet
)
CHECK_NE
(
HOST_NOT_FOUND
,
errRet
)
<<
"ERROR, no such host: "
<<
serverAddr
<<
"ERROR, no such host: "
<<
serverAddr
<<
" ret = "
<<
errRet
;
<<
" ret = "
<<
errRet
;
CHECK
(
server
)
<<
"getipnodebyname error!"
;
CHECK
(
server
)
<<
"getipnodebyname error!"
;
#else
#else
struct
hostent
hostinfo
;
struct
hostent
hostinfo
;
...
...
paddle/pserver/ParameterClient2.cpp
浏览文件 @
6237f6f5
...
@@ -549,9 +549,9 @@ PServerVector ParameterClient2::createVector() {
...
@@ -549,9 +549,9 @@ PServerVector ParameterClient2::createVector() {
if
(
handle
==
-
1
)
{
if
(
handle
==
-
1
)
{
handle
=
response
.
handle
();
handle
=
response
.
handle
();
}
else
{
}
else
{
CHECK_EQ
(
handle
,
response
.
handle
())
CHECK_EQ
(
handle
,
response
.
handle
())
<<
"Inconsistent handle from client"
<<
"Inconsistent handle from client"
<<
&
response
-
&
responses
[
0
]
<<
&
response
-
&
responses
[
0
]
<<
" "
<<
" "
<<
handle
<<
" "
<<
response
.
handle
();
<<
handle
<<
" "
<<
response
.
handle
();
}
}
}
}
return
PServerVector
{
handle
};
return
PServerVector
{
handle
};
...
@@ -579,9 +579,9 @@ PServerMatrix ParameterClient2::createMatrix(int32_t numCols) {
...
@@ -579,9 +579,9 @@ PServerMatrix ParameterClient2::createMatrix(int32_t numCols) {
if
(
handle
==
-
1
)
{
if
(
handle
==
-
1
)
{
handle
=
response
.
handle
();
handle
=
response
.
handle
();
}
else
{
}
else
{
CHECK_EQ
(
handle
,
response
.
handle
())
CHECK_EQ
(
handle
,
response
.
handle
())
<<
"Inconsistent handle from client"
<<
"Inconsistent handle from client"
<<
&
response
-
&
responses
[
0
]
<<
&
response
-
&
responses
[
0
]
<<
" "
<<
" "
<<
handle
<<
" "
<<
response
.
handle
();
<<
handle
<<
" "
<<
response
.
handle
();
}
}
}
}
return
PServerMatrix
{
handle
};
return
PServerMatrix
{
handle
};
...
...
paddle/pserver/ParameterServer2.cpp
浏览文件 @
6237f6f5
...
@@ -1213,8 +1213,8 @@ void ParameterServer2::loadValueVector(const LoadValueRequest& request,
...
@@ -1213,8 +1213,8 @@ void ParameterServer2::loadValueVector(const LoadValueRequest& request,
CHECK_EQ
(
header
.
size
,
(
size_t
)
size_
)
CHECK_EQ
(
header
.
size
,
(
size_t
)
size_
)
<<
"The size ("
<<
header
.
size
<<
") in the file does not match the size "
<<
"The size ("
<<
header
.
size
<<
") in the file does not match the size "
<<
"("
<<
size_
<<
") of the pserver: "
<<
serverId_
;
<<
"("
<<
size_
<<
") of the pserver: "
<<
serverId_
;
CHECK_EQ
(
header
.
valueSize
,
sizeof
(
real
))
CHECK_EQ
(
header
.
valueSize
,
sizeof
(
real
))
<<
"Unsupported valueSize "
<<
"Unsupported valueSize "
<<
header
.
valueSize
;
<<
header
.
valueSize
;
CHECK
(
fs
.
read
(
reinterpret_cast
<
char
*>
(
vec
.
getData
()),
CHECK
(
fs
.
read
(
reinterpret_cast
<
char
*>
(
vec
.
getData
()),
header
.
size
*
sizeof
(
real
)));
header
.
size
*
sizeof
(
real
)));
...
...
paddle/pserver/ParameterServer2.h
浏览文件 @
6237f6f5
...
@@ -545,11 +545,11 @@ protected:
...
@@ -545,11 +545,11 @@ protected:
std
::
vector
<
ParameterServer2
::
Buffer
>*
buffers
);
std
::
vector
<
ParameterServer2
::
Buffer
>*
buffers
);
const
ParameterConfig
&
getParameterConfig
(
const
ParameterBlock
&
block
)
{
const
ParameterConfig
&
getParameterConfig
(
const
ParameterBlock
&
block
)
{
CHECK_LT
(
block
.
para_id
(),
-
1UL
)
CHECK_LT
(
block
.
para_id
(),
-
1UL
)
<<
"invalid parameter id:"
<<
"invalid parameter id:"
<<
block
.
para_id
();
<<
block
.
para_id
();
const
auto
it
=
configMap_
.
find
(
block
.
para_id
());
const
auto
it
=
configMap_
.
find
(
block
.
para_id
());
CHECK
(
it
!=
configMap_
.
end
())
CHECK
(
it
!=
configMap_
.
end
())
<<
"can not find parameter id: "
<<
"can not find parameter id: "
<<
block
.
para_id
();
<<
block
.
para_id
();
return
it
->
second
;
return
it
->
second
;
}
}
...
...
paddle/pserver/ProtoServer.cpp
浏览文件 @
6237f6f5
...
@@ -41,8 +41,8 @@ void ProtoServer::handleRequest(std::unique_ptr<MsgReader> msgReader,
...
@@ -41,8 +41,8 @@ void ProtoServer::handleRequest(std::unique_ptr<MsgReader> msgReader,
void
ProtoServer
::
registerServiceFunctionImp
(
const
std
::
string
&
funcName
,
void
ProtoServer
::
registerServiceFunctionImp
(
const
std
::
string
&
funcName
,
ServiceFunction
func
)
{
ServiceFunction
func
)
{
CHECK
(
!
nameToFuncMap_
.
count
(
funcName
))
CHECK
(
!
nameToFuncMap_
.
count
(
funcName
))
<<
"Duplicated registration: "
<<
"Duplicated registration: "
<<
funcName
;
<<
funcName
;
nameToFuncMap_
[
funcName
]
=
func
;
nameToFuncMap_
[
funcName
]
=
func
;
}
}
...
...
paddle/trainer/TrainerInternal.cpp
浏览文件 @
6237f6f5
...
@@ -97,7 +97,7 @@ void TrainerInternal::trainOneBatch(int64_t batchId,
...
@@ -97,7 +97,7 @@ void TrainerInternal::trainOneBatch(int64_t batchId,
}
}
UpdateCallback
updateCallback
=
[
this
,
showStats
,
&
paraStats
](
UpdateCallback
updateCallback
=
[
this
,
showStats
,
&
paraStats
](
Parameter
*
para
)
{
Parameter
*
para
)
{
if
(
showStats
)
{
if
(
showStats
)
{
//! @TODO(yuyang18) Show stats is actually a ParameterHook, refactor
//! @TODO(yuyang18) Show stats is actually a ParameterHook, refactor
// it
// it
...
...
paddle/utils/BarrierStat.h
浏览文件 @
6237f6f5
...
@@ -344,14 +344,14 @@ private:
...
@@ -344,14 +344,14 @@ private:
} while (0);
} while (0);
// check end barrier
// check end barrier
#define __CHECK_BARRIER_TIMER(set, statName, numConnThreads, ...) \
#define __CHECK_BARRIER_TIMER(set, statName, numConnThreads, ...)
\
do { \
do {
\
std::string internalName = \
std::string internalName =
\
std::string(statName) + std::string(__VA_ARGS__); \
std::string(statName) + std::string(__VA_ARGS__);
\
BarrierStatPtr __stat = \
BarrierStatPtr __stat =
\
(set).getStat(numConnThreads, internalName, BARRIER_END); \
(set).getStat(numConnThreads, internalName, BARRIER_END);
\
PCHECK(__stat->checkPassBarrier())
\
PCHECK(__stat->checkPassBarrier())
<< internalName
\
<< internalName << ": invalid barrier data";
\
<< ": invalid barrier data";
\
} while (0);
} while (0);
/*
/*
...
...
paddle/utils/ClassRegistrar.h
浏览文件 @
6237f6f5
...
@@ -62,8 +62,8 @@ public:
...
@@ -62,8 +62,8 @@ public:
// Create a class instance of type @type using args
// Create a class instance of type @type using args
BaseClass
*
createByType
(
const
std
::
string
&
type
,
CreateArgs
...
args
)
{
BaseClass
*
createByType
(
const
std
::
string
&
type
,
CreateArgs
...
args
)
{
ClassCreator
creator
;
ClassCreator
creator
;
CHECK
(
mapGet
(
type
,
creatorMap_
,
&
creator
))
CHECK
(
mapGet
(
type
,
creatorMap_
,
&
creator
))
<<
"Unknown class type: "
<<
"Unknown class type: "
<<
type
;
<<
type
;
return
creator
(
args
...);
return
creator
(
args
...);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录