diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index f097c41da85affd1ff0b24200dbdbc63bf9c3ab6..0000000000000000000000000000000000000000 --- a/WORKSPACE +++ /dev/null @@ -1,31 +0,0 @@ -# External dependency to Google protobuf. -http_archive( - name="protobuf", - url="http://github.com/google/protobuf/archive/v3.1.0.tar.gz", - sha256="0a0ae63cbffc274efb573bdde9a253e3f32e458c41261df51c5dbc5ad541e8f7", - strip_prefix="protobuf-3.1.0") - -# External dependency to gtest 1.7.0. This method comes from -# https://www.bazel.io/versions/master/docs/tutorial/cpp.html. -new_http_archive( - name="gtest", - url="https://github.com/google/googletest/archive/release-1.7.0.zip", - sha256="b58cb7547a28b2c718d1e38aee18a3659c9e3ff52440297e965f5edffe34b6d0", - build_file="third_party/gtest.BUILD", - strip_prefix="googletest-release-1.7.0") - -# External dependency to gflags. This method comes from -# https://github.com/gflags/example/blob/master/WORKSPACE. -new_git_repository( - name="gflags", - tag="v2.2.0", - remote="https://github.com/gflags/gflags.git", - build_file="third_party/gflags.BUILD") - -# External dependency to glog. This method comes from -# https://github.com/reyoung/bazel_playground/blob/master/WORKSPACE -new_git_repository( - name="glog", - remote="https://github.com/google/glog.git", - commit="b6a5e0524c28178985f0d228e9eaa43808dbec3c", - build_file="third_party/glog.BUILD") diff --git a/doc/getstarted/build_and_install/docker_install_en.rst b/doc/getstarted/build_and_install/docker_install_en.rst index 57725c0d85997a5b67e08ebbf0979fca69998988..34279a29b2e4c84aa5039f2e5ab2c6ed9a06da2f 100644 --- a/doc/getstarted/build_and_install/docker_install_en.rst +++ b/doc/getstarted/build_and_install/docker_install_en.rst @@ -65,16 +65,13 @@ The general development workflow with Docker and Bazel is as follows: --name paddle \ -p 2022:22 \ -v $PWD:/paddle \ - -v $HOME/.cache/bazel:/root/.cache/bazel \ paddle:dev where :code:`-d` makes the container running in background, :code:`--name paddle` allows us to run a nginx container to serve documents in this container, :code:`-p 2022:22` allows us to SSH into this container, :code:`-v $PWD:/paddle` shares the source code - on the host with the container, :code:`-v - $HOME/.cache/bazel:/root/.cache/bazel` shares Bazel cache on the - host with the container. + on the host with the container. 4. SSH into the container: @@ -94,13 +91,6 @@ The general development workflow with Docker and Bazel is as follows: make -j `nproc` CTEST_OUTPUT_ON_FAILURE=1 ctest - or Bazel in the container: - - .. code-block:: bash - - cd /paddle - bazel test ... - CPU-only and GPU Images ----------------------- diff --git a/doc/tutorials/gan/gan.png b/doc/tutorials/gan/gan.png new file mode 100644 index 0000000000000000000000000000000000000000..001ed6cc19e8911f9b10f63211c9658160b3a06e Binary files /dev/null and b/doc/tutorials/gan/gan.png differ diff --git a/doc/tutorials/gan/index_en.md b/doc/tutorials/gan/index_en.md new file mode 100644 index 0000000000000000000000000000000000000000..99c8d730117a469c89abb218eeacf66103c0cbed --- /dev/null +++ b/doc/tutorials/gan/index_en.md @@ -0,0 +1,143 @@ +# Generative Adversarial Networks (GAN) + +This demo implements GAN training described in the original [GAN paper](https://arxiv.org/abs/1406.2661) and deep convolutional generative adversarial networks [DCGAN paper](https://arxiv.org/abs/1511.06434). + +The high-level structure of GAN is shown in Figure. 1 below. It is composed of two major parts: a generator and a discriminator, both of which are based on neural networks. The generator takes in some kind of noise with a known distribution and transforms it into an image. The discriminator takes in an image and determines whether it is artificially generated by the generator or a real image. So the generator and the discriminator are in a competitive game in which generator is trying to generate image to look as real as possible to fool the discriminator, while the discriminator is trying to distinguish between real and fake images. + +

+ +

+

+ Figure 1. GAN-Model-Structure + figure credit +

+ +The generator and discriminator take turn to be trained using SGD. The objective function of the generator is for its generated images being classified as real by the discriminator, and the objective function of the discriminator is to correctly classify real and fake images. When the GAN model is trained to converge to the equilibrium state, the generator will transform the given noise distribution to the distribution of real images, and the discriminator will not be able to distinguish between real and fake images at all. + +## Implementation of GAN Model Structure +Since GAN model involves multiple neural networks, it requires to use paddle python API. So the code walk-through below can also partially serve as an introduction to the usage of Paddle Python API. + +There are three networks defined in gan_conf.py, namely **generator_training**, **discriminator_training** and **generator**. The relationship to the model structure we defined above is that **discriminator_training** is the discriminator, **generator** is the generator, and the **generator_training** combined the generator and discriminator since training generator would require the discriminator to provide loss function. This relationship is described in the following code: +```python +if is_generator_training: + noise = data_layer(name="noise", size=noise_dim) + sample = generator(noise) + +if is_discriminator_training: + sample = data_layer(name="sample", size=sample_dim) + +if is_generator_training or is_discriminator_training: + label = data_layer(name="label", size=1) + prob = discriminator(sample) + cost = cross_entropy(input=prob, label=label) + classification_error_evaluator( + input=prob, label=label, name=mode + '_error') + outputs(cost) + +if is_generator: + noise = data_layer(name="noise", size=noise_dim) + outputs(generator(noise)) +``` + +In order to train the networks defined in gan_conf.py, one first needs to initialize a Paddle environment, parse the config, create GradientMachine from the config and create trainer from GradientMachine as done in the code chunk below: +```python +import py_paddle.swig_paddle as api +# init paddle environment +api.initPaddle('--use_gpu=' + use_gpu, '--dot_period=10', + '--log_period=100', '--gpu_id=' + args.gpu_id, + '--save_dir=' + "./%s_params/" % data_source) + +# Parse config +gen_conf = parse_config(conf, "mode=generator_training,data=" + data_source) +dis_conf = parse_config(conf, "mode=discriminator_training,data=" + data_source) +generator_conf = parse_config(conf, "mode=generator,data=" + data_source) + +# Create GradientMachine +dis_training_machine = api.GradientMachine.createFromConfigProto( +dis_conf.model_config) +gen_training_machine = api.GradientMachine.createFromConfigProto( +gen_conf.model_config) +generator_machine = api.GradientMachine.createFromConfigProto( +generator_conf.model_config) + +# Create trainer +dis_trainer = api.Trainer.create(dis_conf, dis_training_machine) +gen_trainer = api.Trainer.create(gen_conf, gen_training_machine) +``` + +In order to balance the strength between generator and discriminator, we schedule to train whichever one is performing worse by comparing their loss function value. The loss function value can be calculated by a forward pass through the GradientMachine. +```python +def get_training_loss(training_machine, inputs): + outputs = api.Arguments.createArguments(0) + training_machine.forward(inputs, outputs, api.PASS_TEST) + loss = outputs.getSlotValue(0).copyToNumpyMat() + return numpy.mean(loss) +``` + +After training one network, one needs to sync the new parameters to the other networks. The code below demonstrates one example of such use case: +```python +# Train the gen_training +gen_trainer.trainOneDataBatch(batch_size, data_batch_gen) + +# Copy the parameters from gen_training to dis_training and generator +copy_shared_parameters(gen_training_machine, +dis_training_machine) +copy_shared_parameters(gen_training_machine, generator_machine) +``` + + +## A Toy Example +With the infrastructure explained above, we can now walk you through a toy example of generating two dimensional uniform distribution using 10 dimensional Gaussian noise. + +The Gaussian noises are generated using the code below: +```python +def get_noise(batch_size, noise_dim): + return numpy.random.normal(size=(batch_size, noise_dim)).astype('float32') +``` + +The real samples (2-D uniform) are generated using the code below: +```python +# synthesize 2-D uniform data in gan_trainer.py:114 +def load_uniform_data(): + data = numpy.random.rand(1000000, 2).astype('float32') + return data +``` + +The generator and discriminator network are built using fully-connected layer and batch_norm layer, and are defined in gan_conf.py. + +To train the GAN model, one can use the command below. The flag -d specifies the training data (cifar, mnist or uniform) and flag --useGpu specifies whether to use gpu for training (0 is cpu, 1 is gpu). +```bash +$python gan_trainer.py -d uniform --useGpu 1 +``` +The generated samples can be found in ./uniform_samples/ and one example is shown below as Figure 2. One can see that it roughly recovers the 2D uniform distribution. + +

+ +

+

+ Figure 2. Uniform Sample +

+ +## MNIST Example +### Data preparation +To download the MNIST data, one can use the following commands: +```bash +$cd data/ +$./get_mnist_data.sh +``` + +### Model description +Following the DC-Gan paper (https://arxiv.org/abs/1511.06434), we use convolution/convolution-transpose layer in the discriminator/generator network to better deal with images. The details of the network structures are defined in gan_conf_image.py. + +### Training the model +To train the GAN model on mnist data, one can use the following command: +```bash +$python gan_trainer.py -d mnist --useGpu 1 +``` +The generated sample images can be found at ./mnist_samples/ and one example is shown below as Figure 3. +

+ +

+

+ Figure 3. MNIST Sample +

diff --git a/doc/tutorials/gan/mnist_sample.png b/doc/tutorials/gan/mnist_sample.png new file mode 100644 index 0000000000000000000000000000000000000000..f9c7bf7ddd7f148eac4fe347e9c38afaa8876760 Binary files /dev/null and b/doc/tutorials/gan/mnist_sample.png differ diff --git a/doc/tutorials/gan/uniform_sample.png b/doc/tutorials/gan/uniform_sample.png new file mode 100644 index 0000000000000000000000000000000000000000..4a96c45cae82673f5a1df986f2643a8026da7937 Binary files /dev/null and b/doc/tutorials/gan/uniform_sample.png differ diff --git a/doc/tutorials/image_classification/index_cn.md b/doc/tutorials/image_classification/index_cn.md new file mode 100644 index 0000000000000000000000000000000000000000..87f465522a0fa21c8c03754b4be8dcb035c4de81 --- /dev/null +++ b/doc/tutorials/image_classification/index_cn.md @@ -0,0 +1,205 @@ +图像分类教程 +========== + +在本教程中,我们将使用CIFAR-10数据集训练一个卷积神经网络,并使用这个神经网络来对图片进行分类。如下图所示,卷积神经网络可以辨识图片中的主体,并给出分类结果。 +
![Image Classification](./image_classification.png)
+ +## 数据准备 +首先下载CIFAR-10数据集。下面是CIFAR-10数据集的官方网址: + + + +我们准备了一个脚本,可以用于从官方网站上下载CIFAR-10数据集,转为jpeg文件并存入特定的目录。使用这个脚本前请确认已经安装了pillow及相关依赖模块。可以参照下面的命令进行安装: + +1. 安装pillow + +```bash +sudo apt-get install libjpeg-dev +pip install pillow +``` + +2. 下载数据集 + +```bash +cd demo/image_classification/data/ +sh download_cifar.sh +``` + +CIFAR-10数据集包含60000张32x32的彩色图片。图片分为10类,每个类包含6000张。其中50000张图片作为训练集,10000张作为测试集。 + +下图展示了所有的图片类别,每个类别中随机抽取了10张图片。 +
![Image Classification](./cifar.png)
+ +脚本运行完成后,我们应当会得到一个名为cifar-out的文件夹,其下子文件夹的结构如下 + + +``` +train +---airplane +---automobile +---bird +---cat +---deer +---dog +---frog +---horse +---ship +---truck +test +---airplane +---automobile +---bird +---cat +---deer +---dog +---frog +---horse +---ship +---truck +``` + +cifar-out下包含`train`和`test`两个文件夹,其中分别包含了CIFAR-10中的训练集和测试集。这两个文件夹下各自有10个子文件夹,每个子文件夹下存储相应分类的图片。将图片按照上述结构存储好之后,我们就可以着手对分类模型进行训练了。 + +## 预处理 +数据下载之后,还需要进行预处理,将数据转换为Paddle的格式。我们可以通过如下命令进行预处理工作: + +``` +cd demo/image_classification/ +sh preprocess.sh +``` + +其中`preprocess.sh` 调用 `./demo/image_classification/preprocess.py` 对图片进行预处理 +```sh +export PYTHONPATH=$PYTHONPATH:../../ +data_dir=./data/cifar-out +python preprocess.py -i $data_dir -s 32 -c 1 +``` + +`./demo/image_classification/preprocess.py` 使用如下参数: + +- `-i` 或 `--input` 给出输入数据所在路径; +- `-s` 或 `--size` 给出图片尺寸; +- `-c` 或 `--color` 标示图片是彩色图或灰度图 + +## 模型训练 +在开始训练之前,我们需要先创建一个模型配置文件。下面我们给出了一个配置示例。**注意**,这里的列出的和`vgg_16_cifar.py`文件稍有差别,因为该文件可适用于预测。 + +```python +from paddle.trainer_config_helpers import * +data_dir='data/cifar-out/batches/' +meta_path=data_dir+'batches.meta' +args = {'meta':meta_path, 'mean_img_size': 32, + 'img_size': 32, 'num_classes': 10, + 'use_jpeg': 1, 'color': "color"} +define_py_data_sources2(train_list=data_dir+"train.list", + test_list=data_dir+'test.list', + module='image_provider', + obj='processData', + args=args) +settings( + batch_size = 128, + learning_rate = 0.1 / 128.0, + learning_method = MomentumOptimizer(0.9), + regularization = L2Regularization(0.0005 * 128)) + +img = data_layer(name='image', size=3*32*32) +lbl = data_layer(name="label", size=10) +# small_vgg is predined in trainer_config_helpers.network +predict = small_vgg(input_image=img, num_channels=3) +outputs(classification_cost(input=predict, label=lbl)) +``` + +在第一行中我们载入用于定义网络的函数。 +```python +from paddle.trainer_config_helpers import * +``` + +之后定义的`define_py_data_sources2`使用Python数据提供器,其中 `args`将在`image_provider.py`进行使用,该文件负责产生图片数据并传递给Paddle系统 + - `meta`: 训练集平均值。 + - `mean_img_size`: 平均特征图的高度及宽度。 + - `img_size`:输入图片的高度及宽度。 + - `num_classes`:类别个数。 + - `use_jpeg`:处理过程中数据存储格式。 + - `color`:标示是否为彩色图片。 + + `settings`用于设置训练算法。在下面的例子中,learning rate被设置为0.1除以batch size,而weight decay则为0.0005乘以batch size。 + + ```python +settings( + batch_size = 128, + learning_rate = 0.1 / 128.0, + learning_method = MomentumOptimizer(0.9), + regularization = L2Regularization(0.0005 * 128) +) +``` + +`small_vgg`定义了网络结构。这里我们使用的是一个小的VGG网络。关于VGG卷积神经网络的描述可以参考:[http://www.robots.ox.ac.uk/~vgg/research/very_deep/](http://www.robots.ox.ac.uk/~vgg/research/very_deep/)。 +```python +# small_vgg is predined in trainer_config_helpers.network +predict = small_vgg(input_image=img, num_channels=3) +``` +配置创建完毕后,可以运行脚本train.sh来训练模型。 + +```bash +config=vgg_16_cifar.py +output=./cifar_vgg_model +log=train.log + +paddle train \ +--config=$config \ +--dot_period=10 \ +--log_period=100 \ +--test_all_data_in_one_period=1 \ +--use_gpu=1 \ +--save_dir=$output \ +2>&1 | tee $log + +python -m paddle.utils.plotcurve -i $log > plot.png +``` +- 这里我们使用的是GPU模式进行训练。如果你没有GPU环境,可以设置`use_gpu=0`。 +- `./demo/image_classification/vgg_16_cifar.py`是网络和数据配置文件。各项参数的详细说明可以在命令行参数相关文档中找到。 +- 脚本`plotcurve.py`依赖于python的`matplotlib`模块。因此如果这个脚本运行失败,也许是因为需要安装`matplotlib`。 +在训练完成后,训练及测试误差曲线图会被`plotcurve.py`脚本保存在 `plot.png`中。下面是一个误差曲线图的示例: + +
![Training and testing curves.](./plot.png)
+ +## 预测 +在训练完成后,模型及参数会被保存在路径`./cifar_vgg_model/pass-%05d`下。例如第300个pass的模型会被保存在`./cifar_vgg_model/pass-00299`。 + +要对一个图片的进行分类预测,我们可以使用`predict.sh`,该脚本将输出预测分类的标签: + +``` +sh predict.sh +``` + +predict.sh: +``` +model=cifar_vgg_model/pass-00299/ +image=data/cifar-out/test/airplane/seaplane_s_000978.png +use_gpu=1 +python prediction.py $model $image $use_gpu +``` + +## 练习 +在CUB-200数据集上使用VGG模型训练一个鸟类图片分类模型。相关的鸟类数据集可以从如下地址下载,其中包含了200种鸟类的照片(主要来自北美洲)。 + + + + + + +## 细节探究 +### 卷积神经网络 +卷积神经网络是一种使用卷积层的前向神经网络,很适合构建用于理解图片内容的模型。一个典型的神经网络如下图所示: + +![Convolutional Neural Network](./lenet.png) + +一个卷积神经网络包含如下层: + +- 卷积层:通过卷积操作从图片或特征图中提取特征 +- 池化层:使用max-pooling对特征图下采样 +- 全连接层:使输入层到隐藏层的神经元是全部连接的。 + +卷积神经网络在图片分类上有着惊人的性能,这是因为它发掘出了图片的两类重要信息:局部关联性质和空间不变性质。通过交替使用卷积和池化处理, 卷积神经网络能够很好的表示这两类信息。 + +关于如何定义网络中的层,以及如何在层之间进行连接,请参考Layer文档。 diff --git a/doc/tutorials/image_classification/index_en.md b/doc/tutorials/image_classification/index_en.md index 29cfc99702c362d1eaeeff5332f56122b8de337a..60c81a6a539944634773f38ec4c9a59709dd4afc 100644 --- a/doc/tutorials/image_classification/index_en.md +++ b/doc/tutorials/image_classification/index_en.md @@ -147,7 +147,7 @@ for classification. A description of VGG network can be found here [http://www.r # small_vgg is predined in trainer_config_helpers.network predict = small_vgg(input_image=img, num_channels=3) ``` -After writing the config, we can train the model by running the script train.sh. Notice that the following script assumes the you run the script in the `./demo/image_classification` folder. If you run the script in a different folder, you need to change the paths of the scripts and the configuration files accordingly. +After writing the config, we can train the model by running the script train.sh. ```bash config=vgg_16_cifar.py diff --git a/paddle/api/GradientMachine.cpp b/paddle/api/GradientMachine.cpp index 0d1e17529611d11136914cb810b0633e0afccedf..66115f8293b905809639afff779abfdb2bb3a54e 100644 --- a/paddle/api/GradientMachine.cpp +++ b/paddle/api/GradientMachine.cpp @@ -68,6 +68,14 @@ void GradientMachine::start() { m->machine->start(); } void GradientMachine::finish() { m->machine->finish(); } +void GradientMachine::onPassEnd() { m->machine->onPassEnd(); } + +void GradientMachine::prefetch(const Arguments& inArgs) { + auto& in = + m->cast>(inArgs.getInternalArgumentsPtr()); + m->machine->prefetch(in); +} + void GradientMachine::forward(const Arguments& inArgs, Arguments* outArgs, PassType passType) { diff --git a/paddle/api/PaddleAPI.h b/paddle/api/PaddleAPI.h index 0a273f9f6f942a9ca3f4404dfc843eb88d650daa..23f681d9e5334aaadd909ef48b1321f6724132bd 100644 --- a/paddle/api/PaddleAPI.h +++ b/paddle/api/PaddleAPI.h @@ -725,6 +725,16 @@ public: void start(); + /** + * Prefetch row ids of sparse parameter. + */ + void prefetch(const Arguments& inArgs); + + /** + * Do some thing when train pass ended. + */ + void onPassEnd(); + /** * The forward stage of GradientMachine. * diff --git a/paddle/cuda/src/hl_cuda_cudnn.cc b/paddle/cuda/src/hl_cuda_cudnn.cc index c0c8b0e60dbde11fd7e8ce056df7e8a7862049d2..6198f067bab2ec790e641e77dce058fe6a52491a 100644 --- a/paddle/cuda/src/hl_cuda_cudnn.cc +++ b/paddle/cuda/src/hl_cuda_cudnn.cc @@ -14,11 +14,11 @@ limitations under the License. */ #include "hl_cuda_cudnn.h" #include +#include #include #include "hl_cuda_cudnn.ph" #include "hl_dso_loader.h" #include "hl_thread.ph" -#include "paddle/utils/CommandLineParser.h" #include "paddle/utils/Logging.h" DEFINE_int32(cudnn_conv_workspace_limit_in_mb, diff --git a/paddle/cuda/src/hl_dso_loader.cc b/paddle/cuda/src/hl_dso_loader.cc index 54c7620fc081f681d9d33bcd711008fa5029df05..c92909de534a875028d6d4784b02f08648c85a9a 100644 --- a/paddle/cuda/src/hl_dso_loader.cc +++ b/paddle/cuda/src/hl_dso_loader.cc @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "hl_dso_loader.h" -#include "paddle/utils/CommandLineParser.h" +#include #include "paddle/utils/Logging.h" DEFINE_string(cudnn_dir, diff --git a/paddle/gserver/layers/BatchNormalizationLayer.h b/paddle/gserver/layers/BatchNormalizationLayer.h index 052c2077322be59f9d41966c1c8b6ab20c8f85bb..195acbbfc58db8368f6db1c1595dd6b04801ee26 100644 --- a/paddle/gserver/layers/BatchNormalizationLayer.h +++ b/paddle/gserver/layers/BatchNormalizationLayer.h @@ -58,6 +58,8 @@ protected: /// to batch, channels* imagePixels. void shrinkMat(const MatrixPtr& in, MatrixPtr& out); + void onPassEnd() { firstTest_ = true; } + MatrixPtr tmpMat_, tmpGrad_; MatrixPtr expandedIn_, expandedOut_; MatrixPtr expandedInGrad_, expandedOutGrad_, inGrad_; diff --git a/paddle/gserver/layers/RecurrentLayer.cpp b/paddle/gserver/layers/RecurrentLayer.cpp index 94b16996a86d2c52c8b97cbe009076fa3ade03f7..55e0fdfb9048c02b2dcd474c6887eee180328260 100644 --- a/paddle/gserver/layers/RecurrentLayer.cpp +++ b/paddle/gserver/layers/RecurrentLayer.cpp @@ -12,9 +12,9 @@ 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 #include "Layer.h" #include "SequenceToBatch.h" -#include "paddle/utils/CommandLineParser.h" #include "paddle/utils/Stat.h" DEFINE_bool(rnn_use_batch, false, "Using the batch method for calculation."); diff --git a/paddle/gserver/tests/TestUtil.cpp b/paddle/gserver/tests/TestUtil.cpp index e07c60861a4a6567fd1e28559b9806cb623a3bdf..c691fe26255914811c8861cff80495c821990179 100644 --- a/paddle/gserver/tests/TestUtil.cpp +++ b/paddle/gserver/tests/TestUtil.cpp @@ -13,9 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "TestUtil.h" - +#include #include "paddle/math/SparseMatrix.h" -#include "paddle/utils/CommandLineParser.h" DEFINE_int32(fixed_seq_length, 0, "Produce some sequence of fixed length"); diff --git a/paddle/math/SparseRowMatrix.h b/paddle/math/SparseRowMatrix.h index 9364feb4a1462a5a9d16ca0f69213ba32ad97d21..778a9bd845661849261b52dcbeb519809d0c6306 100644 --- a/paddle/math/SparseRowMatrix.h +++ b/paddle/math/SparseRowMatrix.h @@ -14,10 +14,10 @@ limitations under the License. */ #pragma once +#include #include #include #include "Matrix.h" -#include "paddle/utils/CommandLineParser.h" #include "paddle/utils/Util.h" DECLARE_bool(allow_inefficient_sparse_update); diff --git a/paddle/parameter/Parameter.cpp b/paddle/parameter/Parameter.cpp index 1673fc6e533e416dfe4db557a1a8968667d1bfff..29d6e20dc16968cdda3e79b66b0c81aaaf303ef4 100644 --- a/paddle/parameter/Parameter.cpp +++ b/paddle/parameter/Parameter.cpp @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "Parameter.h" +#include #include #include "AverageOptimizer.h" #include "FirstOrderOptimizer.h" @@ -23,7 +24,6 @@ limitations under the License. */ #include "paddle/math/CpuSparseMatrix.h" #include "paddle/math/MathUtils.h" #include "paddle/math/SparseRowMatrix.h" -#include "paddle/utils/CommandLineParser.h" #include "paddle/utils/Logging.h" DEFINE_int32(enable_grad_share, diff --git a/paddle/pserver/BaseClient.cpp b/paddle/pserver/BaseClient.cpp index b4ac7a2506921b2409baaff077cc3541f3dc8d73..0e031a7e20cbc975f0dc368fb1523c1f63d8646b 100644 --- a/paddle/pserver/BaseClient.cpp +++ b/paddle/pserver/BaseClient.cpp @@ -13,9 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "BaseClient.h" +#include #include #include -#include "paddle/utils/CommandLineParser.h" #include "paddle/utils/Stat.h" DECLARE_string(pservers); diff --git a/paddle/pserver/LightNetwork.cpp b/paddle/pserver/LightNetwork.cpp index cbc105e651faa0f283b3becb10449f4e1bc78b38..8c8ba0a2e51b85bde0544c6780b07130336a6bdd 100644 --- a/paddle/pserver/LightNetwork.cpp +++ b/paddle/pserver/LightNetwork.cpp @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include +#include #include #include @@ -382,8 +383,20 @@ void SocketClient::TcpClient(const std::string &serverAddr, int serverPort) { setOption(sockfd); /// Now connect to the server - PCHECK(connect(sockfd, (sockaddr *)&serv_addr, sizeof(serv_addr)) >= 0) - << "ERROR connecting to " << serverAddr; + int retry_second = 0; + int error = 0; + do { + error = connect(sockfd, (sockaddr *)&serv_addr, sizeof(serv_addr)); + if (error == ECONNREFUSED) { + LOG(WARNING) << "connection refused by pserver, try again!"; + if (retry_second++ >= 7) { + LOG(FATAL) << "connection refused by pserver, maybe pserver failed!"; + } + std::this_thread::sleep_for(std::chrono::seconds(1)); + } else { + PCHECK(error >= 0) << "ERROR connecting to " << serverAddr; + } + } while (error == ECONNREFUSED); channel_.reset(new SocketChannel(sockfd, serverAddr)); tcpRdma_ = F_TCP; diff --git a/paddle/scripts/docker/Dockerfile b/paddle/scripts/docker/Dockerfile index f26055d0d4c99327580357f1118ae5eeca1c6d99..b01de499bd1fbcfff1f655535f574ae2caa17707 100644 --- a/paddle/scripts/docker/Dockerfile +++ b/paddle/scripts/docker/Dockerfile @@ -17,18 +17,6 @@ RUN cd /usr/src/gtest && cmake . && make && cp *.a /usr/lib RUN pip install -U BeautifulSoup docopt PyYAML pillow \ sphinx sphinx_rtd_theme recommonmark -# cmake tends to hide and blur the dependencies between code modules, as -# noted here https://github.com/PaddlePaddle/Paddle/issues/763. We are -# thinking about using Bazel to fix this problem, e.g., -# https://github.com/PaddlePaddle/Paddle/issues/681#issuecomment-263996102. To -# start the trail of fixing, we add Bazel to our Dockerfiles. -RUN apt-get update && apt-get install -y curl software-properties-common \ - && add-apt-repository ppa:webupd8team/java \ - && echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections \ - && echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \ - && curl https://bazel.build/bazel-release.pub.gpg | apt-key add - \ - && apt-get update && apt-get install -y oracle-java8-installer bazel - ARG WITH_AVX ARG WITH_DOC ARG WITH_SWIG_PY diff --git a/paddle/scripts/docker/Dockerfile.gpu b/paddle/scripts/docker/Dockerfile.gpu index d13b97714727acd6c1c57fb64603374faacc4fa5..a68cc79b84271c63d41a89494150381d96748b67 100644 --- a/paddle/scripts/docker/Dockerfile.gpu +++ b/paddle/scripts/docker/Dockerfile.gpu @@ -17,18 +17,6 @@ RUN cd /usr/src/gtest && cmake . && make && cp *.a /usr/lib RUN pip install -U BeautifulSoup docopt PyYAML pillow \ sphinx sphinx_rtd_theme recommonmark -# cmake tends to hide and blur the dependencies between code modules, as -# noted here https://github.com/PaddlePaddle/Paddle/issues/763. We are -# thinking about using Bazel to fix this problem, e.g., -# https://github.com/PaddlePaddle/Paddle/issues/681#issuecomment-263996102. To -# start the trail of fixing, we add Bazel to our Dockerfiles. -RUN apt-get update && apt-get install -y curl software-properties-common \ - && add-apt-repository ppa:webupd8team/java \ - && echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections \ - && echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \ - && curl https://bazel.build/bazel-release.pub.gpg | apt-key add - \ - && apt-get update && apt-get install -y oracle-java8-installer bazel - ARG WITH_AVX ARG WITH_DOC ARG WITH_SWIG_PY diff --git a/paddle/utils/CommandLineParser.cpp b/paddle/utils/CommandLineParser.cpp deleted file mode 100644 index 63f16bc54c575a0d5ae02141be3c467ee784b095..0000000000000000000000000000000000000000 --- a/paddle/utils/CommandLineParser.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. - -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 "CommandLineParser.h" - -namespace paddle { -#ifndef GFLAGS_NS -#define GFLAGS_NS google -#endif - -namespace gflags_ns = GFLAGS_NS; - -void ParseCommandLineFlags(int* argc, char** argv, bool withHelp) { - if (withHelp) { - gflags_ns::ParseCommandLineFlags(argc, &argv, true); - } else { - gflags_ns::ParseCommandLineNonHelpFlags(argc, &argv, true); - } -} - -} // namespace paddle diff --git a/paddle/utils/CommandLineParser.h b/paddle/utils/CommandLineParser.h deleted file mode 100644 index 4e89f90bb910cee1adc7fb8dace81ff58435351f..0000000000000000000000000000000000000000 --- a/paddle/utils/CommandLineParser.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve. - -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 - -namespace paddle { -void ParseCommandLineFlags(int* argc, char** argv, bool withHelp = true); - -} // namespace paddle diff --git a/paddle/utils/CustomStackTrace.cpp b/paddle/utils/CustomStackTrace.cpp index 66b38218a7c7ec146f366ded516ebe22d012e47f..9723d7df9744989d9dd6035e51eae35764656065 100644 --- a/paddle/utils/CustomStackTrace.cpp +++ b/paddle/utils/CustomStackTrace.cpp @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "CustomStackTrace.h" +#include #include -#include "CommandLineParser.h" DEFINE_bool( layer_stack_error_only_current_thread, diff --git a/paddle/utils/Flags.h b/paddle/utils/Flags.h index 2ebbcb24eb061531d0807756528d7bf16e6aa124..3e72f8356d883b353127ccae80f2881320d20b2b 100644 --- a/paddle/utils/Flags.h +++ b/paddle/utils/Flags.h @@ -14,7 +14,7 @@ limitations under the License. */ #pragma once -#include "CommandLineParser.h" +#include DECLARE_bool(parallel_nn); DECLARE_int32(async_count); diff --git a/paddle/utils/ThreadLocal.cpp b/paddle/utils/ThreadLocal.cpp index 75ccbd28cf21b7fafb43a072503dff14a29fec8a..d27dae33fd039bbefdbc65908e5ce7dc58eceab7 100644 --- a/paddle/utils/ThreadLocal.cpp +++ b/paddle/utils/ThreadLocal.cpp @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "ThreadLocal.h" -#include "CommandLineParser.h" + +#include + #include "Util.h" DEFINE_bool(thread_local_rand_use_global_seed, diff --git a/paddle/utils/Util.cpp b/paddle/utils/Util.cpp index 7c0d66c488f5064641c53ea7995a75c330a3e49d..0f778dbebf4e124c7a240d738b8f73cef03fc477 100644 --- a/paddle/utils/Util.cpp +++ b/paddle/utils/Util.cpp @@ -24,10 +24,10 @@ limitations under the License. */ #include #include -#include "paddle/utils/Logging.h" +#include -#include "CommandLineParser.h" #include "CustomStackTrace.h" +#include "Logging.h" #include "StringUtil.h" #include "Thread.h" #include "ThreadLocal.h" @@ -152,7 +152,12 @@ void initMain(int argc, char** argv) { line += ' '; } LOG(INFO) << "commandline: " << line; - ParseCommandLineFlags(&argc, argv, true); + +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif + + gflags::ParseCommandLineFlags(&argc, &argv, true); CHECK_EQ(argc, 1) << "Unknown commandline argument: " << argv[1]; installProfilerSwitch(); diff --git a/paddle/utils/Util.h b/paddle/utils/Util.h index 24ddde28e7e9f44c32d70e1b9621954ee77b2883..e5a89070f1a953d70a43321cb5417656c907ee9d 100644 --- a/paddle/utils/Util.h +++ b/paddle/utils/Util.h @@ -26,7 +26,6 @@ limitations under the License. */ #include #include -#include "CommandLineParser.h" #include "DisableCopy.h" #include "Logging.h" #include "TrainerConfig.pb.h" diff --git a/paddle/utils/tests/test_CustomStackTrace.cpp b/paddle/utils/tests/test_CustomStackTrace.cpp index 2ce199837601755ac018889c07c223ad34c4a45b..18dd0aac4305006745dcd8e0a0717fb0fb939778 100644 --- a/paddle/utils/tests/test_CustomStackTrace.cpp +++ b/paddle/utils/tests/test_CustomStackTrace.cpp @@ -12,10 +12,11 @@ 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 #include -#include "paddle/utils/CommandLineParser.h" +#include +#include + #include "paddle/utils/CustomStackTrace.h" #include "paddle/utils/Locks.h" #include "paddle/utils/Util.h" diff --git a/paddle/utils/tests/test_SpinLock.cpp b/paddle/utils/tests/test_SpinLock.cpp index 8351e7e3acd1afe1c6507ffced32f27ce065e5ce..605bedb6c912b0436f40e3eff93d5cf95d8dc489 100644 --- a/paddle/utils/tests/test_SpinLock.cpp +++ b/paddle/utils/tests/test_SpinLock.cpp @@ -12,9 +12,11 @@ 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 #include -#include "paddle/utils/CommandLineParser.h" + +#include +#include + #include "paddle/utils/Locks.h" #include "paddle/utils/Logging.h" #include "paddle/utils/Util.h" diff --git a/paddle/utils/tests/test_ThreadBarrier.cpp b/paddle/utils/tests/test_ThreadBarrier.cpp index 60c2214ffd1066ed4f7b95cd63dfe6a24fe66d67..1237f1b731b2fb733d6823619df2c574476b89de 100644 --- a/paddle/utils/tests/test_ThreadBarrier.cpp +++ b/paddle/utils/tests/test_ThreadBarrier.cpp @@ -12,10 +12,12 @@ 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 #include #include -#include "paddle/utils/CommandLineParser.h" + +#include +#include + #include "paddle/utils/Locks.h" #include "paddle/utils/Logging.h" #include "paddle/utils/Util.h" diff --git a/third_party/gflags.BUILD b/third_party/gflags.BUILD deleted file mode 100644 index 85e8bd0bd74942102e5e9a9f817dc49383a745e7..0000000000000000000000000000000000000000 --- a/third_party/gflags.BUILD +++ /dev/null @@ -1,12 +0,0 @@ -# Bazel (http://bazel.io/) BUILD file for gflags. -# -# See INSTALL.md for instructions for adding gflags to a Bazel workspace. - -licenses(["notice"]) - -exports_files(["src/gflags_complections.sh", "COPYING.txt"]) - -load(":bazel/gflags.bzl", "gflags_sources", "gflags_library") -(hdrs, srcs) = gflags_sources(namespace=["google", "gflags"]) -gflags_library(hdrs=hdrs, srcs=srcs, threads=0) -gflags_library(hdrs=hdrs, srcs=srcs, threads=1) diff --git a/third_party/gflags_test/BUILD b/third_party/gflags_test/BUILD deleted file mode 100644 index b50615203ba17c74a4c7611b685f3d3210389bbf..0000000000000000000000000000000000000000 --- a/third_party/gflags_test/BUILD +++ /dev/null @@ -1,10 +0,0 @@ -licenses(["notice"]) # Apache 2.0 - -cc_test( - name="gflags_test", - srcs=["gflags_test.cc"], - copts=["-Iexternal/gtest/include"], - deps=[ - "@gtest//:gtest", - "@gflags//:gflags", - ], ) diff --git a/third_party/gflags_test/gflags_test.cc b/third_party/gflags_test/gflags_test.cc deleted file mode 100644 index 53286e7e5be062cf66b37d07047b173ea831e6c4..0000000000000000000000000000000000000000 --- a/third_party/gflags_test/gflags_test.cc +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -#include "gflags/gflags.h" -#include "gtest/gtest.h" - -DEFINE_bool(verbose, false, "Display program name before message"); -DEFINE_string(message, "Hello world!", "Message to print"); - -static bool IsNonEmptyMessage(const char *flagname, const std::string &value) { - return value[0] != '\0'; -} -DEFINE_validator(message, &IsNonEmptyMessage); - -namespace third_party { -namespace gflags_test { - -TEST(GflagsTest, ParseAndPrint) { - gflags::SetUsageMessage("some usage message"); - gflags::SetVersionString("1.0.0"); - int argc = 1; - char program_name[] = "gflags_test"; - char **argv = new char *[2]; - argv[0] = program_name; - argv[1] = NULL; - gflags::ParseCommandLineFlags(&argc, reinterpret_cast(&argv), true); - EXPECT_EQ("gflags_test", std::string(gflags::ProgramInvocationShortName())); - EXPECT_EQ("Hello world!", FLAGS_message); - gflags::ShutDownCommandLineFlags(); -} - -} // namespace gflags_test -} // namespace third_party diff --git a/third_party/glog.BUILD b/third_party/glog.BUILD deleted file mode 100644 index a0ff1d6b416c2217b62f64bceee3c6a611c11dfe..0000000000000000000000000000000000000000 --- a/third_party/glog.BUILD +++ /dev/null @@ -1,128 +0,0 @@ -licenses(["notice"]) - -cc_library( - visibility=["//visibility:public"], - name="glog", - includes=[ - ".", - "src", - ], - copts=[ - "-D_START_GOOGLE_NAMESPACE_='namespace google {'", - "-D_END_GOOGLE_NAMESPACE_='}'", - "-DGOOGLE_NAMESPACE='google'", - "-DGOOGLE_GLOG_DLL_DECL=''", - "-DHAVE_DLADDR", - "-DHAVE_SNPRINTF", - "-DHAVE_DLFCN_H", - "-DHAVE_FCNTL", - "-DHAVE_GLOB_H", - "-DHAVE_INTTYPES_H", - "-DHAVE_LIBPTHREAD", - "-DHAVE_SYS_SYSCALL_H", - "-DHAVE_MEMORY_H", - "-DHAVE_NAMESPACES", - "-DHAVE_PREAD", - "-DHAVE_PTHREAD", - "-DHAVE_PWD_H", - "-DHAVE_PWRITE", - "-DHAVE_RWLOCK", - "-DHAVE_SIGACTION", - "-DHAVE_SIGALTSTACK", - "-DHAVE_STDINT_H", - "-DHAVE_STRING_H", - "-DHAVE_SYS_TIME_H", - "-DHAVE_SYS_TYPES_H", - "-DHAVE_SYS_UCONTEXT_H", - "-DHAVE_SYS_UTSNAME_H", - "-DHAVE_UNISTD_H", - "-DHAVE_USING_OPERATOR", - "-DHAVE_HAVE___ATTRIBUTE___", - "-DHAVE_HAVE___BUILTIN_EXPECT", - #"-DNO_FRAME_POINTER", - "-D_GNU_SOURCE", - #"-fno-sanitize=thread", - #"-fno-sanitize=address", - "-Iexternal/glog/src", - ], - srcs=[ - "src/demangle.cc", - "src/logging.cc", - "src/raw_logging.cc", - "src/signalhandler.cc", - "src/symbolize.cc", - "src/utilities.cc", - "src/vlog_is_on.cc", - ":config_h", - ":logging_h", - ":raw_logging_h", - ":stl_logging_h", - ":vlog_is_on_h", - ], - hdrs=[ - "src/demangle.h", - "src/mock-log.h", - "src/stacktrace.h", - "src/symbolize.h", - "src/utilities.h", - "src/base/commandlineflags.h", - "src/base/googleinit.h", - "src/base/mutex.h", - "src/glog/log_severity.h", - ]) - -genrule( - name="config_h", - srcs=["src/config.h.cmake.in"], - outs=["config.h"], - cmd="awk '{ gsub(/^#cmakedefine/, \"//cmakedefine\"); print; }' $(<) > $(@)", -) - -genrule( - name="logging_h", - srcs=["src/glog/logging.h.in"], - outs=["glog/logging.h"], - cmd="$(location :gen_sh) < $(<) > $(@)", - tools=[":gen_sh"]) - -genrule( - name="raw_logging_h", - srcs=["src/glog/raw_logging.h.in"], - outs=["glog/raw_logging.h"], - cmd="$(location :gen_sh) < $(<) > $(@)", - tools=[":gen_sh"]) - -genrule( - name="stl_logging_h", - srcs=["src/glog/stl_logging.h.in"], - outs=["glog/stl_logging.h"], - cmd="$(location :gen_sh) < $(<) > $(@)", - tools=[":gen_sh"]) - -genrule( - name="vlog_is_on_h", - srcs=["src/glog/vlog_is_on.h.in"], - outs=["glog/vlog_is_on.h"], - cmd="$(location :gen_sh) < $(<) > $(@)", - tools=[":gen_sh"]) - -genrule( - name="gen_sh", - outs=["gen.sh"], - cmd=""" -cat > $@ <<"EOF" -#! /bin/sh -sed -e 's/@ac_cv_have_unistd_h@/1/g' \ - -e 's/@ac_cv_have_stdint_h@/1/g' \ - -e 's/@ac_cv_have_systypes_h@/1/g' \ - -e 's/@ac_cv_have_libgflags_h@/1/g' \ - -e 's/@ac_cv_have_uint16_t@/1/g' \ - -e 's/@ac_cv_have___builtin_expect@/1/g' \ - -e 's/@ac_cv_have_.*@/0/g' \ - -e 's/@ac_google_start_namespace@/namespace google {/g' \ - -e 's/@ac_google_end_namespace@/}/g' \ - -e 's/@ac_google_namespace@/google/g' \ - -e 's/@ac_cv___attribute___noinline@/__attribute__((noinline))/g' \ - -e 's/@ac_cv___attribute___noreturn@/__attribute__((noreturn))/g' \ - -e 's/@ac_cv___attribute___printf_4_5@/__attribute__((__format__ (__printf__, 4, 5)))/g' -EOF""") diff --git a/third_party/glog_test/BUILD b/third_party/glog_test/BUILD deleted file mode 100644 index 56d08e95f8e8f063829ae68586fa9ef53306fef6..0000000000000000000000000000000000000000 --- a/third_party/glog_test/BUILD +++ /dev/null @@ -1,10 +0,0 @@ -licenses(["notice"]) # Apache 2.0 - -cc_test( - name="glog_test", - srcs=["glog_test.cc"], - copts=["-Iexternal/gtest/include"], - deps=[ - "@gtest//:gtest", - "@glog//:glog", - ], ) diff --git a/third_party/glog_test/glog_test.cc b/third_party/glog_test/glog_test.cc deleted file mode 100644 index f1d737d625d25e8675f636075876903c42881a35..0000000000000000000000000000000000000000 --- a/third_party/glog_test/glog_test.cc +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -#include "glog/logging.h" -#include "gtest/gtest.h" - -TEST(GlogTest, Logging) { LOG(INFO) << "Hello world"; } diff --git a/third_party/gtest.BUILD b/third_party/gtest.BUILD deleted file mode 100644 index 9255b51d9aaa9c7ee5cbc1b2d537815c7ecbfcba..0000000000000000000000000000000000000000 --- a/third_party/gtest.BUILD +++ /dev/null @@ -1,8 +0,0 @@ -cc_library( - name="gtest", - srcs=glob( - ["src/*.cc"], exclude=["src/gtest-all.cc"]), - hdrs=glob(["include/**/*.h", "src/*.h"]), - copts=["-Iexternal/gtest/include"], - linkopts=["-pthread"], - visibility=["//visibility:public"], ) diff --git a/third_party/protobuf_test/BUILD b/third_party/protobuf_test/BUILD deleted file mode 100644 index 67d4293c70eef081f6bb95de9774613a19ba91dd..0000000000000000000000000000000000000000 --- a/third_party/protobuf_test/BUILD +++ /dev/null @@ -1,24 +0,0 @@ -licenses(["notice"]) # Apache 2.0 - -load("@protobuf//:protobuf.bzl", "cc_proto_library") - -cc_proto_library( - name="example_proto", - srcs=["example.proto"], - protoc="@protobuf//:protoc", - default_runtime="@protobuf//:protobuf", ) - -cc_library( - name="example_lib", - srcs=["example_lib.cc"], - hdrs=["example_lib.h"], - deps=[":example_proto"], ) - -cc_test( - name="example_lib_test", - srcs=["example_lib_test.cc"], - copts=["-Iexternal/gtest/include"], - deps=[ - "@gtest//:gtest", - ":example_lib", - ], ) diff --git a/third_party/protobuf_test/README.md b/third_party/protobuf_test/README.md deleted file mode 100644 index e8bdeee6fee66ef79d0b813b4d8dfa4c180754c6..0000000000000000000000000000000000000000 --- a/third_party/protobuf_test/README.md +++ /dev/null @@ -1 +0,0 @@ -This package tests that Bazel can build protobuf related rules. diff --git a/third_party/protobuf_test/example.proto b/third_party/protobuf_test/example.proto deleted file mode 100644 index 6a7eada9c14a9df5d3ef8971b636c14a11da3d11..0000000000000000000000000000000000000000 --- a/third_party/protobuf_test/example.proto +++ /dev/null @@ -1,7 +0,0 @@ -syntax = "proto3"; - -package third_party.protobuf_test; - -message Greeting { - string name = 1; -} diff --git a/third_party/protobuf_test/example_lib.cc b/third_party/protobuf_test/example_lib.cc deleted file mode 100644 index ced377bc0a17dde31c5c853dec1a852fa0be7223..0000000000000000000000000000000000000000 --- a/third_party/protobuf_test/example_lib.cc +++ /dev/null @@ -1,9 +0,0 @@ -#include "third_party/protobuf_test/example_lib.h" - -namespace third_party { -namespace protobuf_test { - -std::string get_greet(const Greeting& who) { return "Hello " + who.name(); } - -} // namespace protobuf_test -} // namespace thrid_party diff --git a/third_party/protobuf_test/example_lib.h b/third_party/protobuf_test/example_lib.h deleted file mode 100644 index 516326e812e19eb162f5392b519904a65c66c660..0000000000000000000000000000000000000000 --- a/third_party/protobuf_test/example_lib.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "third_party/protobuf_test/example.pb.h" - -#include - -namespace third_party { -namespace protobuf_test { - -std::string get_greet(const Greeting &who); - -} // namespace protobuf_test -} // namespace third_party diff --git a/third_party/protobuf_test/example_lib_test.cc b/third_party/protobuf_test/example_lib_test.cc deleted file mode 100644 index 6229f56e6026908fff991765bd6bdaff6f8236ac..0000000000000000000000000000000000000000 --- a/third_party/protobuf_test/example_lib_test.cc +++ /dev/null @@ -1,15 +0,0 @@ -#include "third_party/protobuf_test/example_lib.h" - -#include "gtest/gtest.h" - -namespace third_party { -namespace protobuf_test { - -TEST(ProtobufTest, GetGreet) { - Greeting g; - g.set_name("Paddle"); - EXPECT_EQ("Hello Paddle", get_greet(g)); -} - -} // namespace protobuf_test -} // namespace third_party