提交 e2e1b11b 编写于 作者: X xiebaiyuan 提交者: GitHub

[mobile] fix part package , opt log ,test=mobile (#2643)

* [mobile] fix part package , opt log ,test=mobile

* fix code style ,test=mobile

* [mobile]code style ,test=mobile

* fix code style ,test=mobile
上级 aadb65d2
...@@ -33,28 +33,49 @@ namespace paddle_mobile { ...@@ -33,28 +33,49 @@ namespace paddle_mobile {
static const char *ANDROID_LOG_TAG = static const char *ANDROID_LOG_TAG =
"paddle_mobile LOG built on " __DATE__ " " __TIME__; "paddle_mobile LOG built on " __DATE__ " " __TIME__;
#ifdef PADDLE_ENABLE_COLORABLE_LOG
#define PADDLE_RED "\033[1;31;40m"
#define PADDLE_GREEN "\033[1;32;40m"
#define PADDLE_YELLOW "\033[1;33;40m"
#define PADDLE_LIGHT_RED "\033[1;35;40m"
#define PADDLE_BLUE "\033[1;34;40m"
#define PADDLE_WHITE "\033[1;37;40m"
#define PADDLE_CONON "\033[0m"
#else
#define PADDLE_RED ""
#define PADDLE_GREEN ""
#define PADDLE_YELLOW ""
#define PADDLE_LIGHT_RED ""
#define PADDLE_BLUE ""
#define PADDLE_WHITE ""
#define PADDLE_CONON ""
#endif
#define ANDROIDLOGI(...) \ #define ANDROIDLOGI(...) \
__android_log_print(ANDROID_LOG_INFO, ANDROID_LOG_TAG, __VA_ARGS__); \ __android_log_print(ANDROID_LOG_INFO, ANDROID_LOG_TAG, __VA_ARGS__); \
fprintf(stderr, "%s\n", __VA_ARGS__); \ fprintf(stderr, PADDLE_YELLOW "%s\n" PADDLE_CONON, __VA_ARGS__); \
fflush(stderr) fflush(stderr)
#define ANDROIDLOGW(...) \ #define ANDROIDLOGW(...) \
__android_log_print(ANDROID_LOG_WARNING, ANDROID_LOG_TAG, __VA_ARGS__); \ __android_log_print(ANDROID_LOG_WARN, ANDROID_LOG_TAG, __VA_ARGS__); \
fprintf(stderr, "%s\n", __VA_ARGS__); \ fprintf(stderr, PADDLE_LIGHT_RED "%s\n" PADDLE_CONON, __VA_ARGS__); \
fflush(stderr) fflush(stderr)
#define ANDROIDLOGD(...) \ #define ANDROIDLOGD(...) \
__android_log_print(ANDROID_LOG_DEBUG, ANDROID_LOG_TAG, __VA_ARGS__); \ __android_log_print(ANDROID_LOG_DEBUG, ANDROID_LOG_TAG, __VA_ARGS__); \
fprintf(stderr, "%s\n", __VA_ARGS__); \ fprintf(stderr, PADDLE_WHITE "%s\n" PADDLE_CONON, __VA_ARGS__); \
fflush(stderr) fflush(stderr)
#define ANDROIDLOGE(...) \ #define ANDROIDLOGE(...) \
__android_log_print(ANDROID_LOG_ERROR, ANDROID_LOG_TAG, __VA_ARGS__); \ __android_log_print(ANDROID_LOG_ERROR, ANDROID_LOG_TAG, __VA_ARGS__); \
fprintf(stderr, "%s\n", __VA_ARGS__); \ fprintf(stderr, PADDLE_RED "%s\n" PADDLE_CONON, __VA_ARGS__); \
fflush(stderr)
#define ANDROIDLOGV(...) \
__android_log_print(ANDROID_LOG_VERBOSE, ANDROID_LOG_TAG, __VA_ARGS__); \
fprintf(stderr, PADDLE_GREEN "%s\n" PADDLE_CONON, __VA_ARGS__); \
fflush(stderr) fflush(stderr)
#else #else
#define ANDROIDLOGI(...) #define ANDROIDLOGI(...)
#define ANDROIDLOGW(...) #define ANDROIDLOGW(...)
#define ANDROIDLOGD(...) #define ANDROIDLOGD(...)
#define ANDROIDLOGE(...) #define ANDROIDLOGE(...)
#define ANDROIDLOGV(...)
#endif #endif
...@@ -63,6 +84,7 @@ enum LogLevel { ...@@ -63,6 +84,7 @@ enum LogLevel {
kLOG_ERROR, kLOG_ERROR,
kLOG_WARNING, kLOG_WARNING,
kLOG_INFO, kLOG_INFO,
kLOG_VERBOSE,
kLOG_DEBUG, kLOG_DEBUG,
kLOG_DEBUG1, kLOG_DEBUG1,
kLOG_DEBUG2, kLOG_DEBUG2,
...@@ -73,9 +95,9 @@ enum LogLevel { ...@@ -73,9 +95,9 @@ enum LogLevel {
// log level // log level
static LogLevel log_level = kLOG_DEBUG4; static LogLevel log_level = kLOG_DEBUG4;
static std::vector<std::string> logs{"NO", "ERROR ", "WARNING", static std::vector<std::string> logs{"NO ", "ERROR ", "WARNING", "INFO ",
"INFO ", "DEBUG ", "DEBUG1 ", "VERBOSE", "DEBUG ", "DEBUG1 ", "DEBUG2 ",
"DEBUG2 ", "DEBUG3 ", "DEBUG4 "}; "DEBUG3 ", "DEBUG4 "};
struct ToLog; struct ToLog;
struct Print; struct Print;
...@@ -97,9 +119,27 @@ struct Print { ...@@ -97,9 +119,27 @@ struct Print {
#else #else
std::cerr << buffer_.str() << std::endl; std::cerr << buffer_.str() << std::endl;
#endif #endif
} else { } else if (level == kLOG_INFO) {
#ifdef ANDROID #ifdef ANDROID
ANDROIDLOGI(buffer_.str().c_str()); ANDROIDLOGI(buffer_.str().c_str());
#else
std::cerr << buffer_.str() << std::endl;
#endif
} else if (level == kLOG_VERBOSE) {
#ifdef ANDROID
ANDROIDLOGV(buffer_.str().c_str());
#else
std::cerr << buffer_.str() << std::endl;
#endif
} else if (level == kLOG_WARNING) {
#ifdef ANDROID
ANDROIDLOGW(buffer_.str().c_str());
#else
std::cerr << buffer_.str() << std::endl;
#endif
} else {
#ifdef ANDROID
ANDROIDLOGD(buffer_.str().c_str());
#else #else
std::cout << buffer_.str() << std::endl; std::cout << buffer_.str() << std::endl;
#endif #endif
...@@ -131,6 +171,7 @@ struct ToLog { ...@@ -131,6 +171,7 @@ struct ToLog {
#define LOG(level) \ #define LOG(level) \
if (level > paddle_mobile::log_level) { \ if (level > paddle_mobile::log_level) { \
/* NOLINTNEXTLINE */ \
} else \ } else \
paddle_mobile::ToLog( \ paddle_mobile::ToLog( \
level, static_cast<const std::stringstream &>( \ level, static_cast<const std::stringstream &>( \
...@@ -143,6 +184,7 @@ struct ToLog { ...@@ -143,6 +184,7 @@ struct ToLog {
#define DLOG \ #define DLOG \
if (paddle_mobile::kLOG_DEBUG > paddle_mobile::log_level) { \ if (paddle_mobile::kLOG_DEBUG > paddle_mobile::log_level) { \
/* NOLINTNEXTLINE */ \
} else \ } else \
paddle_mobile::ToLog( \ paddle_mobile::ToLog( \
paddle_mobile::kLOG_DEBUG, \ paddle_mobile::kLOG_DEBUG, \
...@@ -156,11 +198,13 @@ struct ToLog { ...@@ -156,11 +198,13 @@ struct ToLog {
#define LOGF(level, format, ...) \ #define LOGF(level, format, ...) \
if (level > paddle_mobile::log_level) { \ if (level > paddle_mobile::log_level) { \
/* NOLINTNEXTLINE */ \
} else \ } else \
printf(format, ##__VA_ARGS__) printf(format, ##__VA_ARGS__)
#define DLOGF(format, ...) \ #define DLOGF(format, ...) \
if (paddle_mobile::kLOG_DEBUG > paddle_mobile::log_level) { \ if (paddle_mobile::kLOG_DEBUG > paddle_mobile::log_level) { \
/* NOLINTNEXTLINE */ \
} else \ } else \
printf(format, ##__VA_ARGS__) printf(format, ##__VA_ARGS__)
...@@ -170,12 +214,14 @@ struct ToLog { ...@@ -170,12 +214,14 @@ struct ToLog {
#define ANDROIDLOGW(...) #define ANDROIDLOGW(...)
#define ANDROIDLOGD(...) #define ANDROIDLOGD(...)
#define ANDROIDLOGE(...) #define ANDROIDLOGE(...)
#define ANDROIDLOGV(...)
enum LogLevel { enum LogLevel {
kNO_LOG, kNO_LOG,
kLOG_ERROR, kLOG_ERROR,
kLOG_WARNING, kLOG_WARNING,
kLOG_INFO, kLOG_INFO,
kLOG_VERBOSE,
kLOG_DEBUG, kLOG_DEBUG,
kLOG_DEBUG1, kLOG_DEBUG1,
kLOG_DEBUG2, kLOG_DEBUG2,
...@@ -193,7 +239,7 @@ struct Print { ...@@ -193,7 +239,7 @@ struct Print {
}; };
struct ToLog { struct ToLog {
ToLog(LogLevel level) {} explicit ToLog(LogLevel level) {}
template <typename T> template <typename T>
ToLog &operator<<(T const &value) { ToLog &operator<<(T const &value) {
...@@ -203,11 +249,13 @@ struct ToLog { ...@@ -203,11 +249,13 @@ struct ToLog {
#define LOG(level) \ #define LOG(level) \
if (true) { \ if (true) { \
/* NOLINTNEXTLINE */ \
} else \ } else \
paddle_mobile::ToLog(level) paddle_mobile::ToLog(level)
#define DLOG \ #define DLOG \
if (true) { \ if (true) { \
/* NOLINTNEXTLINE */ \
} else \ } else \
paddle_mobile::ToLog(paddle_mobile::kLOG_DEBUG) paddle_mobile::ToLog(paddle_mobile::kLOG_DEBUG)
......
...@@ -554,7 +554,7 @@ PMStatus Executor<Device, T>::Predict() { ...@@ -554,7 +554,7 @@ PMStatus Executor<Device, T>::Predict() {
clock_gettime(CLOCK_MONOTONIC, &ts); clock_gettime(CLOCK_MONOTONIC, &ts);
profile[op_index].runBegin = (uint64_t)ts.tv_sec * 1e9 + ts.tv_nsec; profile[op_index].runBegin = (uint64_t)ts.tv_sec * 1e9 + ts.tv_nsec;
#endif #endif
DLOG << i << "th, " LOG(paddle_mobile::kLOG_INFO) << i << "th, "
<< "run op: " << op_handler->Type(); << "run op: " << op_handler->Type();
if (lod_mode_ && input_dim_has_changed_) { if (lod_mode_ && input_dim_has_changed_) {
op_handler->InferShape(); op_handler->InferShape();
......
...@@ -12,6 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ...@@ -12,6 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#ifdef CONV_OP
#include "operators/kernel/arm/convolution/conv_common.h" #include "operators/kernel/arm/convolution/conv_common.h"
#include "framework/context.h" #include "framework/context.h"
#include "operators/math/gemm/gemm1x1s1.h" #include "operators/math/gemm/gemm1x1s1.h"
...@@ -111,3 +113,4 @@ void InitBaseConvKernel(ConvParam<CPU> *param) { ...@@ -111,3 +113,4 @@ void InitBaseConvKernel(ConvParam<CPU> *param) {
} // namespace operators } // namespace operators
} // namespace paddle_mobile } // namespace paddle_mobile
#endif
...@@ -11,6 +11,7 @@ distributed under the License is distributed on an "AS IS" BASIS, ...@@ -11,6 +11,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#ifdef CONV_OP
#include "operators/kernel/central-arm-func/conv_arm_func.h" #include "operators/kernel/central-arm-func/conv_arm_func.h"
#include <vector> #include <vector>
...@@ -375,3 +376,4 @@ template void DepthwiseConv5x5<int8_t, int32_t>(const ConvParam<CPU> &param); ...@@ -375,3 +376,4 @@ template void DepthwiseConv5x5<int8_t, int32_t>(const ConvParam<CPU> &param);
} // namespace operators } // namespace operators
} // namespace paddle_mobile } // namespace paddle_mobile
#endif
...@@ -11,6 +11,7 @@ distributed under the License is distributed on an "AS IS" BASIS, ...@@ -11,6 +11,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#ifdef CONV_OP
#include "operators/kernel/cl/cl-kernel-func/conv_func.h" #include "operators/kernel/cl/cl-kernel-func/conv_func.h"
#include <vector> #include <vector>
...@@ -1123,3 +1124,4 @@ void ConvTranspose3x3s2AddBnRelu(framework::CLHelper *cl_helper, ...@@ -1123,3 +1124,4 @@ void ConvTranspose3x3s2AddBnRelu(framework::CLHelper *cl_helper,
} }
} // namespace operators } // namespace operators
} // namespace paddle_mobile } // namespace paddle_mobile
#endif
...@@ -11,7 +11,7 @@ distributed under the License is distributed on an "AS IS" BASIS, ...@@ -11,7 +11,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#ifdef INSTANCENORM_OP
#include "operators/kernel/cl/cl-kernel-func/instancenorm_func.h" #include "operators/kernel/cl/cl-kernel-func/instancenorm_func.h"
#include <algorithm> #include <algorithm>
namespace paddle_mobile { namespace paddle_mobile {
...@@ -75,3 +75,4 @@ void InstanceNorm(framework::CLHelper *cl_helper, ...@@ -75,3 +75,4 @@ void InstanceNorm(framework::CLHelper *cl_helper,
} }
} // namespace operators } // namespace operators
} // namespace paddle_mobile } // namespace paddle_mobile
#endif
...@@ -193,13 +193,16 @@ endif () ...@@ -193,13 +193,16 @@ endif ()
list(FIND NET "op" CON) list(FIND NET "op" CON)
if (CON GREATER -1) if (CON GREATER -1)
# gen test # # gen test
ADD_EXECUTABLE(test-sigmoid operators/test_sigmoid_op.cpp test_include.h) # ADD_EXECUTABLE(test-sigmoid operators/test_sigmoid_op.cpp test_include.h)
target_link_libraries(test-sigmoid paddle-mobile) # target_link_libraries(test-sigmoid paddle-mobile)
#
# # gen test log
# ADD_EXECUTABLE(test-leakyrelu operators/test_leaky_relu_op.cpp)
# target_link_libraries(test-leakyrelu paddle-mobile)
# gen test log # gen test log
ADD_EXECUTABLE(test-leakyrelu operators/test_leaky_relu_op.cpp) ADD_EXECUTABLE(test-log common/test_log.cpp)
target_link_libraries(test-leakyrelu paddle-mobile) target_link_libraries(test-log paddle-mobile)
set(FOUND_MATCH ON) set(FOUND_MATCH ON)
endif () endif ()
...@@ -238,7 +241,7 @@ if (ENABLE_ALL_TEST) ...@@ -238,7 +241,7 @@ if (ENABLE_ALL_TEST)
target_link_libraries(test-conv-op paddle-mobile) target_link_libraries(test-conv-op paddle-mobile)
# gen test # gen test
ADD_EXECUTABLE(test-expend-op operators/test_expend_op.cpp test_helper.h test_include.h executor_for_test_opencl.h ) ADD_EXECUTABLE(test-expend-op operators/test_expend_op.cpp test_helper.h test_include.h executor_for_test_opencl.h)
target_link_libraries(test-expend-op paddle-mobile) target_link_libraries(test-expend-op paddle-mobile)
# gen test # gen test
...@@ -485,7 +488,6 @@ if (ENABLE_ALL_TEST) ...@@ -485,7 +488,6 @@ if (ENABLE_ALL_TEST)
ADD_EXECUTABLE(test-gesture net/test_gesture.cpp test_helper.h test_include.h) ADD_EXECUTABLE(test-gesture net/test_gesture.cpp test_helper.h test_include.h)
target_link_libraries(test-gesture paddle-mobile) target_link_libraries(test-gesture paddle-mobile)
ADD_EXECUTABLE(test-sequence-expand-op operators/test_sequence_expand_op.cpp test_helper.h test_include.h) ADD_EXECUTABLE(test-sequence-expand-op operators/test_sequence_expand_op.cpp test_helper.h test_include.h)
target_link_libraries(test-sequence-expand-op paddle-mobile) target_link_libraries(test-sequence-expand-op paddle-mobile)
...@@ -550,7 +552,7 @@ if (ENABLE_ALL_TEST) ...@@ -550,7 +552,7 @@ if (ENABLE_ALL_TEST)
ADD_EXECUTABLE(test-inference-api-v2 net/test_inference_api_v2.cpp test_helper.h test_include.h executor_for_test.h) ADD_EXECUTABLE(test-inference-api-v2 net/test_inference_api_v2.cpp test_helper.h test_include.h executor_for_test.h)
target_link_libraries(test-inference-api-v2 paddle-mobile) target_link_libraries(test-inference-api-v2 paddle-mobile)
endif () endif ()
else() else ()
# gen test # gen test
ADD_EXECUTABLE(test-net net/test_net.cpp test_helper.h test_include.h executor_for_test.h) ADD_EXECUTABLE(test-net net/test_net.cpp test_helper.h test_include.h executor_for_test.h)
target_link_libraries(test-net paddle-mobile) target_link_libraries(test-net paddle-mobile)
...@@ -560,4 +562,4 @@ else() ...@@ -560,4 +562,4 @@ else()
ADD_EXECUTABLE(test-inference-api-v2 net/test_inference_api_v2.cpp test_helper.h test_include.h executor_for_test.h) ADD_EXECUTABLE(test-inference-api-v2 net/test_inference_api_v2.cpp test_helper.h test_include.h executor_for_test.h)
target_link_libraries(test-inference-api-v2 paddle-mobile) target_link_libraries(test-inference-api-v2 paddle-mobile)
endif() endif ()
...@@ -15,10 +15,8 @@ limitations under the License. */ ...@@ -15,10 +15,8 @@ limitations under the License. */
#include "common/log.h" #include "common/log.h"
int main() { int main() {
DLOGF("DASJFDAFJ%d -- %f", 12345, 344.234); LOG(paddle_mobile::kLOG_DEBUG3) << "test debug"
<< " next log";
LOGF(paddle_mobile::kLOG_DEBUG, "DASJFDAFJ%d -- %f", 12345, 344.234);
LOG(paddle_mobile::kLOG_DEBUG) << "test debug" LOG(paddle_mobile::kLOG_DEBUG) << "test debug"
<< " next log"; << " next log";
...@@ -26,9 +24,12 @@ int main() { ...@@ -26,9 +24,12 @@ int main() {
<< " next log"; << " next log";
LOG(paddle_mobile::kLOG_DEBUG2) << "test debug2" LOG(paddle_mobile::kLOG_DEBUG2) << "test debug2"
<< " next log"; << " next log";
LOG(paddle_mobile::kLOG_INFO) << "INFO!!!";
LOG(paddle_mobile::kLOG_WARNING) << "WARNING!!!";
LOG(paddle_mobile::kLOG_VERBOSE) << "VERBOSE!!!";
DLOG << "test DLOG"; DLOG << "test DLOG";
LOG(paddle_mobile::kLOG_ERROR) << " error occur !"; LOG(paddle_mobile::kLOG_ERROR) << "ERROR !";
return 0; return 0;
} }
...@@ -273,8 +273,9 @@ endif() ...@@ -273,8 +273,9 @@ endif()
list(FIND NET "op" CON) list(FIND NET "op" CON)
if (CON GREATER -1) if (CON GREATER -1)
message("op enabled") message("op enabled")
set(SIGMOID_OP ON) # set(SIGMOID_OP ON)
set(LEAKY_RELU_OP ON) # set(LEAKY_RELU_OP ON)
set(BLOG ON)
set(FOUND_MATCH ON) set(FOUND_MATCH ON)
endif() endif()
...@@ -763,4 +764,7 @@ endif() ...@@ -763,4 +764,7 @@ endif()
if (GRID_SAMPLER_OP) if (GRID_SAMPLER_OP)
add_definitions(-DGRID_SAMPLER_OP) add_definitions(-DGRID_SAMPLER_OP)
endif() endif()
if (BLOG)
add_definitions(-DBLOG)
endif()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册