Skip to content

Commit eefe5a7

Browse files
committed
Merge branch 'develop' of github.com:baidu/Paddle into feature/mnist_train_api
2 parents f8e4b0b + 4ccd5ea commit eefe5a7

32 files changed

+205
-135
lines changed

demo/quick_start/api_predict.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ set -e
1717
#Note the default model is pass-00002, you shold make sure the model path
1818
#exists or change the mode path.
1919
#only test on trainer_config.lr.py
20-
model=output/pass-00001/
20+
model=output/model/pass-00001/
2121
config=trainer_config.lr.py
2222
label=data/labels.list
2323
dict=data/dict.txt
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
set -e
16+
17+
# Should run pserver.sh before run this script.
18+
bin_dir=$(cd `dirname $0`; pwd)
19+
home_dir=$(cd "${bin_dir}/.."; pwd)
20+
source "$bin_dir/env.sh"
21+
22+
model_dir="$bin_dir/output"
23+
log_file="$bin_dir/train.log"
24+
25+
pushd "$home_dir"
26+
cfg=trainer_config.lr.py
27+
paddle train \
28+
--config=$cfg \
29+
--save_dir=${model_dir} \
30+
--trainer_count=4 \
31+
--local=0 \
32+
--log_period=100 \
33+
--num_passes=15 \
34+
--use_gpu=false \
35+
--show_parameter_stats_period=100 \
36+
--test_all_data_in_one_period=1 \
37+
--num_gradient_servers=1 \
38+
--nics=`get_nics` \
39+
--port=7164 \
40+
--ports_num=1 \
41+
--pservers="127.0.0.1" \
42+
--comment="paddle_trainer" \
43+
2>&1 | tee "$log_file"
44+
popd

demo/quick_start/cluster/env.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
set -e
16+
17+
function get_nics() {
18+
machine=`uname -s`
19+
local nics=""
20+
if [ "$machine" == "Linux" ]; then
21+
nics="lo"
22+
elif [ "$machine" == "Darwin" ]; then
23+
nics="lo0"
24+
else
25+
nics="unsupport"
26+
fi
27+
echo $nics
28+
}

demo/quick_start/cluster/pserver.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
set -e
16+
bin_dir=$(cd `dirname $0`; pwd)
17+
source "$bin_dir/env.sh"
18+
19+
paddle pserver \
20+
--nics=`get_nics` \
21+
--port=7164 \
22+
--ports_num=1 \
23+
--ports_num_for_sparse=1 \
24+
--num_gradient_servers=1 \
25+
--comment="paddle_pserver" \
26+
2>&1 | tee 'pserver.log'

paddle/api/PaddleAPI.h

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@ limitations under the License. */
2020
#include <string>
2121
#include <vector>
2222
#include "paddle/utils/GlobalConstants.h"
23-
#include "paddle/utils/TypeDefs.h"
23+
#include "paddle/utils/common.h"
2424

2525
/// Import PaddlePaddle's enumeration into global namespace.
2626
using namespace paddle::enumeration_wrapper; // NOLINT
2727

28-
#define DISABLE_COPY_AND_ASSIGN(classname) \
29-
classname(const classname& other); \
30-
classname& operator=(const classname& other)
31-
3228
/**
3329
* @brief Initialize paddle.
3430
*
@@ -102,7 +98,7 @@ const size_t NO_SPARSE_ID = -1UL;
10298
struct MatrixPrivate;
10399
class Matrix {
104100
Matrix(); // User Cannot Create Matrix.
105-
DISABLE_COPY_AND_ASSIGN(Matrix);
101+
DISABLE_COPY(Matrix);
106102
static Matrix* createByPaddleMatrixPtr(void* sharedPtr);
107103

108104
public:
@@ -242,7 +238,7 @@ class Matrix {
242238

243239
struct VectorPrivate;
244240
class Vector {
245-
DISABLE_COPY_AND_ASSIGN(Vector);
241+
DISABLE_COPY(Vector);
246242
Vector();
247243
static Vector* createByPaddleVectorPtr(void* ptr);
248244

@@ -322,7 +318,7 @@ class Vector {
322318
struct IVectorPrivate;
323319
class IVector {
324320
IVector();
325-
DISABLE_COPY_AND_ASSIGN(IVector);
321+
DISABLE_COPY(IVector);
326322
static IVector* createByPaddleVectorPtr(void* ptr);
327323

328324
public:
@@ -402,7 +398,7 @@ struct ArgumentsPrivate;
402398
class Arguments {
403399
private:
404400
Arguments(); // Internal Create.
405-
DISABLE_COPY_AND_ASSIGN(Arguments);
401+
DISABLE_COPY(Arguments);
406402

407403
public:
408404
/**
@@ -472,7 +468,7 @@ enum GradientMatchineCreateMode {
472468

473469
struct ParameterConfigPrivate;
474470
class ParameterConfig {
475-
DISABLE_COPY_AND_ASSIGN(ParameterConfig);
471+
DISABLE_COPY(ParameterConfig);
476472
ParameterConfig();
477473

478474
/**
@@ -502,7 +498,7 @@ class ParameterConfig {
502498

503499
struct OptimizationConfigPrivate;
504500
class OptimizationConfig {
505-
DISABLE_COPY_AND_ASSIGN(OptimizationConfig);
501+
DISABLE_COPY(OptimizationConfig);
506502
OptimizationConfig();
507503

508504
public:
@@ -527,7 +523,7 @@ struct ParameterPrivate;
527523
class Parameter {
528524
private:
529525
Parameter();
530-
DISABLE_COPY_AND_ASSIGN(Parameter);
526+
DISABLE_COPY(Parameter);
531527

532528
public:
533529
virtual ~Parameter();
@@ -572,7 +568,7 @@ struct ModelConfigPrivate;
572568
class ModelConfig {
573569
private:
574570
ModelConfig();
575-
DISABLE_COPY_AND_ASSIGN(ModelConfig);
571+
DISABLE_COPY(ModelConfig);
576572

577573
public:
578574
virtual ~ModelConfig();
@@ -593,7 +589,7 @@ struct TrainerConfigPrivate;
593589
class TrainerConfig {
594590
private:
595591
TrainerConfig();
596-
DISABLE_COPY_AND_ASSIGN(TrainerConfig);
592+
DISABLE_COPY(TrainerConfig);
597593

598594
public:
599595
virtual ~TrainerConfig();
@@ -633,7 +629,7 @@ class UpdateCallback {
633629

634630
struct ParameterTraverseCallbackPrivate;
635631
class ParameterTraverseCallback {
636-
DISABLE_COPY_AND_ASSIGN(ParameterTraverseCallback);
632+
DISABLE_COPY(ParameterTraverseCallback);
637633
ParameterTraverseCallback();
638634

639635
public:
@@ -655,7 +651,7 @@ class ParameterTraverseCallback {
655651
*/
656652
struct ParameterOptimizerPrivate;
657653
class ParameterOptimizer {
658-
DISABLE_COPY_AND_ASSIGN(ParameterOptimizer);
654+
DISABLE_COPY(ParameterOptimizer);
659655
ParameterOptimizer();
660656

661657
public:
@@ -692,7 +688,7 @@ struct GradientMachinePrivate;
692688
class GradientMachine {
693689
private:
694690
GradientMachine();
695-
DISABLE_COPY_AND_ASSIGN(GradientMachine);
691+
DISABLE_COPY(GradientMachine);
696692

697693
public:
698694
virtual ~GradientMachine();
@@ -908,7 +904,7 @@ class Trainer {
908904
TrainerPrivate* m;
909905
Trainer();
910906
Trainer(TrainerConfig* optConfig, GradientMachine* gm);
911-
DISABLE_COPY_AND_ASSIGN(Trainer);
907+
DISABLE_COPY(Trainer);
912908

913909
public:
914910
virtual ~Trainer();
@@ -974,7 +970,7 @@ class ISequenceResults {
974970

975971
struct SequenceGeneratorPrivate;
976972
class SequenceGenerator {
977-
DISABLE_COPY_AND_ASSIGN(SequenceGenerator);
973+
DISABLE_COPY(SequenceGenerator);
978974
SequenceGenerator();
979975

980976
public:

paddle/api/paddle_ld_flags.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,12 @@ def cmake_bool(cmake_str):
141141

142142
def c_flag(self):
143143
if self.with_coverage:
144-
return ["-fprofile-arcs", "-ftest-coverage", "-O0", "-g"]
144+
return [
145+
"-fprofile-arcs", "-ftest-coverage", "-O0", "-g",
146+
"-std=c++11"
147+
]
145148
else:
146-
return None
149+
return ["-std=c++11"]
147150
except ImportError:
148151

149152
class PaddleLDFlag(object):

paddle/cuda/include/hl_base.h

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,31 @@ limitations under the License. */
1616
#define HL_BASE_H_
1717

1818
#include <cstddef>
19-
#include "paddle/utils/TypeDefs.h"
19+
20+
#ifdef PADDLE_TYPE_DOUBLE
21+
#define HL_FLOAT_MAX 3.40282347e+38F
22+
#define HL_FLOAT_MIN 1.17549435e-38F
23+
using real = double;
24+
#else
25+
#define HL_FLOAT_MAX 1.7976931348623157e+308
26+
#define HL_FLOAT_MIN 2.2250738585072014e-308
27+
using real = float;
28+
#endif
29+
30+
/**
31+
* The maximum input value for exp, used to avoid overflow problem.
32+
* currently only used for tanh function.
33+
*/
34+
#define EXP_MAX_INPUT 40.0
35+
36+
/**
37+
* @brief DIVUP(x, y) is similar to ceil(x / y).
38+
* @note For CUDA, DIVUP will be used to specify
39+
* the size of blockDim.
40+
*/
41+
#ifndef DIVUP
42+
#define DIVUP(x, y) (((x) + (y)-1) / (y))
43+
#endif
2044

2145
/**
2246
* HPPL is an internal high performance parallel computing library
@@ -181,46 +205,6 @@ typedef struct {
181205
size_t nnz;
182206
} _hl_sparse_matrix_s, *hl_sparse_matrix_s;
183207

184-
#ifndef PADDLE_TYPE_DOUBLE
185-
/**
186-
* HPPL data type: real (float or double)
187-
*
188-
* if real == float
189-
*
190-
* HL_FLOAT_MAX: 3.40282347e+38F
191-
*
192-
* HL_FLOAT_MIN: 1.17549435e-38F
193-
*/
194-
#define HL_FLOAT_MAX 3.40282347e+38F
195-
/**
196-
* if real == double
197-
*
198-
* HL_FLOAT_MAX: 1.7976931348623157e+308
199-
*
200-
* HL_FLOAT_MIN: 2.2250738585072014e-308
201-
*/
202-
#define HL_FLOAT_MIN 1.17549435e-38F
203-
#else
204-
#define HL_FLOAT_MAX 1.7976931348623157e+308
205-
#define HL_FLOAT_MIN 2.2250738585072014e-308
206-
#endif
207-
208-
/**
209-
* The maximum input value for exp, used to avoid overflow problem.
210-
*
211-
* Currently only used for tanh function.
212-
*/
213-
#define EXP_MAX_INPUT 40.0
214-
215-
/**
216-
* @brief DIVUP(x, y) is similar to ceil(x / y).
217-
* @note For CUDA, DIVUP will be used to specify
218-
* the size of blockDim.
219-
*/
220-
#ifndef DIVUP
221-
#define DIVUP(x, y) (((x) + (y)-1) / (y))
222-
#endif
223-
224208
#ifdef __NVCC__
225209

226210
#include "cuda_runtime.h"

paddle/gserver/dataproviders/DataProvider.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ limitations under the License. */
3434
#include "paddle/utils/Logging.h"
3535
#include "paddle/utils/Queue.h"
3636
#include "paddle/utils/ThreadLocal.h"
37-
#include "paddle/utils/TypeDefs.h"
3837
#include "paddle/utils/Util.h"
38+
#include "paddle/utils/common.h"
3939

4040
namespace paddle {
4141
/**

paddle/gserver/layers/GruCompute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License. */
1616

1717
#include "ModelConfig.pb.h"
1818
#include "hl_gpu.h"
19-
#include "paddle/utils/TypeDefs.h"
19+
#include "paddle/utils/common.h"
2020

2121
namespace paddle {
2222

paddle/gserver/layers/LstmCompute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License. */
1616

1717
#include "ModelConfig.pb.h"
1818
#include "hl_gpu.h"
19-
#include "paddle/utils/TypeDefs.h"
19+
#include "paddle/utils/common.h"
2020

2121
namespace paddle {
2222

0 commit comments

Comments
 (0)