Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#251 from allonli/develop
Browse files Browse the repository at this point in the history
/test contains many source files check style
  • Loading branch information
allonli authored May 24, 2018
2 parents 1620fd1 + 942f112 commit 0d35f17
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 85 deletions.
34 changes: 17 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ repos:
sha: v1.0.1
hooks:
- id: remove-crlf
files: (src).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
files: (src/).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
- id: remove-tabs
files: (src).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
files: (test/|src/).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$

- repo: https://github.com/pre-commit/pre-commit-hooks
sha: 5bf6c09bfa1297d3692cadd621ef95f1284e33c0
Expand All @@ -16,17 +16,17 @@ repos:
- id: detect-private-key
files: (?!.*tar.gz)^.*$
- id: end-of-file-fixer
files: (src).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|h|hpp|hxx)$
files: (test/|src/).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|h|hpp|hxx)$
- id: trailing-whitespace
files: (src).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|h|hpp|hxx)$
files: (test/|src/).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|h|hpp|hxx)$

- repo: local
hooks:
- id: copyright
name: copyright
entry: python ./tools/pre-commit.hooks/copyright.hook
language: system
files: (src).*\.(c|cc|cxx|cpp|h|hpp|hxx|py)$
files: (test/|src/).*\.(c|cc|cxx|cpp|h|hpp|hxx|py)$
exclude: (?!.*third_party)^.*$ | (?!.*book)^.*$

- repo: local
Expand All @@ -36,17 +36,7 @@ repos:
description: Format files with ClangFormat.
entry: bash ./tools/pre-commit.hooks/clang-format.hook -i
language: system
files: (src).*\.(c|cc|cxx|cpp|h|hpp|hxx)$

#
#- repo: local
# hooks:
# - id: clang-tidy
# name: clang-tidy
# description: Check C++ code style using clang-tidy.
# entry: bash ./tools/pre-commit.hooks/.clang-tidy.hook -i
# language: system
# files: (src).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
files: (test/|src/).*\.(c|cc|cxx|cpp|h|hpp|hxx)$

- repo: local
hooks:
Expand All @@ -55,6 +45,16 @@ repos:
description: Check C++ code style using cpplint.
entry: bash ./tools/pre-commit.hooks/cpplint.hook
language: system
files: (test|src).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
files: (test/|src/).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
exclude: (?!.*third_party)^.*$ | (?!.*book)^.*$i | *\.pb\.cpp


#
#- repo: local
# hooks:
# - id: clang-tidy
# name: clang-tidy
# description: Check C++ code style using clang-tidy.
# entry: bash ./tools/pre-commit.hooks/.clang-tidy.hook -i
# language: system
# files: (src).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@

This project is used to develop the next version deep learning freamwork for mobile device.

# Development

[Used model in development](https://mms-mis.cdn.bcebos.com/paddle-mobile/models.zip)

## Old Version of Mobile-Deep-Learning
The old version of MDL was I moved to here [Mobile-Deep-Learning](https://github.com/allonli/mobile-deep-learning)



1 change: 0 additions & 1 deletion test/common/test_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ limitations under the License. */
#include "common/log.h"

int main() {

DLOGF("DASJFDAFJ%d -- %f", 12345, 344.234);

LOGF(paddle_mobile::kLOG_DEBUG, "DASJFDAFJ%d -- %f", 12345, 344.234);
Expand Down
14 changes: 6 additions & 8 deletions test/framework/executor_for_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +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 "executor_for_test.h"
#include "framework/executor_for_test.h"

template <typename DeviceType, typename OpType>
Executor4Test<DeviceType, OpType>::Executor4Test(const Program<DeviceType> p,
std::string op_type)
: Executor<DeviceType>(p) {

if (this->program_.originProgram == nullptr) {
LOG(paddle_mobile::LogLevel::kLOG_ERROR)
<< "to_predict_program_ == nullptr";
Expand All @@ -27,7 +26,7 @@ Executor4Test<DeviceType, OpType>::Executor4Test(const Program<DeviceType> p,
const std::vector<std::shared_ptr<BlockDesc>> blocks =
this->to_predict_program_->Blocks();

for (std::shared_ptr<BlockDesc> block_desc: blocks) {
for (std::shared_ptr<BlockDesc> block_desc : blocks) {
std::vector<std::shared_ptr<OpDesc>> ops = block_desc->Ops();
for (std::shared_ptr<OpDesc> op : ops) {
if (op->Type() == op_type) {
Expand All @@ -43,9 +42,8 @@ Executor4Test<DeviceType, OpType>::Executor4Test(const Program<DeviceType> p,
}

template <typename DeviceType, typename OpType>
std::shared_ptr<Tensor>
Executor4Test<DeviceType, OpType>::predict(const Tensor &t, std::string input,
std::string output, DDim &dDim) {
std::shared_ptr<Tensor> Executor4Test<DeviceType, OpType>::predict(
const Tensor &t, std::string input, std::string output, const DDim &dDim) {
auto scope = this->program_.scope;
Variable *g_feed_value = scope->Var(input);
auto tensor = g_feed_value->GetMutable<Tensor>();
Expand All @@ -68,5 +66,5 @@ template class Executor4Test<
paddle_mobile::CPU,
paddle_mobile::operators::PoolOp<paddle_mobile::CPU, float>>;
template class Executor4Test<
paddle_mobile::CPU,
paddle_mobile::operators::SoftmaxOp<paddle_mobile::CPU, float>>;
paddle_mobile::CPU,
paddle_mobile::operators::SoftmaxOp<paddle_mobile::CPU, float>>;
12 changes: 6 additions & 6 deletions test/framework/executor_for_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ limitations under the License. */
#include "operators/pool_op.h"
#include "operators/softmax_op.h"

using paddle_mobile::framework::Tensor;
using paddle_mobile::framework::LoDTensor;
using std::string;
using paddle_mobile::framework::BlockDesc;
using paddle_mobile::framework::DDim;
using paddle_mobile::framework::Executor;
using paddle_mobile::framework::Program;
using paddle_mobile::framework::BlockDesc;
using paddle_mobile::framework::LoDTensor;
using paddle_mobile::framework::OpDesc;
using paddle_mobile::framework::Program;
using paddle_mobile::framework::Tensor;
using paddle_mobile::framework::Variable;
using std::string;
template <typename DeviceType, typename OpType>
class Executor4Test : public Executor<DeviceType> {
public:
Executor4Test(Program<DeviceType> p, string op_type);

std::shared_ptr<Tensor> predict(const Tensor &t, string input, string output,
DDim &dDim);
const DDim &dDim);
};
8 changes: 4 additions & 4 deletions test/framework/test_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ 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 "io.h"
#include "/io.h"

int main() {
paddle_mobile::Loader<paddle_mobile::CPU> loader;

//../../../test/models/googlenet
//../../../test/models/mobilenet
// ../../../test/models/googlenet
// ../../../test/models/mobilenet
auto program = loader.Load(std::string("../models/googlenet"));
return 0;
}
}
10 changes: 3 additions & 7 deletions test/framework/test_optimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,19 @@ 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 "/io.h"
#include "framework/program/program-optimize/node.h"
#include "framework/program/program-optimize/program_optimize.h"
#include "io.h"

using namespace paddle_mobile;
using namespace paddle_mobile::framework;

int main() {

Loader<paddle_mobile::CPU> loader;
// "../../../test/models/googlenet"
auto program = loader.Load("../models/googlenet");
ProgramOptimize optimize;
// program.originProgram->Description("origin");
// program.originProgram->Description("origin");
auto optimize_program = optimize.FushionOptimize(program.originProgram);
if (optimize_program != nullptr) {
// optimize_program->Description("optimize");
// optimize_program->Description("optimize");
} else {
LOG(kLOG_ERROR) << "optimize_program is null";
}
Expand Down
16 changes: 9 additions & 7 deletions test/operators/test_batchnorm_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ limitations under the License. */
namespace paddle_mobile {
namespace framework {

template <typename Dtype> class TestBatchNormOp {
public:
template <typename Dtype>
class TestBatchNormOp {
public:
explicit TestBatchNormOp(const Program<Dtype> p) : program_(p) {
if (use_optimize_) {
to_predict_program_ = program_.optimizeProgram;
Expand Down Expand Up @@ -59,8 +60,9 @@ template <typename Dtype> class TestBatchNormOp {
}
}

std::shared_ptr<Tensor> predict_bn(Tensor &t1, Tensor &t2, Tensor &t3,
Tensor &t4, Tensor &t5) {
std::shared_ptr<Tensor> predict_bn(const Tensor &t1, const Tensor &t2,
const Tensor &t3, const Tensor &t4,
const Tensor &t5) {
// feed
auto scope = program_.scope;
Variable *x1_feed_value = scope->Var("conv2d_0.tmp_0");
Expand Down Expand Up @@ -96,7 +98,7 @@ template <typename Dtype> class TestBatchNormOp {
return out_tensor;
}

private:
private:
const framework::Program<Dtype> program_;
std::shared_ptr<ProgramDesc> to_predict_program_;
std::map<framework::BlockDesc,
Expand All @@ -117,8 +119,8 @@ template <typename Dtype> class TestBatchNormOp {
};

template class TestBatchNormOp<CPU>;
} // namespace framework
} // namespace paddle_mobile
} // namespace framework
} // namespace paddle_mobile

int main() {
DLOG << "----------**********----------";
Expand Down
15 changes: 8 additions & 7 deletions test/operators/test_concat_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ limitations under the License. */
namespace paddle_mobile {
namespace framework {

template <typename Dtype> class TestConcatOp {
public:
template <typename Dtype>
class TestConcatOp {
public:
explicit TestConcatOp(const Program<Dtype> p) : program_(p) {
if (use_optimize_) {
to_predict_program_ = program_.optimizeProgram;
Expand Down Expand Up @@ -55,8 +56,8 @@ template <typename Dtype> class TestConcatOp {
}
}

std::shared_ptr<Tensor> predict_concat(Tensor &t1, Tensor &t2, Tensor &t3,
Tensor &t4) {
std::shared_ptr<Tensor> predict_concat(const Tensor &t1, const Tensor &t2,
const Tensor &t3, const Tensor &t4) {
// feed
auto scope = program_.scope;
Variable *x1_feed_value = scope->Var("conv2d_3.tmp_1");
Expand Down Expand Up @@ -88,7 +89,7 @@ template <typename Dtype> class TestConcatOp {
return out_tensor;
}

private:
private:
const framework::Program<Dtype> program_;
std::shared_ptr<ProgramDesc> to_predict_program_;
std::map<framework::BlockDesc,
Expand All @@ -109,8 +110,8 @@ template <typename Dtype> class TestConcatOp {
};

template class TestConcatOp<CPU>;
} // namespace framework
} // namespace paddle_mobile
} // namespace framework
} // namespace paddle_mobile

int main() {
DLOG << "----------**********----------";
Expand Down
11 changes: 5 additions & 6 deletions test/operators/test_cov_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ 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 "../framework/executor_for_test.h"
#include "../test_helper.h"
#include "./io.h"
#include <io>
#include "framework/executor_for_test.h"
#include "framework/test_helper.h"

int main() {
paddle_mobile::Loader<paddle_mobile::CPU> loader;
//../models/image_classification_resnet.inference.model
// ../models/image_classification_resnet.inference.model
auto program = loader.Load(std::string("../models/googlenet"));
if (program.originProgram == nullptr) {
DLOG << "program file read fail";
Expand All @@ -32,8 +32,7 @@ int main() {
SetupTensor<float>(&input, {1, 3, 32, 32}, static_cast<float>(0),
static_cast<float>(1));
auto out_ddim = paddle_mobile::framework::make_ddim({1, 64, 56, 56});
auto output =
executor.predict(input, "data", "conv2d_0.tmp_0", out_ddim);
auto output = executor.predict(input, "data", "conv2d_0.tmp_0", out_ddim);

auto output_ptr = output->data<float>();
for (int j = 0; j < output->numel(); ++j) {
Expand Down
13 changes: 7 additions & 6 deletions test/operators/test_elementwise_add_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ limitations under the License. */
namespace paddle_mobile {
namespace framework {

template <typename Dtype> class TestElementwiseAddOp {
public:
template <typename Dtype>
class TestElementwiseAddOp {
public:
explicit TestElementwiseAddOp(const Program<Dtype> p) : program_(p) {
if (use_optimize_) {
to_predict_program_ = program_.optimizeProgram;
Expand Down Expand Up @@ -59,7 +60,7 @@ template <typename Dtype> class TestElementwiseAddOp {
}
}

std::shared_ptr<Tensor> predict_add(Tensor &t1, Tensor &t2) {
std::shared_ptr<Tensor> predict_add(const Tensor &t1, const Tensor &t2) {
// feed
auto scope = program_.scope;
Variable *x_feed_value = scope->Var("batch_norm_2.tmp_2");
Expand All @@ -83,7 +84,7 @@ template <typename Dtype> class TestElementwiseAddOp {
return out_tensor;
}

private:
private:
const framework::Program<Dtype> program_;
std::shared_ptr<ProgramDesc> to_predict_program_;
std::map<framework::BlockDesc,
Expand All @@ -103,8 +104,8 @@ template <typename Dtype> class TestElementwiseAddOp {
};

template class TestElementwiseAddOp<CPU>;
} // namespace framework
} // namespace paddle_mobile
} // namespace framework
} // namespace paddle_mobile
int main() {
DLOG << "----------**********----------";
DLOG << "begin to run ElementAddOp Test";
Expand Down
Loading

0 comments on commit 0d35f17

Please sign in to comment.