diff --git a/mace/core/operator.cc b/mace/core/operator.cc index ae6ca107e1f13e72958f401e88cdde5af6005d98..ad3c8e5820d469802cbe0c9cea3da2c12661c227 100644 --- a/mace/core/operator.cc +++ b/mace/core/operator.cc @@ -62,6 +62,8 @@ std::unique_ptr OperatorRegistry::CreateOperator( } } +namespace ops { + extern void Register_Activation(OperatorRegistry *op_registry); extern void Register_AddN(OperatorRegistry *op_registry); extern void Register_BatchNorm(OperatorRegistry *op_registry); @@ -88,32 +90,34 @@ extern void Register_Eltwise(OperatorRegistry *op_registry); extern void Register_FullyConnected(OperatorRegistry *op_registry); extern void Register_Slice(OperatorRegistry *op_registry); +} // namespace ops + OperatorRegistry::OperatorRegistry() { - Register_Activation(this); - Register_AddN(this); - Register_BatchNorm(this); - Register_BatchToSpaceND(this); - Register_BiasAdd(this); - Register_BufferToImage(this); - Register_ChannelShuffle(this); - Register_Concat(this); - Register_Conv2D(this); - Register_DepthwiseConv2d(this); - Register_FoldedBatchNorm(this); - Register_FusedConv2D(this); - Register_GlobalAvgPooling(this); - Register_ImageToBuffer(this); - Register_Pooling(this); - Register_ResizeBilinear(this); - Register_Softmax(this); - Register_SpaceToBatchND(this); - Register_MatMul(this); - Register_WinogradTransform(this); - Register_WinogradInverseTransform(this); - Register_Reshape(this); - Register_Eltwise(this); - Register_FullyConnected(this); - Register_Slice(this); + ops::Register_Activation(this); + ops::Register_AddN(this); + ops::Register_BatchNorm(this); + ops::Register_BatchToSpaceND(this); + ops::Register_BiasAdd(this); + ops::Register_BufferToImage(this); + ops::Register_ChannelShuffle(this); + ops::Register_Concat(this); + ops::Register_Conv2D(this); + ops::Register_DepthwiseConv2d(this); + ops::Register_FoldedBatchNorm(this); + ops::Register_FusedConv2D(this); + ops::Register_GlobalAvgPooling(this); + ops::Register_ImageToBuffer(this); + ops::Register_Pooling(this); + ops::Register_ResizeBilinear(this); + ops::Register_Softmax(this); + ops::Register_SpaceToBatchND(this); + ops::Register_MatMul(this); + ops::Register_WinogradTransform(this); + ops::Register_WinogradInverseTransform(this); + ops::Register_Reshape(this); + ops::Register_Eltwise(this); + ops::Register_FullyConnected(this); + ops::Register_Slice(this); } } // namespace mace diff --git a/mace/ops/activation.cc b/mace/ops/activation.cc index 204896c3cb6538843254b99b7316a903a551aadb..d7a000807654b576199482d63b7249d0049dc1f1 100644 --- a/mace/ops/activation.cc +++ b/mace/ops/activation.cc @@ -5,6 +5,7 @@ #include "mace/ops/activation.h" namespace mace { +namespace ops { void Register_Activation(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("Activation") @@ -26,4 +27,5 @@ void Register_Activation(OperatorRegistry *op_registry) { ActivationOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/activation.h b/mace/ops/activation.h index 12761927a954c2ffd3e94b1a086bc28911e4aae5..bfe91591ed0fab88011de3187cf523c00d3f0fd1 100644 --- a/mace/ops/activation.h +++ b/mace/ops/activation.h @@ -5,10 +5,13 @@ #ifndef MACE_OPS_ACTIVATION_H_ #define MACE_OPS_ACTIVATION_H_ +#include + #include "mace/core/operator.h" #include "mace/kernels/activation.h" namespace mace { +namespace ops { template class ActivationOp : public Operator { @@ -36,6 +39,7 @@ class ActivationOp : public Operator { kernels::ActivationFunctor functor_; }; +} // namespace ops } // namespace mace #endif // MACE_OPS_ACTIVATION_H_ diff --git a/mace/ops/activation_benchmark.cc b/mace/ops/activation_benchmark.cc index 4e904fce84e31762dc03fe23f3047d21d1293eca..d80099d7d5952eede5120d3c4b0bde850865b972 100644 --- a/mace/ops/activation_benchmark.cc +++ b/mace/ops/activation_benchmark.cc @@ -3,11 +3,15 @@ // #include + #include "mace/core/operator.h" #include "mace/core/testing/test_benchmark.h" #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void ReluBenchmark( int iters, int batch, int channels, int height, int width) { @@ -316,4 +320,6 @@ BM_SIGMOID(1, 3, 512, 512); BM_SIGMOID(1, 32, 112, 112); BM_SIGMOID(1, 64, 256, 256); +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/activation_test.cc b/mace/ops/activation_test.cc index 77f8e745b23da3e8e3755a422e5bf7d7dc1452d8..82006c56fcc6cb4543b24ef698d8c4adfaf7ddbd 100644 --- a/mace/ops/activation_test.cc +++ b/mace/ops/activation_test.cc @@ -6,6 +6,8 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { class ActivationOpTest : public OpsTestBase {}; @@ -365,4 +367,6 @@ TEST_F(ActivationOpTest, OPENCLSimpleSigmoid) { TestSimpleSigmoid(); } +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/addn.cc b/mace/ops/addn.cc index 2a18e458ac049bb17fe48309b745541b501dffd8..8e253cf1dbbd45791e72b65352af60d389e44b87 100644 --- a/mace/ops/addn.cc +++ b/mace/ops/addn.cc @@ -5,6 +5,7 @@ #include "mace/ops/addn.h" namespace mace { +namespace ops { void Register_AddN(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("AddN") @@ -26,4 +27,5 @@ void Register_AddN(OperatorRegistry *op_registry) { AddNOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/addn.h b/mace/ops/addn.h index 5824844b380fc220d11d399f4b306a1065c77186..24a91660e7d49af683fada81e90e8215ec2e699c 100644 --- a/mace/ops/addn.h +++ b/mace/ops/addn.h @@ -11,6 +11,7 @@ #include "mace/kernels/addn.h" namespace mace { +namespace ops { template class AddNOp : public Operator { @@ -40,6 +41,7 @@ class AddNOp : public Operator { kernels::AddNFunctor functor_; }; +} // namespace ops } // namespace mace #endif // MACE_OPS_ADDN_H_ diff --git a/mace/ops/addn_benchmark.cc b/mace/ops/addn_benchmark.cc index 85c7853de2c6e08e4b4ab525d13f80293881b0aa..79d3aca33855119f1fa44a9871cd71c47418b0b6 100644 --- a/mace/ops/addn_benchmark.cc +++ b/mace/ops/addn_benchmark.cc @@ -3,11 +3,15 @@ // #include + #include "mace/core/operator.h" #include "mace/core/testing/test_benchmark.h" #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void AddNBenchmark(int iters, int inputs, int n, int h, int w, int c) { mace::testing::StopTiming(); @@ -75,4 +79,6 @@ BM_ADDN(4, 1, 128, 128, 3); BM_ADDN(2, 1, 256, 256, 3); BM_ADDN(2, 1, 512, 512, 3); +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/addn_test.cc b/mace/ops/addn_test.cc index c061e40c6ae6047afe2e30e0ae9417b72821eb51..e6e5b4cb923066ee9ed02cc87b4e388959b79b6d 100644 --- a/mace/ops/addn_test.cc +++ b/mace/ops/addn_test.cc @@ -6,6 +6,8 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { class AddnOpTest : public OpsTestBase {}; @@ -62,15 +64,15 @@ TEST_F(AddnOpTest, CPUSimpleAdd3) { SimpleAdd3(); } template void RandomTest() { testing::internal::LogToStderr(); - srand(time(NULL)); + static unsigned int seed = time(NULL); for (int round = 0; round < 10; ++round) { - // generate random input - index_t n = 1 + (rand() % 5); - index_t h = 1 + (rand() % 100); - index_t w = 1 + (rand() % 100); - index_t c = 1 + (rand() % 32); - int input_num = 2 + rand() % 3; + // generate random input + index_t n = 1 + (rand_r(&seed) % 5); + index_t h = 1 + (rand_r(&seed) % 100); + index_t w = 1 + (rand_r(&seed) % 100); + index_t c = 1 + (rand_r(&seed) % 32); + int input_num = 2 + rand_r(&seed) % 3; // Construct graph OpsTestNet net; auto op_def = OpDefBuilder("AddN", "AddNTest"); @@ -117,4 +119,6 @@ void RandomTest() { TEST_F(AddnOpTest, OPENCLRandom) { RandomTest(); } +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/batch_norm.cc b/mace/ops/batch_norm.cc index e0754fee8c502f542a25ff17eb2bfc3b828885e0..6e804cd1ae3535acfe6f402683d8ac9550f702dd 100644 --- a/mace/ops/batch_norm.cc +++ b/mace/ops/batch_norm.cc @@ -5,6 +5,7 @@ #include "mace/ops/batch_norm.h" namespace mace { +namespace ops { void Register_BatchNorm(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("BatchNorm") @@ -26,4 +27,5 @@ void Register_BatchNorm(OperatorRegistry *op_registry) { BatchNormOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/batch_norm.h b/mace/ops/batch_norm.h index 96b1af133b2532f1fbf9166219547d079d2637ed..f22c52b573ffd1d9ef0c1f0f5de3d603c84e7277 100644 --- a/mace/ops/batch_norm.h +++ b/mace/ops/batch_norm.h @@ -10,6 +10,7 @@ #include "mace/kernels/batch_norm.h" namespace mace { +namespace ops { template class BatchNormOp : public Operator { @@ -55,6 +56,7 @@ class BatchNormOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_BATCH_NORM_H_ diff --git a/mace/ops/batch_norm_benchmark.cc b/mace/ops/batch_norm_benchmark.cc index 5091e26e77fc1f445b4f62e5ff1340a85fe2ab6d..cdd4c693631dcbbecc3c2c0bf250153bd280dad7 100644 --- a/mace/ops/batch_norm_benchmark.cc +++ b/mace/ops/batch_norm_benchmark.cc @@ -8,6 +8,9 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void BatchNorm( int iters, int batch, int channels, int height, int width) { @@ -101,4 +104,6 @@ BM_BATCH_NORM(1, 1024, 7, 7); BM_BATCH_NORM(32, 1, 256, 256); BM_BATCH_NORM(32, 3, 256, 256); +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/batch_norm_test.cc b/mace/ops/batch_norm_test.cc index 5c2f703841e0ce084ff8120d3b8002f2d8b4d407..5a599a611c28cce68bdef2b3036dcdfe7872bd86 100644 --- a/mace/ops/batch_norm_test.cc +++ b/mace/ops/batch_norm_test.cc @@ -6,6 +6,8 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { class BatchNormOpTest : public OpsTestBase {}; @@ -75,11 +77,10 @@ TEST_F(BatchNormOpTest, SimpleCPU) { Simple(); } TEST_F(BatchNormOpTest, SimpleOPENCL) { Simple(); } TEST_F(BatchNormOpTest, SimpleRandomOPENCL) { - srand(time(NULL)); - // generate random input - index_t batch = 1 + rand() % 10; - index_t channels = 3 + rand() % 50; + static unsigned int seed = time(NULL); + index_t batch = 1 + rand_r(&seed) % 10; + index_t channels = 3 + rand_r(&seed) % 50; index_t height = 64; index_t width = 64; @@ -147,11 +148,10 @@ TEST_F(BatchNormOpTest, SimpleRandomOPENCL) { } TEST_F(BatchNormOpTest, SimpleRandomHalfOPENCL) { - srand(time(NULL)); - // generate random input - index_t batch = 1 + rand() % 10; - index_t channels = 3 + rand() % 50; + static unsigned int seed = time(NULL); + index_t batch = 1 + rand_r(&seed) % 10; + index_t channels = 3 + rand_r(&seed) % 50; index_t height = 64; index_t width = 64; @@ -220,11 +220,10 @@ TEST_F(BatchNormOpTest, SimpleRandomHalfOPENCL) { } TEST_F(BatchNormOpTest, ComplexRandomOPENCL) { - srand(time(NULL)); - // generate random input - index_t batch = 1 + rand() % 10; - index_t channels = 3 + rand() % 50; + static unsigned int seed = time(NULL); + index_t batch = 1 + rand_r(&seed) % 10; + index_t channels = 3 + rand_r(&seed) % 50; index_t height = 103; index_t width = 113; @@ -292,11 +291,10 @@ TEST_F(BatchNormOpTest, ComplexRandomOPENCL) { } TEST_F(BatchNormOpTest, ComplexRandomHalfOPENCL) { - srand(time(NULL)); - // generate random input - index_t batch = 1 + rand() % 10; - index_t channels = 3 + rand() % 50; + static unsigned int seed = time(NULL); + index_t batch = 1 + rand_r(&seed) % 10; + index_t channels = 3 + rand_r(&seed) % 50; index_t height = 103; index_t width = 113; @@ -363,4 +361,7 @@ TEST_F(BatchNormOpTest, ComplexRandomHalfOPENCL) { kernels::BufferType::IN_OUT_CHANNEL); ExpectTensorNear(expected, *net.GetOutput("OPENCLOutput"), 0.5); } -} + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/batch_to_space.cc b/mace/ops/batch_to_space.cc index 83a79fba400c56f4e83b0b6f73748bd559c9bbb7..878e79f4f7c359b792560d2889b8552ba7086f4f 100644 --- a/mace/ops/batch_to_space.cc +++ b/mace/ops/batch_to_space.cc @@ -5,6 +5,7 @@ #include "mace/ops/batch_to_space.h" namespace mace { +namespace ops { void Register_BatchToSpaceND(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("BatchToSpaceND") @@ -19,4 +20,5 @@ void Register_BatchToSpaceND(OperatorRegistry *op_registry) { BatchToSpaceNDOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/batch_to_space.h b/mace/ops/batch_to_space.h index 91d2c0c63ecb89e18b3d82121742fd5aa03a5461..51157aa72d2e6f77dc30e70e76f274f68d8d96d2 100644 --- a/mace/ops/batch_to_space.h +++ b/mace/ops/batch_to_space.h @@ -2,15 +2,17 @@ // Copyright (c) 2017 XiaoMi All rights reserved. // -#ifndef MACE_OPS_SPACE_TO_BATCH_H_ -#define MACE_OPS_SPACE_TO_BATCH_H_ +#ifndef MACE_OPS_BATCH_TO_SPACE_H_ +#define MACE_OPS_BATCH_TO_SPACE_H_ #include +#include #include "mace/core/operator.h" #include "mace/kernels/space_to_batch.h" namespace mace { +namespace ops { template class BatchToSpaceNDOp : public Operator { @@ -68,6 +70,7 @@ class BatchToSpaceNDOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace -#endif // MACE_OPS_SPACE_TO_BATCH_H_ +#endif // MACE_OPS_BATCH_TO_SPACE_H_ diff --git a/mace/ops/batch_to_space_benchmark.cc b/mace/ops/batch_to_space_benchmark.cc index aa68adc4ae4fd90969e0d334078df48fc1a79bc3..9d85d7d9df037d0cc7f814a02efbe6681f514099 100644 --- a/mace/ops/batch_to_space_benchmark.cc +++ b/mace/ops/batch_to_space_benchmark.cc @@ -7,6 +7,9 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void BMBatchToSpace( int iters, int batch, int channels, int height, int width, int arg) { @@ -53,4 +56,7 @@ static void BMBatchToSpace( BM_BATCH_TO_SPACE(128, 8, 8, 128, 2); BM_BATCH_TO_SPACE(4, 128, 128, 32, 2); BM_BATCH_TO_SPACE(16, 64, 64, 32, 4); + +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/bias_add.cc b/mace/ops/bias_add.cc index 44b147ea4ef4e5f93df1d8da8abfcca9f215b428..aeeabc49e0ef1a52c10efcdfa131d70e95a0affa 100644 --- a/mace/ops/bias_add.cc +++ b/mace/ops/bias_add.cc @@ -5,6 +5,7 @@ #include "mace/ops/bias_add.h" namespace mace { +namespace ops { void Register_BiasAdd(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("BiasAdd") @@ -26,4 +27,5 @@ void Register_BiasAdd(OperatorRegistry *op_registry) { BiasAddOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/bias_add.h b/mace/ops/bias_add.h index ddc88f731cdb7ebd5fe156f74c0c9d3c12258718..686dd673eb5acc669b490a46e1da1612b2275e71 100644 --- a/mace/ops/bias_add.h +++ b/mace/ops/bias_add.h @@ -2,13 +2,14 @@ // Copyright (c) 2017 XiaoMi All rights reserved. // -#ifndef MACE_BIAS_ADD_H_ -#define MACE_BIAS_ADD_H_ +#ifndef MACE_OPS_BIAS_ADD_H_ +#define MACE_OPS_BIAS_ADD_H_ #include "mace/core/operator.h" #include "mace/kernels/bias_add.h" namespace mace { +namespace ops { template class BiasAddOp : public Operator { @@ -40,6 +41,7 @@ class BiasAddOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace -#endif // MACE_BIAS_ADD_H_ +#endif // MACE_OPS_BIAS_ADD_H_ diff --git a/mace/ops/bias_add_benchmark.cc b/mace/ops/bias_add_benchmark.cc index 8af9405b0a0cd9958d674dcd50476eb6816725e4..1ba0fac20812239703cf9c2fa5ccf37e8a7bc715 100644 --- a/mace/ops/bias_add_benchmark.cc +++ b/mace/ops/bias_add_benchmark.cc @@ -8,6 +8,9 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void BiasAdd(int iters, int batch, int channels, int height, int width) { mace::testing::StopTiming(); @@ -77,4 +80,7 @@ BM_BIAS_ADD(1, 512, 14, 14); BM_BIAS_ADD(1, 1024, 7, 7); BM_BIAS_ADD(32, 1, 256, 256); BM_BIAS_ADD(32, 3, 256, 256); + +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/bias_add_test.cc b/mace/ops/bias_add_test.cc index 91bc96e4553c53c1f611fd5a16b3012eb8f7e4cf..4803bcd23611d6d8728cd99e82d58cb8ecc29303 100644 --- a/mace/ops/bias_add_test.cc +++ b/mace/ops/bias_add_test.cc @@ -6,6 +6,8 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { class BiasAddOpTest : public OpsTestBase {}; @@ -60,13 +62,12 @@ TEST_F(BiasAddOpTest, BiasAddSimpleOPENCL) { } TEST_F(BiasAddOpTest, SimpleRandomOPENCL) { - srand(time(NULL)); - // generate random input - index_t batch = 1 + rand() % 10; - index_t channels = 3 + rand() % 50; - index_t height = 64 + rand() % 50; - index_t width = 64 + rand() % 50; + static unsigned int seed = time(NULL); + index_t batch = 1 + rand_r(&seed) % 10; + index_t channels = 3 + rand_r(&seed) % 50; + index_t height = 64 + rand_r(&seed) % 50; + index_t width = 64 + rand_r(&seed) % 50; // Construct graph OpsTestNet net; @@ -110,13 +111,12 @@ TEST_F(BiasAddOpTest, SimpleRandomOPENCL) { } TEST_F(BiasAddOpTest, ComplexRandomOPENCL) { - srand(time(NULL)); - // generate random input - index_t batch = 1 + rand() % 10; - index_t channels = 3 + rand() % 50; - index_t height = 103 + rand() % 100; - index_t width = 113 + rand() % 100; + static unsigned int seed = time(NULL); + index_t batch = 1 + rand_r(&seed) % 10; + index_t channels = 3 + rand_r(&seed) % 50; + index_t height = 103 + rand_r(&seed) % 100; + index_t width = 113 + rand_r(&seed) % 100; // Construct graph OpsTestNet net; @@ -158,4 +158,7 @@ TEST_F(BiasAddOpTest, ComplexRandomOPENCL) { kernels::BufferType::IN_OUT_CHANNEL); ExpectTensorNear(expected, *net.GetOutput("OPENCLOutput"), 1e-2); } -} + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/buffer_to_image.cc b/mace/ops/buffer_to_image.cc index 718374de349ef20d476faa063ee63fb2557bb3b7..abeccde0c49f229071e6c00e33f3fce72ca9abcf 100644 --- a/mace/ops/buffer_to_image.cc +++ b/mace/ops/buffer_to_image.cc @@ -5,6 +5,7 @@ #include "mace/ops/buffer_to_image.h" namespace mace { +namespace ops { void Register_BufferToImage(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("BufferToImage") @@ -20,4 +21,5 @@ void Register_BufferToImage(OperatorRegistry *op_registry) { BufferToImageOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/buffer_to_image.h b/mace/ops/buffer_to_image.h index d1d8621b0063b89965a8a83e6d27aba639ac8893..a50bebd37f2395b729486bed50cc00f971422a84 100644 --- a/mace/ops/buffer_to_image.h +++ b/mace/ops/buffer_to_image.h @@ -9,6 +9,7 @@ #include "mace/kernels/buffer_to_image.h" namespace mace { +namespace ops { template class BufferToImageOp : public Operator { @@ -36,5 +37,6 @@ class BufferToImageOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_BUFFER_TO_IMAGE_H_ diff --git a/mace/ops/buffer_to_image_test.cc b/mace/ops/buffer_to_image_test.cc index 04baa38275f6ecf4309a33ae5ed6ed3603007dfb..1d6d55ad181ae880f423b8444b49fb0e92255a8a 100644 --- a/mace/ops/buffer_to_image_test.cc +++ b/mace/ops/buffer_to_image_test.cc @@ -5,7 +5,9 @@ #include "gtest/gtest.h" #include "mace/ops/ops_test_util.h" -using namespace mace; +namespace mace { +namespace ops { +namespace test { template void TestBidirectionTransform(const int type, @@ -188,3 +190,7 @@ TEST(BufferToImageTest, ArgStringHalfToHalfSmall) { TestStringHalfBidirectionTransform( kernels::ARGUMENT, {2}, input_data); } + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/channel_shuffle.cc b/mace/ops/channel_shuffle.cc index 9e00da6f9eccaacc7e10e93bcff81c03904993da..c1c5df9cd2da4046c33585d15d708f97625b9139 100644 --- a/mace/ops/channel_shuffle.cc +++ b/mace/ops/channel_shuffle.cc @@ -5,6 +5,7 @@ #include "mace/ops/channel_shuffle.h" namespace mace { +namespace ops { void Register_ChannelShuffle(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("ChannelShuffle") @@ -24,4 +25,5 @@ void Register_ChannelShuffle(OperatorRegistry *op_registry) { ChannelShuffleOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/channel_shuffle.h b/mace/ops/channel_shuffle.h index 5de47d663e96ba31368ab89c2b651730ede024a7..93cbfd40230034ac586561387d4bf7bb490f3794 100644 --- a/mace/ops/channel_shuffle.h +++ b/mace/ops/channel_shuffle.h @@ -11,6 +11,7 @@ #include "mace/kernels/channel_shuffle.h" namespace mace { +namespace ops { template class ChannelShuffleOp : public Operator { @@ -42,6 +43,7 @@ class ChannelShuffleOp : public Operator { kernels::ChannelShuffleFunctor functor_; }; +} // namespace ops } // namespace mace #endif // MACE_OPS_CHANNEL_SHUFFLE_H_ diff --git a/mace/ops/channel_shuffle_benchmark.cc b/mace/ops/channel_shuffle_benchmark.cc index 7f403b5670a4ec59ae09a5a74096a72d763fa98c..5fa1f6bd36faef15331ecd0efb9a1ab70b76902f 100644 --- a/mace/ops/channel_shuffle_benchmark.cc +++ b/mace/ops/channel_shuffle_benchmark.cc @@ -7,10 +7,12 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { -template +template static void ChannelShuffle( - int iters, int batch, int channels, int height, int width, int group) { + int iters, int batch, int channels, int height, int width, int group) { mace::testing::StopTiming(); OpsTestNet net; @@ -23,15 +25,15 @@ static void ChannelShuffle( kernels::BufferType::IN_OUT_CHANNEL); OpDefBuilder("ChannelShuffle", "ChannelShuffleTest") - .Input("InputImage") - .Output("Output") - .AddIntArg("group", group) - .Finalize(net.NewOperatorDef()); + .Input("InputImage") + .Output("Output") + .AddIntArg("group", group) + .Finalize(net.NewOperatorDef()); } else { OpDefBuilder("Softmax", "SoftmaxBM") - .Input("Input") - .Output("Output") - .Finalize(net.NewOperatorDef()); + .Input("Input") + .Output("Output") + .Finalize(net.NewOperatorDef()); } // Warm-up @@ -47,18 +49,19 @@ static void ChannelShuffle( net.Sync(); } -#define BM_CHANNEL_SHUFFLE_MACRO(N, C, H, W, G, TYPE, DEVICE) \ - static void BM_CHANNEL_SHUFFLE_##N##_##C##_##H##_##W##_##G##_##TYPE##_##DEVICE( \ - int iters) { \ - const int64_t tot = static_cast(iters) * N * C * H * W; \ - mace::testing::MaccProcessed(tot); \ - mace::testing::BytesProcessed(tot *(sizeof(TYPE))); \ - ChannelShuffle(iters, N, C, H, W, G); \ - } \ +#define BM_CHANNEL_SHUFFLE_MACRO(N, C, H, W, G, TYPE, DEVICE) \ + static void \ + BM_CHANNEL_SHUFFLE_##N##_##C##_##H##_##W##_##G##_##TYPE##_##DEVICE( \ + int iters) { \ + const int64_t tot = static_cast(iters) * N * C * H * W; \ + mace::testing::MaccProcessed(tot); \ + mace::testing::BytesProcessed(tot *(sizeof(TYPE))); \ + ChannelShuffle(iters, N, C, H, W, G); \ + } \ BENCHMARK(BM_CHANNEL_SHUFFLE_##N##_##C##_##H##_##W##_##G##_##TYPE##_##DEVICE) -#define BM_CHANNEL_SHUFFLE(N, C, H, W, G) \ - BM_CHANNEL_SHUFFLE_MACRO(N, C, H, W, G, float, CPU); \ +#define BM_CHANNEL_SHUFFLE(N, C, H, W, G) \ + BM_CHANNEL_SHUFFLE_MACRO(N, C, H, W, G, float, CPU); \ BM_CHANNEL_SHUFFLE_MACRO(N, C, H, W, G, float, OPENCL); \ BM_CHANNEL_SHUFFLE_MACRO(N, C, H, W, G, half, OPENCL); @@ -66,4 +69,6 @@ BM_CHANNEL_SHUFFLE(1, 64, 64, 64, 8); BM_CHANNEL_SHUFFLE(1, 64, 128, 128, 8); BM_CHANNEL_SHUFFLE(1, 64, 256, 256, 8); -} // namespace mace +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/channel_shuffle_test.cc b/mace/ops/channel_shuffle_test.cc index 879e563edf4e1581a295a3cf6e1e1be37d53d3c8..6de9904c04e45e5b59c63dca9da08fac19cf39c9 100644 --- a/mace/ops/channel_shuffle_test.cc +++ b/mace/ops/channel_shuffle_test.cc @@ -1,10 +1,13 @@ // // Copyright (c) 2017 XiaoMi All rights reserved. // + #include "mace/core/operator.h" #include "mace/ops/ops_test_util.h" -using namespace mace; +namespace mace { +namespace ops { +namespace test { class ChannelShuffleOpTest : public OpsTestBase {}; @@ -38,30 +41,34 @@ TEST_F(ChannelShuffleOpTest, C16G4_OPENCL) { // Add input data net.AddInputFromArray( - "Input", {1, 1, 2, 16}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}); + "Input", {1, 1, 2, 16}, + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}); BufferToImage(net, "Input", "InputImage", - kernels::BufferType::IN_OUT_CHANNEL); - + kernels::BufferType::IN_OUT_CHANNEL); OpDefBuilder("ChannelShuffle", "ChannelShuffleTest") - .Input("InputImage") - .Output("OutputImage") - .AddIntArg("group", 4) - .Finalize(net.NewOperatorDef()); + .Input("InputImage") + .Output("OutputImage") + .AddIntArg("group", 4) + .Finalize(net.NewOperatorDef()); // Run net.RunOp(DeviceType::OPENCL); // Transfer output ImageToBuffer(net, "OutputImage", "Output", - kernels::BufferType::IN_OUT_CHANNEL); + kernels::BufferType::IN_OUT_CHANNEL); // Check auto expected = CreateTensor( - {1, 1, 2, 16}, {0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, - 16, 20, 24, 28, 17, 21, 25, 29, 18, 22, 26, 30, 19, 23, 27, 31}); + {1, 1, 2, 16}, + {0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, + 16, 20, 24, 28, 17, 21, 25, 29, 18, 22, 26, 30, 19, 23, 27, 31}); ExpectTensorNear(*expected, *net.GetOutput("Output"), 0.001); -} \ No newline at end of file +} + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/concat.cc b/mace/ops/concat.cc index 361fce51cf0ce7ecfb60da65e5b17791a6c4067d..2e6dbc8f30e99fac1e762466d034013b9239d968 100644 --- a/mace/ops/concat.cc +++ b/mace/ops/concat.cc @@ -5,6 +5,7 @@ #include "mace/ops/concat.h" namespace mace { +namespace ops { void Register_Concat(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("Concat") @@ -25,4 +26,5 @@ void Register_Concat(OperatorRegistry *op_registry) { ConcatOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/concat.h b/mace/ops/concat.h index cadd52937fd35e9fbf158411c40330d9da0e7ee3..b791619d31d440393dd9fdb0dfb688199d6789ec 100644 --- a/mace/ops/concat.h +++ b/mace/ops/concat.h @@ -5,9 +5,13 @@ #ifndef MACE_OPS_CONCAT_H_ #define MACE_OPS_CONCAT_H_ +#include + #include "mace/core/operator.h" #include "mace/kernels/concat.h" + namespace mace { +namespace ops { template class ConcatOp : public Operator { @@ -41,6 +45,7 @@ class ConcatOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_CONCAT_H_ diff --git a/mace/ops/concat_benchmark.cc b/mace/ops/concat_benchmark.cc index bbbbc126c34d7ee50c0816d289f88bd1b6830148..6e98d03c69ede587c2551f0ec5114be9611643de 100644 --- a/mace/ops/concat_benchmark.cc +++ b/mace/ops/concat_benchmark.cc @@ -7,6 +7,9 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void ConcatHelper(int iters, int concat_dim, int dim1) { mace::testing::StopTiming(); @@ -106,4 +109,6 @@ BM_CONCAT_OPENCL_MACRO(3, 32, 32, 64, half); BM_CONCAT_OPENCL_MACRO(3, 32, 32, 128, half); BM_CONCAT_OPENCL_MACRO(3, 32, 32, 256, half); +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/concat_test.cc b/mace/ops/concat_test.cc index 2e061ad4d92e99c6d8b1f069cda71e39eaf09ca0..9612b04dce7f7e5c0ce28742163fdeb35784f7a2 100644 --- a/mace/ops/concat_test.cc +++ b/mace/ops/concat_test.cc @@ -2,11 +2,16 @@ // Copyright (c) 2017 XiaoMi All rights reserved. // -#include "mace/ops/concat.h" +#include +#include + #include "gmock/gmock.h" #include "mace/ops/ops_test_util.h" +#include "mace/ops/concat.h" -using namespace mace; +namespace mace { +namespace ops { +namespace test { class ConcatOpTest : public OpsTestBase {}; @@ -87,10 +92,10 @@ TEST_F(ConcatOpTest, CPUSimpleVertical) { } TEST_F(ConcatOpTest, CPURandom) { - srand(time(nullptr)); + static unsigned int seed = time(NULL); int dim = 5; - int num_inputs = 2 + rand() % 10; - int axis = rand() % dim; + int num_inputs = 2 + rand_r(&seed) % 10; + int axis = rand_r(&seed) % dim; // Construct graph OpsTestNet net; auto builder = OpDefBuilder("Concat", "ConcatTest"); @@ -108,7 +113,7 @@ TEST_F(ConcatOpTest, CPURandom) { std::vector input_ptrs(num_inputs, nullptr); index_t concat_axis_size = 0; for (int i = 0; i < num_inputs; ++i) { - input_shapes[i][axis] = 1 + rand() % dim; + input_shapes[i][axis] = 1 + rand_r(&seed) % dim; concat_axis_size += input_shapes[i][axis]; GenerateRandomRealTypeData(input_shapes[i], inputs[i]); input_ptrs[i] = inputs[i].data(); @@ -216,4 +221,8 @@ TEST_F(ConcatOpTest, OPENCLUnAligned) { TEST_F(ConcatOpTest, OPENCLAlignedMultiInput) { OpenclRandomTest( {{3, 32, 32, 32}, {3, 32, 32, 32}, {3, 32, 32, 32}, {3, 32, 32, 32}}, 3); -} \ No newline at end of file +} + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/conv_2d.cc b/mace/ops/conv_2d.cc index 0185c1d1e62cdb0bf836b162e29101b12aa6f348..cf45d9df7acf38b4da0c1afa6f3f6c501b5a9a8b 100644 --- a/mace/ops/conv_2d.cc +++ b/mace/ops/conv_2d.cc @@ -5,6 +5,7 @@ #include "mace/ops/conv_2d.h" namespace mace { +namespace ops { void Register_Conv2D(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("Conv2D") @@ -26,4 +27,5 @@ void Register_Conv2D(OperatorRegistry *op_registry) { Conv2dOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/conv_2d.h b/mace/ops/conv_2d.h index c441b0b45b0b00619fe0a36554dcef307227b2d9..08f1bab24ea1b6b8b19faf34d57d38de0fcfb71b 100644 --- a/mace/ops/conv_2d.h +++ b/mace/ops/conv_2d.h @@ -12,6 +12,7 @@ #include "mace/ops/conv_pool_2d_base.h" namespace mace { +namespace ops { template class Conv2dOp : public ConvPool2dOpBase { @@ -44,6 +45,7 @@ class Conv2dOp : public ConvPool2dOpBase { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_CONV_2D_H_ diff --git a/mace/ops/conv_2d_benchmark.cc b/mace/ops/conv_2d_benchmark.cc index 05af6a09c4191f2b2ab675006329908f9e9b9aab..5399d0ad8dcc4776a6d0f43e1732c83360d99e2c 100644 --- a/mace/ops/conv_2d_benchmark.cc +++ b/mace/ops/conv_2d_benchmark.cc @@ -10,6 +10,8 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { template static void Conv2d(int iters, @@ -139,4 +141,6 @@ BM_CONV_2D(1, 32, 256, 256, 3, 3, 1, 4, VALID, 32); BM_CONV_2D(1, 128, 56, 56, 1, 1, 1, 1, SAME, 128); BM_CONV_2D(1, 1024, 7, 7, 1, 1, 1, 1, SAME, 1024); +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/conv_2d_test.cc b/mace/ops/conv_2d_test.cc index 086f73284fc2584c07d6edeaf766a9e5b52cee19..0fcde7188626883692e18b217d1ba6e52f8c137c 100644 --- a/mace/ops/conv_2d_test.cc +++ b/mace/ops/conv_2d_test.cc @@ -2,11 +2,15 @@ // Copyright (c) 2017 XiaoMi All rights reserved. // -#include "mace/ops/conv_2d.h" #include +#include + +#include "mace/ops/conv_2d.h" #include "mace/ops/ops_test_util.h" -using namespace mace; +namespace mace { +namespace ops { +namespace test { class Conv2dOpTest : public OpsTestBase {}; @@ -347,14 +351,13 @@ static void TestComplexConvNxNS12(const std::vector &shape, testing::internal::LogToStderr(); auto func = [&](int kernel_h, int kernel_w, int stride_h, int stride_w, Padding type) { - srand(time(NULL)); - // generate random input - index_t batch = 3 + (rand() % 10); + static unsigned int seed = time(NULL); + index_t batch = 3 + (rand_r(&seed) % 10); index_t height = shape[0]; index_t width = shape[1]; - index_t input_channels = shape[2] + (rand() % 10); - index_t output_channels = shape[3] + (rand() % 10); + index_t input_channels = shape[2] + (rand_r(&seed) % 10); + index_t output_channels = shape[3] + (rand_r(&seed) % 10); // Construct graph OpsTestNet net; OpDefBuilder("Conv2D", "Conv2dTest") @@ -729,3 +732,7 @@ TEST_F(Conv2dOpTest, OPENCLAlignedPad2) { TEST_F(Conv2dOpTest, OPENCLUnalignedPad4) { TestArbitraryPadConvNxN({107, 113, 5, 7}, {4, 4}); } + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/conv_pool_2d_base.h b/mace/ops/conv_pool_2d_base.h index c3db95abcee0b253b3d7b9a37dfac6f8e5ae8ab4..a6f1299da25174e15a267373ca70a1090878c53b 100644 --- a/mace/ops/conv_pool_2d_base.h +++ b/mace/ops/conv_pool_2d_base.h @@ -5,10 +5,13 @@ #ifndef MACE_OPS_CONV_POOL_2D_BASE_H_ #define MACE_OPS_CONV_POOL_2D_BASE_H_ +#include + #include "mace/core/operator.h" #include "mace/kernels/conv_pool_2d_util.h" namespace mace { +namespace ops { template class ConvPool2dOpBase : public Operator { @@ -29,6 +32,7 @@ class ConvPool2dOpBase : public Operator { std::vector dilations_; }; +} // namespace ops } // namespace mace #endif // MACE_OPS_CONV_POOL_2D_BASE_H_ diff --git a/mace/ops/core_test.cc b/mace/ops/core_test.cc index 5c4f6efaf2a6b19df77185aa9c9740f760cd069b..3d533e5d5eddc56c74db483f173cac93bdb0ccd4 100644 --- a/mace/ops/core_test.cc +++ b/mace/ops/core_test.cc @@ -5,6 +5,8 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { TEST(CoreTest, INIT_MODE) { std::vector op_defs; @@ -56,4 +58,6 @@ TEST(CoreTest, INIT_MODE) { 1e-5); } +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/depthwise_conv2d.cc b/mace/ops/depthwise_conv2d.cc index a6fb9eb4d86d60f2762ea0052e820f6f2e2b79af..112cb03163f384e6b5ea1361b53e512f57f3c999 100644 --- a/mace/ops/depthwise_conv2d.cc +++ b/mace/ops/depthwise_conv2d.cc @@ -5,6 +5,7 @@ #include "mace/ops/depthwise_conv2d.h" namespace mace { +namespace ops { void Register_DepthwiseConv2d(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("DepthwiseConv2d") @@ -26,4 +27,5 @@ void Register_DepthwiseConv2d(OperatorRegistry *op_registry) { DepthwiseConv2dOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/depthwise_conv2d.h b/mace/ops/depthwise_conv2d.h index 0678ba0757d17a50fa1b2ef2cdcc5c4b2635a46d..f7abd6891f2d5dfbc0aefdd4b653b80330853ad5 100644 --- a/mace/ops/depthwise_conv2d.h +++ b/mace/ops/depthwise_conv2d.h @@ -6,6 +6,7 @@ #define MACE_OPS_DEPTHWISE_CONV2D_H_ #include +#include #include "mace/core/operator.h" #include "mace/kernels/conv_2d.h" @@ -13,6 +14,7 @@ #include "mace/ops/conv_pool_2d_base.h" namespace mace { +namespace ops { template class DepthwiseConv2dOp : public ConvPool2dOpBase { @@ -48,6 +50,7 @@ class DepthwiseConv2dOp : public ConvPool2dOpBase { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_DEPTHWISE_CONV2D_H_ diff --git a/mace/ops/depthwise_conv2d_benchmark.cc b/mace/ops/depthwise_conv2d_benchmark.cc index 6ba3b0006307bc879498ce3632ef7c4636b904f5..2d7ec655b8044183fb376b5de77f05eb0185933a 100644 --- a/mace/ops/depthwise_conv2d_benchmark.cc +++ b/mace/ops/depthwise_conv2d_benchmark.cc @@ -10,6 +10,8 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { template static void DepthwiseConv2d(int iters, @@ -121,4 +123,6 @@ BM_DEPTHWISE_CONV_2D(1, 64, 33, 31, 3, 3, 2, SAME, 1); BM_DEPTHWISE_CONV_2D(1, 3, 512, 512, 3, 3, 2, VALID, 1); BM_DEPTHWISE_CONV_2D(1, 3, 512, 512, 3, 3, 2, SAME, 1); +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/depthwise_conv2d_test.cc b/mace/ops/depthwise_conv2d_test.cc index 840d13aa0f3f8c34276759e6af99a3363a7ed985..6c841c752aedcd3c32b53bcdb53c1a4399a70a2d 100644 --- a/mace/ops/depthwise_conv2d_test.cc +++ b/mace/ops/depthwise_conv2d_test.cc @@ -5,9 +5,9 @@ #include "mace/ops/conv_2d.h" #include "mace/ops/ops_test_util.h" -using namespace mace; - -namespace { +namespace mace { +namespace ops { +namespace test { class DepthwiseConv2dOpTest : public OpsTestBase {}; @@ -207,11 +207,10 @@ void TestNxNS12(const index_t height, const index_t width) { testing::internal::LogToStderr(); auto func = [&](int kernel_h, int kernel_w, int stride_h, int stride_w, Padding type) { - srand(time(NULL)); - // generate random input - index_t batch = 1 + rand() % 5; - index_t input_channels = 3 + rand() % 16; + static unsigned int seed = time(NULL); + index_t batch = 1 + rand_r(&seed) % 5; + index_t input_channels = 3 + rand_r(&seed) % 16; index_t multiplier = 1; // Construct graph OpsTestNet net; @@ -316,4 +315,6 @@ TEST_F(DepthwiseConv2dOpTest, OpenCLUnalignedNxNS12Half) { TestNxNS12(107, 113); } -} // namespace +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/eltwise.cc b/mace/ops/eltwise.cc index 88d7d43f0daa8e3434589fd8a5ae6c9673bf91d1..5c49f3563f46dc30e634fc225dca262a32d3d682 100644 --- a/mace/ops/eltwise.cc +++ b/mace/ops/eltwise.cc @@ -5,6 +5,7 @@ #include "mace/ops/eltwise.h" namespace mace { +namespace ops { void Register_Eltwise(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("Eltwise") @@ -26,4 +27,5 @@ void Register_Eltwise(OperatorRegistry *op_registry) { EltwiseOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/eltwise.h b/mace/ops/eltwise.h index 621a8f2b01fa575e4dfb79a4ab347f8455c8083b..f68622e5cd781f8078d0ada568b2e82fb634edfc 100644 --- a/mace/ops/eltwise.h +++ b/mace/ops/eltwise.h @@ -2,13 +2,14 @@ // Copyright (c) 2017 XiaoMi All rights reserved. // -#ifndef MACE_OPS_RESHAPE_H_ -#define MACE_OPS_RESHAPE_H_ +#ifndef MACE_OPS_ELTWISE_H_ +#define MACE_OPS_ELTWISE_H_ #include "mace/core/operator.h" #include "mace/kernels/eltwise.h" namespace mace { +namespace ops { template class EltwiseOp : public Operator { @@ -44,6 +45,7 @@ class EltwiseOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace -#endif // MACE_OPS_RESHAPE_H_ +#endif // MACE_OPS_ELTWISE_H_ diff --git a/mace/ops/eltwise_benchmark.cc b/mace/ops/eltwise_benchmark.cc index 8dcb243ae893d854c16261df22e1bf2c8a6c7ce0..25917890e25ee02c77206d0546f1eb9dc6e42b20 100644 --- a/mace/ops/eltwise_benchmark.cc +++ b/mace/ops/eltwise_benchmark.cc @@ -2,13 +2,17 @@ // Copyright (c) 2017 XiaoMi All rights reserved. // -#include "mace/kernels/eltwise.h" #include + #include "mace/core/operator.h" #include "mace/core/testing/test_benchmark.h" +#include "mace/kernels/eltwise.h" #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void EltwiseBenchmark( int iters, kernels::EltwiseType type, int n, int h, int w, int c) { @@ -81,4 +85,6 @@ BM_ELTWISE(0, 1, 240, 240, 256); BM_ELTWISE(1, 1, 240, 240, 256); BM_ELTWISE(2, 1, 240, 240, 256); +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/eltwise_test.cc b/mace/ops/eltwise_test.cc index ae8cf5f0605413aac6775790dd510ff0d33baca8..28d7384369916794f5b678862f7d9f574b974154 100644 --- a/mace/ops/eltwise_test.cc +++ b/mace/ops/eltwise_test.cc @@ -7,6 +7,8 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { class EltwiseOpTest : public OpsTestBase {}; @@ -170,4 +172,6 @@ TEST_F(EltwiseOpTest, OPENCLRandomHalf) { {13, 32, 32, 64}); } +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/folded_batch_norm.cc b/mace/ops/folded_batch_norm.cc index 5847ab9485f192232b109482a3f5d89e4259db04..10cc39272c814f09e37cee22450ed51259aac710 100644 --- a/mace/ops/folded_batch_norm.cc +++ b/mace/ops/folded_batch_norm.cc @@ -5,6 +5,7 @@ #include "mace/ops/folded_batch_norm.h" namespace mace { +namespace ops { void Register_FoldedBatchNorm(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("FoldedBatchNorm") @@ -26,4 +27,5 @@ void Register_FoldedBatchNorm(OperatorRegistry *op_registry) { FoldedBatchNormOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/folded_batch_norm.h b/mace/ops/folded_batch_norm.h index 28f7f99a8b20e26b553165258885222aca860483..dd2f7b17c87ea58c5956b9ea014dd7f1a09ce964 100644 --- a/mace/ops/folded_batch_norm.h +++ b/mace/ops/folded_batch_norm.h @@ -5,10 +5,13 @@ #ifndef MACE_OPS_FOLDED_BATCH_NORM_H_ #define MACE_OPS_FOLDED_BATCH_NORM_H_ +#include + #include "mace/core/operator.h" #include "mace/kernels/batch_norm.h" namespace mace { +namespace ops { template class FoldedBatchNormOp : public Operator { @@ -48,6 +51,7 @@ class FoldedBatchNormOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_FOLDED_BATCH_NORM_H_ diff --git a/mace/ops/folded_batch_norm_test.cc b/mace/ops/folded_batch_norm_test.cc index 77bf351d7cefd766f3e7e57296631b91f18e2290..416e6ad8c3011007b530c7e6942a74e2ffd1ed2b 100644 --- a/mace/ops/folded_batch_norm_test.cc +++ b/mace/ops/folded_batch_norm_test.cc @@ -6,6 +6,8 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { class FoldedBatchNormOpTest : public OpsTestBase {}; @@ -14,12 +16,12 @@ void CalculateScaleOffset(const std::vector &gamma, const std::vector &mean, const std::vector &var, const float epsilon, - std::vector &scale, - std::vector &offset) { + std::vector *scale, + std::vector *offset) { size_t size = gamma.size(); for (int i = 0; i < size; ++i) { - scale[i] = gamma[i] / std::sqrt(var[i] + epsilon); - offset[i] = offset[i] - mean[i] * scale[i]; + (*scale)[i] = gamma[i] / std::sqrt(var[i] + epsilon); + (*offset)[i] = (*offset)[i] - mean[i] * (*scale)[i]; } } @@ -32,7 +34,7 @@ void Simple() { {5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15}); std::vector scale(1); std::vector offset(1); - CalculateScaleOffset({4.0f}, {2.0}, {10}, {11.67f}, 1e-3, scale, offset); + CalculateScaleOffset({4.0f}, {2.0}, {10}, {11.67f}, 1e-3, &scale, &offset); net.AddInputFromArray("Scale", {1}, scale); net.AddInputFromArray("Offset", {1}, offset); @@ -172,11 +174,10 @@ width}); */ TEST_F(FoldedBatchNormOpTest, SimpleRandomOPENCL) { - srand(time(NULL)); - // generate random input - index_t batch = 1 + rand() % 10; - index_t channels = 3 + rand() % 50; + static unsigned int seed = time(NULL); + index_t batch = 1 + rand_r(&seed) % 10; + index_t channels = 3 + rand_r(&seed) % 50; index_t height = 64; index_t width = 64; @@ -227,11 +228,10 @@ TEST_F(FoldedBatchNormOpTest, SimpleRandomOPENCL) { } TEST_F(FoldedBatchNormOpTest, SimpleRandomHalfOPENCL) { - srand(time(NULL)); - // generate random input - index_t batch = 1 + rand() % 10; - index_t channels = 3 + rand() % 50; + static unsigned int seed = time(NULL); + index_t batch = 1 + rand_r(&seed) % 10; + index_t channels = 3 + rand_r(&seed) % 50; index_t height = 64; index_t width = 64; @@ -283,11 +283,10 @@ TEST_F(FoldedBatchNormOpTest, SimpleRandomHalfOPENCL) { } TEST_F(FoldedBatchNormOpTest, ComplexRandomOPENCL) { - srand(time(NULL)); - // generate random input - index_t batch = 1 + rand() % 10; - index_t channels = 3 + rand() % 50; + static unsigned int seed = time(NULL); + index_t batch = 1 + rand_r(&seed) % 10; + index_t channels = 3 + rand_r(&seed) % 50; index_t height = 103; index_t width = 113; @@ -337,11 +336,10 @@ TEST_F(FoldedBatchNormOpTest, ComplexRandomOPENCL) { } TEST_F(FoldedBatchNormOpTest, ComplexRandomHalfOPENCL) { - srand(time(NULL)); - // generate random input - index_t batch = 1 + rand() % 10; - index_t channels = 3 + rand() % 50; + static unsigned int seed = time(NULL); + index_t batch = 1 + rand_r(&seed) % 10; + index_t channels = 3 + rand_r(&seed) % 50; index_t height = 103; index_t width = 113; @@ -390,4 +388,7 @@ TEST_F(FoldedBatchNormOpTest, ComplexRandomHalfOPENCL) { kernels::BufferType::IN_OUT_CHANNEL); ExpectTensorNear(expected, *net.GetOutput("OPENCLOutput"), 0.5); } -} + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/fully_connected.cc b/mace/ops/fully_connected.cc index 7f9df74c3389be777dea74d2bd570e9b61c0f4cc..dd4c5b87228d8e1c0aacbf2b93e5cb1a03e3aa76 100644 --- a/mace/ops/fully_connected.cc +++ b/mace/ops/fully_connected.cc @@ -5,6 +5,7 @@ #include "mace/ops/fully_connected.h" namespace mace { +namespace ops { void Register_FullyConnected(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("FC") @@ -26,4 +27,5 @@ void Register_FullyConnected(OperatorRegistry *op_registry) { FullyConnectedOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/fully_connected.h b/mace/ops/fully_connected.h index 282804a5793a4b8c5bb6bab26b2389e41f0f5170..5ac305ff9abb5ecc570f50375d8c4335f72e2fdd 100644 --- a/mace/ops/fully_connected.h +++ b/mace/ops/fully_connected.h @@ -5,10 +5,13 @@ #ifndef MACE_OPS_FULLY_CONNECTED_H_ #define MACE_OPS_FULLY_CONNECTED_H_ +#include + #include "mace/core/operator.h" #include "mace/kernels/fully_connected.h" namespace mace { +namespace ops { template class FullyConnectedOp : public Operator { @@ -46,6 +49,7 @@ class FullyConnectedOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_FULLY_CONNECTED_H_ diff --git a/mace/ops/fully_connected_benchmark.cc b/mace/ops/fully_connected_benchmark.cc index 5078b1240a10900d789078b8c368781be64ae81b..da9749c40f45b17a46d50c5ddee929b0efdd46d7 100644 --- a/mace/ops/fully_connected_benchmark.cc +++ b/mace/ops/fully_connected_benchmark.cc @@ -3,11 +3,15 @@ // #include + #include "mace/core/operator.h" #include "mace/core/testing/test_benchmark.h" #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void FCBenchmark( int iters, int batch, int height, int width, int channel, int out_channel) { @@ -83,4 +87,7 @@ BM_FC(1, 16, 16, 32, 32); BM_FC(1, 8, 8, 32, 1000); BM_FC(1, 2, 2, 512, 2); BM_FC(1, 7, 7, 512, 4096); + +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/fully_connected_test.cc b/mace/ops/fully_connected_test.cc index c50e6952b2e57c47c63a064c85294695081b5cd3..09a0b04f341a4fcef9e181b97fa375bfa6cf1157 100644 --- a/mace/ops/fully_connected_test.cc +++ b/mace/ops/fully_connected_test.cc @@ -3,10 +3,13 @@ // #include + #include "mace/core/operator.h" #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { class FullyConnectedOpTest : public OpsTestBase {}; @@ -263,4 +266,6 @@ TEST_F(FullyConnectedOpTest, OPENCLHalfWidthFormatAligned) { TestWXFormat(1, 16, 32, 32, 32); } -} +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/fused_conv_2d.cc b/mace/ops/fused_conv_2d.cc index 4a0245f5e03e252775b1f17cea5a6823ecdaa56e..d4b5de4f809c7398adc6622ae9a11ee7aa911524 100644 --- a/mace/ops/fused_conv_2d.cc +++ b/mace/ops/fused_conv_2d.cc @@ -5,6 +5,7 @@ #include "mace/ops/fused_conv_2d.h" namespace mace { +namespace ops { void Register_FusedConv2D(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("FusedConv2D") @@ -26,4 +27,5 @@ void Register_FusedConv2D(OperatorRegistry *op_registry) { FusedConv2dOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/fused_conv_2d.h b/mace/ops/fused_conv_2d.h index 0184f92f80700fd686e20a8c5918c3ce3c6ecb28..db9c6e3a48920c1346b12ac2943d42f940fb6c8f 100644 --- a/mace/ops/fused_conv_2d.h +++ b/mace/ops/fused_conv_2d.h @@ -6,12 +6,14 @@ #define MACE_OPS_FUSED_CONV_2D_H_ #include +#include #include "mace/core/operator.h" #include "mace/kernels/conv_2d.h" #include "mace/ops/conv_pool_2d_base.h" namespace mace { +namespace ops { template class FusedConv2dOp : public ConvPool2dOpBase { @@ -46,6 +48,7 @@ class FusedConv2dOp : public ConvPool2dOpBase { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_FUSED_CONV_2D_H_ diff --git a/mace/ops/fused_conv_2d_test.cc b/mace/ops/fused_conv_2d_test.cc index ad64be0d973c8d4a175341119282aab3f0e34e21..a893e0e7ebf408054afb575d621fe528cc40295a 100644 --- a/mace/ops/fused_conv_2d_test.cc +++ b/mace/ops/fused_conv_2d_test.cc @@ -2,10 +2,14 @@ // Copyright (c) 2017 XiaoMi All rights reserved. // +#include + #include "mace/ops/fused_conv_2d.h" #include "mace/ops/ops_test_util.h" -using namespace mace; +namespace mace { +namespace ops { +namespace test { class FusedConv2dOpTest : public OpsTestBase {}; @@ -274,14 +278,13 @@ static void TestComplexConvNxNS12(const std::vector &shape) { testing::internal::LogToStderr(); auto func = [&](int kernel_h, int kernel_w, int stride_h, int stride_w, Padding type) { - srand(time(NULL)); - // generate random input - index_t batch = 3 + (rand() % 10); + static unsigned int seed = time(NULL); + index_t batch = 3 + (rand_r(&seed) % 10); index_t height = shape[0]; index_t width = shape[1]; - index_t input_channels = shape[2] + (rand() % 10); - index_t output_channels = shape[3] + (rand() % 10); + index_t input_channels = shape[2] + (rand_r(&seed) % 10); + index_t output_channels = shape[3] + (rand_r(&seed) % 10); // Construct graph OpsTestNet net; OpDefBuilder("FusedConv2D", "FusedConv2dTest") @@ -350,14 +353,13 @@ static void TestHalfComplexConvNxNS12(const std::vector &shape) { testing::internal::LogToStderr(); auto func = [&](int kernel_h, int kernel_w, int stride_h, int stride_w, Padding type) { - srand(time(NULL)); - // generate random input - index_t batch = 3 + (rand() % 10); + static unsigned int seed = time(NULL); + index_t batch = 3 + (rand_r(&seed) % 10); index_t height = shape[0]; index_t width = shape[1]; - index_t input_channels = shape[2] + (rand() % 10); - index_t output_channels = shape[3] + (rand() % 10); + index_t input_channels = shape[2] + (rand_r(&seed) % 10); + index_t output_channels = shape[3] + (rand_r(&seed) % 10); // Construct graph OpsTestNet net; OpDefBuilder("FusedConv2D", "FusedConv2dTest") @@ -676,3 +678,7 @@ TEST_F(FusedConv2dOpTest, OPENCL15X15AtrousConvD4) { TestGeneralHalfAtrousConv({63, 71}, {15, 15, 16, 16}, {2, 2}); } + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/global_avg_pooling.cc b/mace/ops/global_avg_pooling.cc index 65d34b49fff906c8159218a363afdcfcb70e67d4..5421f1ce0756f13e470645ed9a12242a6fe7612e 100644 --- a/mace/ops/global_avg_pooling.cc +++ b/mace/ops/global_avg_pooling.cc @@ -5,6 +5,7 @@ #include "mace/ops/global_avg_pooling.h" namespace mace { +namespace ops { void Register_GlobalAvgPooling(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("GlobalAvgPooling") @@ -14,4 +15,5 @@ void Register_GlobalAvgPooling(OperatorRegistry *op_registry) { GlobalAvgPoolingOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/global_avg_pooling.h b/mace/ops/global_avg_pooling.h index dc1cda9e8bfb1dc0a1a14729f6bb1899b3072641..59ab7452dc91e7c80ffeced960fbace9ffd5daef 100644 --- a/mace/ops/global_avg_pooling.h +++ b/mace/ops/global_avg_pooling.h @@ -5,10 +5,13 @@ #ifndef MACE_OPS_GLOBAL_AVG_POOLING_H_ #define MACE_OPS_GLOBAL_AVG_POOLING_H_ +#include + #include "mace/core/operator.h" #include "mace/kernels/global_avg_pooling.h" namespace mace { +namespace ops { template class GlobalAvgPoolingOp : public Operator { @@ -38,6 +41,7 @@ class GlobalAvgPoolingOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_GLOBAL_AVG_POOLING_H_ diff --git a/mace/ops/global_avg_pooling_benchmark.cc b/mace/ops/global_avg_pooling_benchmark.cc index 1ea07c4b0b58c202cac9b0a12057b9473b8c1702..0e8126bc3704e728dfd935d38c59ed1ddcf3c1b2 100644 --- a/mace/ops/global_avg_pooling_benchmark.cc +++ b/mace/ops/global_avg_pooling_benchmark.cc @@ -7,8 +7,9 @@ #include "mace/core/testing/test_benchmark.h" #include "mace/ops/ops_test_util.h" -using namespace mace; -using namespace mace::kernels; +namespace mace { +namespace ops { +namespace test { template static void GlobalAvgPooling( @@ -53,3 +54,7 @@ static void GlobalAvgPooling( BM_GLOBAL_AVG_POOLING(1, 3, 7, 7); BM_GLOBAL_AVG_POOLING(1, 3, 64, 64); BM_GLOBAL_AVG_POOLING(1, 3, 256, 256); + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/global_avg_pooling_test.cc b/mace/ops/global_avg_pooling_test.cc index a00ffc36d542562bf1bf4365f67977fda4fdbc38..8b82f7ab4e3c9e8a98d0cf5549028a3a4d691a9f 100644 --- a/mace/ops/global_avg_pooling_test.cc +++ b/mace/ops/global_avg_pooling_test.cc @@ -4,7 +4,9 @@ #include "mace/core/operator.h" #include "mace/ops/ops_test_util.h" -using namespace mace; +namespace mace { +namespace ops { +namespace test { class GlobalAvgPoolingOpTest : public OpsTestBase {}; @@ -31,3 +33,7 @@ TEST_F(GlobalAvgPoolingOpTest, 3x7x7_CPU) { ExpectTensorNear(*expected, *net.GetOutput("Output"), 0.001); } + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/image_to_buffer.cc b/mace/ops/image_to_buffer.cc index d5031539d83ab330eaf0410e68063a16b4892b40..6ea1d8db5fc61452cdea89d776c423d99a222223 100644 --- a/mace/ops/image_to_buffer.cc +++ b/mace/ops/image_to_buffer.cc @@ -5,6 +5,7 @@ #include "mace/ops/image_to_buffer.h" namespace mace { +namespace ops { void Register_ImageToBuffer(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("ImageToBuffer") @@ -20,4 +21,5 @@ void Register_ImageToBuffer(OperatorRegistry *op_registry) { ImageToBufferOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/image_to_buffer.h b/mace/ops/image_to_buffer.h index 22169b4e0e7379385fc750480caf5b261dd12336..b786d3092faeb3c989bc9ad9870c063d57faaa37 100644 --- a/mace/ops/image_to_buffer.h +++ b/mace/ops/image_to_buffer.h @@ -9,6 +9,7 @@ #include "mace/kernels/buffer_to_image.h" namespace mace { +namespace ops { template class ImageToBufferOp : public Operator { @@ -35,5 +36,7 @@ class ImageToBufferOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace + #endif // MACE_OPS_IMAGE_TO_BUFFER_H_ diff --git a/mace/ops/matmul.cc b/mace/ops/matmul.cc index e8a178cb053a92cf6237d274d8206f7d941c9c2f..3ebe99a93acd1dafe8b90cdf468affdc60f4d880 100644 --- a/mace/ops/matmul.cc +++ b/mace/ops/matmul.cc @@ -5,6 +5,7 @@ #include "mace/ops/matmul.h" namespace mace { +namespace ops { void Register_MatMul(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("MatMul") @@ -26,4 +27,5 @@ void Register_MatMul(OperatorRegistry *op_registry) { MatMulOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/matmul.h b/mace/ops/matmul.h index b45ae35aa83f7f94f426d245fdc21bb47959607f..b8bca6a247e04885e2dc73015c27262cb8285542 100644 --- a/mace/ops/matmul.h +++ b/mace/ops/matmul.h @@ -9,6 +9,7 @@ #include "mace/kernels/matmul.h" namespace mace { +namespace ops { template class MatMulOp : public Operator { @@ -35,6 +36,7 @@ class MatMulOp : public Operator { kernels::MatMulFunctor functor_; }; +} // namespace ops } // namespace mace #endif // MACE_OPS_MATMUL_H_ diff --git a/mace/ops/matmul_benchmark.cc b/mace/ops/matmul_benchmark.cc index c83b872afd56e5652b4abe39974db182f46fcd20..5c136f57206fcb2b7a915bf08886a6e4469428c9 100644 --- a/mace/ops/matmul_benchmark.cc +++ b/mace/ops/matmul_benchmark.cc @@ -3,11 +3,15 @@ // #include + #include "mace/core/operator.h" #include "mace/core/testing/test_benchmark.h" #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void MatMulBenchmark( int iters, int batch, int height, int channels, int out_width) { @@ -71,4 +75,7 @@ BM_MATMUL(16, 32, 128, 3969); BM_MATMUL(16, 128, 128, 49); BM_MATMUL(16, 128, 128, 961); BM_MATMUL(16, 128, 128, 3969); + +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/matmul_test.cc b/mace/ops/matmul_test.cc index d8b80eade81343e571a2e233d0e81fb232138652..237b8f134bcd3b70258e419d007805ac8f23310d 100644 --- a/mace/ops/matmul_test.cc +++ b/mace/ops/matmul_test.cc @@ -3,10 +3,13 @@ // #include + #include "mace/core/operator.h" #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { class MatMulOpTest : public OpsTestBase {}; @@ -170,4 +173,7 @@ TEST_F(MatMulOpTest, OPENCLHalfUnAlignedWithBatch) { Complex(16, 32, 64, 64); Complex(31, 31, 61, 67); } -} + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/ops_test_util.h b/mace/ops/ops_test_util.h index 3003fffe4c185b7200c331d064f85f88da5bc004..b782115b24b33df6ccf540cc5a36f5edbf431c1b 100644 --- a/mace/ops/ops_test_util.h +++ b/mace/ops/ops_test_util.h @@ -2,10 +2,14 @@ // Copyright (c) 2017 XiaoMi All rights reserved. // -#ifndef MACE_OPS_TEST_UTIL_H_ -#define MACE_OPS_TEST_UTIL_H_ +#ifndef MACE_OPS_OPS_TEST_UTIL_H_ +#define MACE_OPS_OPS_TEST_UTIL_H_ #include +#include +#include +#include +#include #include "gtest/gtest.h" #include "mace/core/net.h" @@ -16,6 +20,8 @@ #include "mace/utils/utils.h" namespace mace { +namespace ops { +namespace test { class OpDefBuilder { public: @@ -95,7 +101,7 @@ class OpDefBuilder { class OpsTestNet { public: - OpsTestNet() : op_registry_(new OperatorRegistry()){}; + OpsTestNet() : op_registry_(new OperatorRegistry()) {} template void AddInputFromArray(const std::string &name, @@ -412,6 +418,8 @@ void ImageToBuffer(OpsTestNet &net, net.Sync(); } +} // namespace test +} // namespace ops } // namespace mace -#endif // MACE_OPS_TEST_UTIL_H_ +#endif // MACE_OPS_OPS_TEST_UTIL_H_ diff --git a/mace/ops/pooling.cc b/mace/ops/pooling.cc index f761f5459ae260ba2352e8a759f002b35aa1df57..166a71ade097b34249b865b9d8ded158f415a22a 100644 --- a/mace/ops/pooling.cc +++ b/mace/ops/pooling.cc @@ -5,6 +5,7 @@ #include "mace/ops/pooling.h" namespace mace { +namespace ops { void Register_Pooling(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("Pooling") @@ -30,4 +31,5 @@ void Register_Pooling(OperatorRegistry *op_registry) { PoolingOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/pooling.h b/mace/ops/pooling.h index b88093aba20b60e2190c88548a8b5da4817ecf11..1033ad6ec32eac56def19a7286dcf29f8979a7bb 100644 --- a/mace/ops/pooling.h +++ b/mace/ops/pooling.h @@ -5,11 +5,14 @@ #ifndef MACE_OPS_POOLING_H_ #define MACE_OPS_POOLING_H_ +#include + #include "mace/core/operator.h" #include "mace/kernels/pooling.h" #include "mace/ops/conv_pool_2d_base.h" namespace mace { +namespace ops { template class PoolingOp : public ConvPool2dOpBase { @@ -25,7 +28,7 @@ class PoolingOp : public ConvPool2dOpBase { this->strides_.data(), this->padding_type_, this->paddings_, - this->dilations_.data()){}; + this->dilations_.data()) {} bool Run(StatsFuture *future) override { const Tensor *input = this->Input(INPUT); @@ -44,6 +47,7 @@ class PoolingOp : public ConvPool2dOpBase { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_POOLING_H_ diff --git a/mace/ops/pooling_benchmark.cc b/mace/ops/pooling_benchmark.cc index dae7e1af0e749bf4b82a71d706490a1867e9033d..af6688abe1c41cb2dc80b05040b1cb7c2f47cbb5 100644 --- a/mace/ops/pooling_benchmark.cc +++ b/mace/ops/pooling_benchmark.cc @@ -8,8 +8,9 @@ #include "mace/kernels/conv_pool_2d_util.h" #include "mace/ops/ops_test_util.h" -using namespace mace; -using namespace mace::kernels; +namespace mace { +namespace ops { +namespace test { template static void Pooling(int iters, @@ -70,3 +71,7 @@ BM_POOLING(1, 3, 129, 129, 2, 2, SAME, MAX); BM_POOLING(1, 3, 257, 257, 2, 2, SAME, MAX); BM_POOLING(1, 3, 513, 513, 2, 2, SAME, MAX); BM_POOLING(1, 3, 1025, 1025, 2, 2, SAME, MAX); + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/pooling_test.cc b/mace/ops/pooling_test.cc index 8bababc8caee025a39973bad2b2bc7321896d1de..e57e57163cd8af7d59dd043c146c9bdc0cc6c33d 100644 --- a/mace/ops/pooling_test.cc +++ b/mace/ops/pooling_test.cc @@ -9,7 +9,9 @@ #include "mace/ops/conv_pool_2d_base.h" #include "mace/ops/ops_test_util.h" -using namespace mace; +namespace mace { +namespace ops { +namespace test { class PoolingOpTest : public OpsTestBase {}; @@ -393,3 +395,7 @@ TEST_F(PoolingOpTest, OPENCLUnAlignedLargeKernelAvgPooling) { AvgPoolingTest({3, 31, 37, 128}, {8, 8}, {8, 8}, Padding::SAME); } + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/reshape.cc b/mace/ops/reshape.cc index df528603537ab05087df3b7713180afb660eeed0..26dff665eeb040893ced6832bfa4b4312b6a4482 100644 --- a/mace/ops/reshape.cc +++ b/mace/ops/reshape.cc @@ -5,6 +5,7 @@ #include "mace/ops/reshape.h" namespace mace { +namespace ops { void Register_Reshape(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("Reshape") @@ -14,4 +15,5 @@ void Register_Reshape(OperatorRegistry *op_registry) { ReshapeOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/reshape.h b/mace/ops/reshape.h index a4aec7155115ee9d1538818082dc623e418731af..e7f1a80ad5f315d3e873e13ba1c0d9e075fc9234 100644 --- a/mace/ops/reshape.h +++ b/mace/ops/reshape.h @@ -5,10 +5,13 @@ #ifndef MACE_OPS_RESHAPE_H_ #define MACE_OPS_RESHAPE_H_ +#include + #include "mace/core/operator.h" #include "mace/kernels/reshape.h" namespace mace { +namespace ops { template class ReshapeOp : public Operator { @@ -61,6 +64,7 @@ class ReshapeOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_RESHAPE_H_ diff --git a/mace/ops/reshape_test.cc b/mace/ops/reshape_test.cc index 851f33ccd493244ace99f57bbd129d04a16bce58..e8c363a61e255f28657b9a7cf0f4955e4dcd279b 100644 --- a/mace/ops/reshape_test.cc +++ b/mace/ops/reshape_test.cc @@ -6,7 +6,9 @@ #include "mace/core/operator.h" #include "mace/ops/ops_test_util.h" -using namespace mace; +namespace mace { +namespace ops { +namespace test { class ReshapeTest : public OpsTestBase {}; @@ -53,3 +55,7 @@ TEST_F(ReshapeTest, Complex) { TestReshape({1, 2, 3, 4}, {-1, 1}, {24, 1}); TestReshape({1, 2, 3, 4}, {1, 3, 8}, {1, 3, 8}); } + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/resize_bilinear.cc b/mace/ops/resize_bilinear.cc index d304c24cd4288821732b32ce547a01724efadc13..a7449a3c6a97ce8dc5fcff666507a33d16e92a4b 100644 --- a/mace/ops/resize_bilinear.cc +++ b/mace/ops/resize_bilinear.cc @@ -5,6 +5,7 @@ #include "mace/ops/resize_bilinear.h" namespace mace { +namespace ops { void Register_ResizeBilinear(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("ResizeBilinear") @@ -26,4 +27,5 @@ void Register_ResizeBilinear(OperatorRegistry *op_registry) { ResizeBilinearOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/resize_bilinear.h b/mace/ops/resize_bilinear.h index bea852b529bb068cd0cee0e731fed29770aed157..1fc727484920c4092b7e12ca8a8031c562a366a4 100644 --- a/mace/ops/resize_bilinear.h +++ b/mace/ops/resize_bilinear.h @@ -2,13 +2,14 @@ // Copyright (c) 2017 XiaoMi All rights reserved. // -#ifndef MACE_RESIZE_BILINEAR_H -#define MACE_RESIZE_BILINEAR_H +#ifndef MACE_OPS_RESIZE_BILINEAR_H_ +#define MACE_OPS_RESIZE_BILINEAR_H_ #include "mace/core/operator.h" #include "mace/kernels/resize_bilinear.h" namespace mace { +namespace ops { template class ResizeBilinearOp : public Operator { @@ -34,6 +35,7 @@ class ResizeBilinearOp : public Operator { kernels::ResizeBilinearFunctor functor_; }; +} // namespace ops } // namespace mace -#endif // MACE_RESIZE_BILINEAR_H +#endif // MACE_OPS_RESIZE_BILINEAR_H_ diff --git a/mace/ops/resize_bilinear_benchmark.cc b/mace/ops/resize_bilinear_benchmark.cc index 9daee298782f9034fa74c02844c17b2bc257159f..6e19a000ebe67a8a4c6a1f6070fec112b5e92236 100644 --- a/mace/ops/resize_bilinear_benchmark.cc +++ b/mace/ops/resize_bilinear_benchmark.cc @@ -8,6 +8,9 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void ResizeBilinearBenchmark(int iters, int batch, @@ -84,4 +87,6 @@ BM_RESIZE_BILINEAR(1, 128, 240, 240, 480, 480); BM_RESIZE_BILINEAR(1, 3, 4032, 3016, 480, 480); BM_RESIZE_BILINEAR(1, 3, 480, 480, 4032, 3016); +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/resize_bilinear_test.cc b/mace/ops/resize_bilinear_test.cc index 1b3bf6181773b4983cba31fa67bff243cecf1b39..9e4034e239171d4b5709dbf0b017646f26c2e1b2 100644 --- a/mace/ops/resize_bilinear_test.cc +++ b/mace/ops/resize_bilinear_test.cc @@ -2,11 +2,15 @@ // Copyright (c) 2017 XiaoMi All rights reserved. // -#include "mace/ops/resize_bilinear.h" +#include + #include "mace/core/operator.h" +#include "mace/ops/resize_bilinear.h" #include "mace/ops/ops_test_util.h" -using namespace mace; +namespace mace { +namespace ops { +namespace test { class ResizeBilinearTest : public OpsTestBase {}; @@ -61,17 +65,16 @@ TEST_F(ResizeBilinearTest, ResizeBilinearWAlignCorners) { template void TestRandomResizeBilinear() { - srand(time(nullptr)); testing::internal::LogToStderr(); - + static unsigned int seed = time(NULL); for (int round = 0; round < 10; ++round) { - int batch = 1 + rand() % 5; - int channels = 1 + rand() % 100; - int height = 1 + rand() % 100; - int width = 1 + rand() % 100; - int in_height = 1 + rand() % 100; - int in_width = 1 + rand() % 100; - int align_corners = rand() % 1; + int batch = 1 + rand_r(&seed) % 5; + int channels = 1 + rand_r(&seed) % 100; + int height = 1 + rand_r(&seed) % 100; + int width = 1 + rand_r(&seed) % 100; + int in_height = 1 + rand_r(&seed) % 100; + int in_width = 1 + rand_r(&seed) % 100; + int align_corners = rand_r(&seed) % 1; // Construct graph OpsTestNet net; @@ -106,7 +109,7 @@ void TestRandomResizeBilinear() { ImageToBuffer(net, "OutputImage", "DeviceOutput", kernels::BufferType::IN_OUT_CHANNEL); } else { - // TODO support NEON + // TODO(someone): support NEON } // Check ExpectTensorNear(expected, *net.GetOutput("DeviceOutput"), 0.001); @@ -122,3 +125,7 @@ TEST_F(ResizeBilinearTest, NEONRandomResizeBilinear) { TEST_F(ResizeBilinearTest, OPENCLRandomResizeBilinear) { TestRandomResizeBilinear(); } + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/slice.cc b/mace/ops/slice.cc index 6de3da403fca90031c76597c31126f742bf8ba5f..d482b0288bbcaaa8d7144ad98de10b50d4c7db40 100644 --- a/mace/ops/slice.cc +++ b/mace/ops/slice.cc @@ -5,6 +5,7 @@ #include "mace/ops/slice.h" namespace mace { +namespace ops { void Register_Slice(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("Slice") @@ -25,4 +26,5 @@ void Register_Slice(OperatorRegistry *op_registry) { SliceOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/slice.h b/mace/ops/slice.h index 41106a6339bc21ff9ce4b176bb02cdb12b1299c8..466914f3580f7de9c58b5a6ff96ee9e351b58f55 100644 --- a/mace/ops/slice.h +++ b/mace/ops/slice.h @@ -5,9 +5,13 @@ #ifndef MACE_OPS_SLICE_H_ #define MACE_OPS_SLICE_H_ +#include + #include "mace/core/operator.h" #include "mace/kernels/slice.h" + namespace mace { +namespace ops { template class SliceOp : public Operator { @@ -32,6 +36,7 @@ class SliceOp : public Operator { OP_INPUT_TAGS(INPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_SLICE_H_ diff --git a/mace/ops/slice_benchmark.cc b/mace/ops/slice_benchmark.cc index 5273f592c71084434b265affd4ef5760cf6aef37..a0aeb90a191384976914bed7052e53c200c01b34 100644 --- a/mace/ops/slice_benchmark.cc +++ b/mace/ops/slice_benchmark.cc @@ -7,6 +7,9 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void BMSliceHelper(int iters, const std::vector &input_shape, @@ -75,5 +78,6 @@ BM_SLICE(1, 32, 32, 256, 2); BM_SLICE(1, 128, 128, 32, 2); BM_SLICE(1, 128, 128, 128, 2); - +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/slice_test.cc b/mace/ops/slice_test.cc index ff65fffa78ff2e8507944e53e100fbc6b31df506..7f94aa55eb6deddbb2a058588abd47a0378eaf69 100644 --- a/mace/ops/slice_test.cc +++ b/mace/ops/slice_test.cc @@ -2,22 +2,26 @@ // Copyright (c) 2017 XiaoMi All rights reserved. // +#include + +#include "gmock/gmock.h" #include "mace/ops/slice.h" #include "mace/ops/ops_test_util.h" -#include "gmock/gmock.h" -using namespace mace; +namespace mace { +namespace ops { +namespace test { class SliceOpTest : public OpsTestBase {}; template void RandomTest(const int num_outputs) { - srand(time(nullptr)); - const index_t output_channels = 4 * (1 + rand() % 10); + static unsigned int seed = time(NULL); + const index_t output_channels = 4 * (1 + rand_r(&seed) % 10); const index_t input_channels = num_outputs * output_channels; - const index_t batch = 3 + (rand() % 10); - const index_t height = 13 + (rand() % 10); - const index_t width = 17 + (rand() % 10); + const index_t batch = 3 + (rand_r(&seed) % 10); + const index_t height = 13 + (rand_r(&seed) % 10); + const index_t width = 17 + (rand_r(&seed) % 10); // Construct graph OpsTestNet net; @@ -47,7 +51,6 @@ void RandomTest(const int num_outputs) { builder = builder.Output(MakeString("Output", i)); } builder.Finalize(net.NewOperatorDef()); - } // Run @@ -97,3 +100,7 @@ TEST_F(SliceOpTest, OPENCLHalf) { RandomTest(4); RandomTest(11); } + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/softmax.cc b/mace/ops/softmax.cc index 7b68e76241e9df00d3f1bf048ee7a5079ebed29d..6b8ead8164736f59a59b6079992c7bbd28a8b1b8 100644 --- a/mace/ops/softmax.cc +++ b/mace/ops/softmax.cc @@ -5,6 +5,7 @@ #include "mace/ops/softmax.h" namespace mace { +namespace ops { void Register_Softmax(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("Softmax") @@ -26,4 +27,5 @@ void Register_Softmax(OperatorRegistry *op_registry) { SoftmaxOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/softmax.h b/mace/ops/softmax.h index 3eebabe03394588b4042008c0231b732f6949aa9..0aedaa3cadf155b3dffe99576007d56f5c2cd6c7 100644 --- a/mace/ops/softmax.h +++ b/mace/ops/softmax.h @@ -2,13 +2,14 @@ // Copyright (c) 2017 XiaoMi All rights reserved. // -#ifndef MACE_SOFTMAX_H_ -#define MACE_SOFTMAX_H_ +#ifndef MACE_OPS_SOFTMAX_H_ +#define MACE_OPS_SOFTMAX_H_ #include "mace/core/operator.h" #include "mace/kernels/softmax.h" namespace mace { +namespace ops { template class SoftmaxOp : public Operator { @@ -34,6 +35,7 @@ class SoftmaxOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace -#endif // MACE_SOFTMAX_H_ +#endif // MACE_OPS_SOFTMAX_H_ diff --git a/mace/ops/softmax_benchmark.cc b/mace/ops/softmax_benchmark.cc index 4f2e8ce8cdf4e483189cc78065d10df6221abd07..bd40f4f77da2e0d98cbdb062de83bc4624047ccf 100644 --- a/mace/ops/softmax_benchmark.cc +++ b/mace/ops/softmax_benchmark.cc @@ -3,11 +3,15 @@ // #include + #include "mace/core/operator.h" #include "mace/core/testing/test_benchmark.h" #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void SoftmaxBenchmark( int iters, int batch, int channels, int height, int width) { @@ -66,4 +70,7 @@ BM_SOFTMAX(1, 3, 512, 512); BM_SOFTMAX(1, 4, 512, 512); BM_SOFTMAX(1, 10, 256, 256); BM_SOFTMAX(1, 1024, 7, 7); + +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/softmax_test.cc b/mace/ops/softmax_test.cc index 68c4e4e60109bba09f0282454b4de63403834a31..b53b94651e87e9f2a94395ebd780c07c446b76eb 100644 --- a/mace/ops/softmax_test.cc +++ b/mace/ops/softmax_test.cc @@ -6,6 +6,8 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { class SoftmaxOpTest : public OpsTestBase {}; @@ -102,4 +104,6 @@ TEST_F(SoftmaxOpTest, OPENCLUnAligned) { Complex({5, 211, 107, 1}); } +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/space_to_batch.cc b/mace/ops/space_to_batch.cc index 89957f67bd838f910535a5bfceb64d2976c8876a..009f4abe37589af4d3ac5f9889c5652086d3b02f 100644 --- a/mace/ops/space_to_batch.cc +++ b/mace/ops/space_to_batch.cc @@ -5,6 +5,7 @@ #include "mace/ops/space_to_batch.h" namespace mace { +namespace ops { void Register_SpaceToBatchND(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("SpaceToBatchND") @@ -19,4 +20,5 @@ void Register_SpaceToBatchND(OperatorRegistry *op_registry) { SpaceToBatchNDOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/space_to_batch.h b/mace/ops/space_to_batch.h index b25c589505afb1668d5e37869e9f667744792f86..dd051fa92ffc56602fb9e27c9f175065cff1a2fe 100644 --- a/mace/ops/space_to_batch.h +++ b/mace/ops/space_to_batch.h @@ -6,11 +6,13 @@ #define MACE_OPS_SPACE_TO_BATCH_H_ #include +#include #include "mace/core/operator.h" #include "mace/kernels/space_to_batch.h" namespace mace { +namespace ops { template class SpaceToBatchNDOp : public Operator { @@ -71,6 +73,7 @@ class SpaceToBatchNDOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_SPACE_TO_BATCH_H_ diff --git a/mace/ops/space_to_batch_benchmark.cc b/mace/ops/space_to_batch_benchmark.cc index db72ce54ff6fc5d0a5d631bae9d9b5910228d88c..f00409b5497df8ae3acc4ec6c0c1aad5a45532b3 100644 --- a/mace/ops/space_to_batch_benchmark.cc +++ b/mace/ops/space_to_batch_benchmark.cc @@ -7,6 +7,9 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void BMSpaceToBatch( int iters, int batch, int height, int width, int channels, int shape) { @@ -55,4 +58,7 @@ static void BMSpaceToBatch( BM_SPACE_TO_BATCH(128, 16, 16, 128, 2); BM_SPACE_TO_BATCH(1, 256, 256, 32, 2); BM_SPACE_TO_BATCH(1, 256, 256, 32, 4); + +} // namespace test +} // namespace ops } // namespace mace diff --git a/mace/ops/space_to_batch_test.cc b/mace/ops/space_to_batch_test.cc index b9cb14f602a504b2434f9123b0ad69c288545f67..588483b58f031d85f3aa9a61fd55e3ceaa8f3672 100644 --- a/mace/ops/space_to_batch_test.cc +++ b/mace/ops/space_to_batch_test.cc @@ -3,10 +3,13 @@ // #include + #include "gtest/gtest.h" #include "mace/ops/ops_test_util.h" -using namespace mace; +namespace mace { +namespace ops { +namespace test { template void RunSpaceToBatch(const std::vector &input_shape, @@ -216,3 +219,7 @@ TEST(SpaceToBatchTest, MultiBatchAndChannelData) { // {2, 2, 2, 2}, // space_tensor.get()); //} + +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/winograd_convolution_test.cc b/mace/ops/winograd_convolution_test.cc index 41e8478abe6c7de1a6db1863a78e2cb709517e13..6c96f0cc18038fb9b339a601e1c32c042d43cf7d 100644 --- a/mace/ops/winograd_convolution_test.cc +++ b/mace/ops/winograd_convolution_test.cc @@ -3,11 +3,14 @@ // #include + #include "mace/core/operator.h" #include "mace/kernels/conv_pool_2d_util.h" #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { class WinogradConvlutionTest : public OpsTestBase {}; @@ -39,7 +42,7 @@ void WinogradConvolution(const index_t batch, const index_t in_channels, const index_t out_channels, const Padding padding) { - srand(time(NULL)); + // srand(time(NULL)); // Construct graph OpsTestNet net; @@ -156,7 +159,7 @@ void WinogradConvolutionWithPad(const index_t batch, const index_t in_channels, const index_t out_channels, const int padding) { - srand(time(NULL)); + // srand(time(NULL)); // Construct graph OpsTestNet net; @@ -245,9 +248,6 @@ void WinogradConvolutionWithPad(const index_t batch, } } -TEST_F(WinogradConvlutionTest, UnAlignedConvolutionPad2) { - WinogradConvolutionWithPad(1, 64, 64, 40, 19, 2); - WinogradConvolutionWithPad(1, 32, 32, 96, 109, 2); -} - -} +} // namespace test +} // namespace ops +} // namespace mace diff --git a/mace/ops/winograd_inverse_transform.cc b/mace/ops/winograd_inverse_transform.cc index 677fe3e7905bac6c553e794bd28c998627faff08..47d1148b78d14ec3bb3cda183d645bae1ac59599 100644 --- a/mace/ops/winograd_inverse_transform.cc +++ b/mace/ops/winograd_inverse_transform.cc @@ -5,6 +5,7 @@ #include "mace/ops/winograd_inverse_transform.h" namespace mace { +namespace ops { void Register_WinogradInverseTransform(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("WinogradInverseTransform") @@ -19,4 +20,5 @@ void Register_WinogradInverseTransform(OperatorRegistry *op_registry) { WinogradInverseTransformOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/winograd_inverse_transform.h b/mace/ops/winograd_inverse_transform.h index 4ea492899a7301ad9656d2bdd0370e5ae96fec33..55be83b70e983abc1fed4623dfd21ed3018233f1 100644 --- a/mace/ops/winograd_inverse_transform.h +++ b/mace/ops/winograd_inverse_transform.h @@ -6,12 +6,14 @@ #define MACE_OPS_WINOGRAD_INVERSE_TRANSFORM_H_ #include +#include #include "mace/core/operator.h" #include "mace/kernels/activation.h" #include "mace/kernels/winograd_transform.h" namespace mace { +namespace ops { template class WinogradInverseTransformOp : public Operator { @@ -42,6 +44,7 @@ class WinogradInverseTransformOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_WINOGRAD_INVERSE_TRANSFORM_H_ diff --git a/mace/ops/winograd_transform.cc b/mace/ops/winograd_transform.cc index e7cd86882a73ca967bfbfb587181cd6ae57ad70a..f8aa4f621a137d6b87337951fd7896c20ec0a3dc 100644 --- a/mace/ops/winograd_transform.cc +++ b/mace/ops/winograd_transform.cc @@ -5,6 +5,7 @@ #include "mace/ops/winograd_transform.h" namespace mace { +namespace ops { void Register_WinogradTransform(OperatorRegistry *op_registry) { REGISTER_OPERATOR(op_registry, OpKeyBuilder("WinogradTransform") @@ -19,4 +20,5 @@ void Register_WinogradTransform(OperatorRegistry *op_registry) { WinogradTransformOp); } +} // namespace ops } // namespace mace diff --git a/mace/ops/winograd_transform.h b/mace/ops/winograd_transform.h index e225adc768570345680c7d93039c8db2ca7738d6..c9476fc80e642451394270ac6350cdab8f1c4602 100644 --- a/mace/ops/winograd_transform.h +++ b/mace/ops/winograd_transform.h @@ -11,6 +11,7 @@ #include "mace/kernels/winograd_transform.h" namespace mace { +namespace ops { template class WinogradTransformOp : public Operator { @@ -37,6 +38,7 @@ class WinogradTransformOp : public Operator { OP_OUTPUT_TAGS(OUTPUT); }; +} // namespace ops } // namespace mace #endif // MACE_OPS_WINOGRAD_TRANSFORM_H_ diff --git a/mace/ops/winograd_transform_benchmark.cc b/mace/ops/winograd_transform_benchmark.cc index 23f7249bbb28fb00c4f44794425eac01d5c86c14..bb20d186efea82ff236b0d7a89a37b0a6b16baa6 100644 --- a/mace/ops/winograd_transform_benchmark.cc +++ b/mace/ops/winograd_transform_benchmark.cc @@ -7,6 +7,9 @@ #include "mace/ops/ops_test_util.h" namespace mace { +namespace ops { +namespace test { + template static void BMWinogradTransform( int iters, int batch, int height, int width, int channels) { @@ -105,4 +108,6 @@ BM_WINOGRAD_INVERSE_TRANSFORM(1, 14, 14, 32); BM_WINOGRAD_INVERSE_TRANSFORM(1, 62, 62, 32); BM_WINOGRAD_INVERSE_TRANSFORM(1, 126, 126, 32); +} // namespace test +} // namespace ops } // namespace mace