diff --git a/lite/api/paddle_lite_factory_helper.h b/lite/api/paddle_lite_factory_helper.h index 9dc5c9e857243ecb57f785737b00929e36c5d83c..3923ab28a823127a5a9b82c352bf756ce25d0c76 100644 --- a/lite/api/paddle_lite_factory_helper.h +++ b/lite/api/paddle_lite_factory_helper.h @@ -19,7 +19,50 @@ #pragma once // some platform-independent defintion -#include "lite/utils/macros.h" +// #include "lite/utils/macros.h" +// just copy lite/utils/macros.h here temperarily by mlu, since it affects +// compilation of demos +// BEGIN by MLU +#ifndef DISALLOW_COPY_AND_ASSIGN +#define DISALLOW_COPY_AND_ASSIGN(class__) \ + class__(const class__&) = delete; \ + class__& operator=(const class__&) = delete; +#endif + +#define LITE_UNIMPLEMENTED CHECK(false) << "Not Implemented"; + +#if defined(_WIN32) +#define UNUSED +#define __builtin_expect(EXP, C) (EXP) +#else +#define UNUSED __attribute__((unused)) +#endif + +/* +#ifndef LIKELY +#define LIKELY(x) __builtin_expect(!!(x), 1) +#endif + +#ifndef UNLIKELY +//#define UNLIKELY(x) __built_expect(!!(x), 0) +#define UNLIKELY(x) (x) +#endif + */ + +#ifdef __CUDACC__ +#define HOSTDEVICE __host__ __device__ +#define DEVICE __device__ +#define HOST __host__ +#else +#define HOSTDEVICE +#define DEVICE +#define HOST +#endif + +#if defined(__FLT_MAX__) +#define FLT_MAX __FLT_MAX__ +#endif // __FLT_MAX__ +// END by MLU #define USE_LITE_OP(op_type__) \ extern int touch_op_##op_type__(); \ diff --git a/lite/core/mir/mlu_postprocess_pass.cc b/lite/core/mir/mlu_postprocess_pass.cc index 03d3c5056031c0604e706157fd509508dcd5ea8d..4ea24390d661e055ee87d17d3a6125e945625421 100644 --- a/lite/core/mir/mlu_postprocess_pass.cc +++ b/lite/core/mir/mlu_postprocess_pass.cc @@ -570,11 +570,11 @@ void MLUPostprocessPass::Apply(const std::unique_ptr& graph) { // arg_in and arg_out are assumed to be NHWC which user should be aware of. // Thus here we change these args' layout to NHWC #ifdef LITE_WITH_MLU - if (lite::DeviceInfo::Global().InputLayout() == DATALAYOUT(kNHWC)) { + if (lite::TargetWrapperMlu::InputLayout() == DATALAYOUT(kNHWC)) { ModifyLayout(graph.get()); } - if (lite::DeviceInfo::Global().UseFirstConv()) { + if (lite::TargetWrapperMlu::UseFirstConv()) { GatherAndModifyFirstConvNodes(graph.get()); } #endif diff --git a/lite/kernels/mlu/bridges/graph.h b/lite/kernels/mlu/bridges/graph.h index 80d3e3bcf1f075701df44f3843ea9e27001575dd..c4fb10bdb581b97d42e16ec6c9cce38465a84f93 100644 --- a/lite/kernels/mlu/bridges/graph.h +++ b/lite/kernels/mlu/bridges/graph.h @@ -120,7 +120,8 @@ class Graph { output_addrs_[i] = output_tensors_[i]->mlu_data(); } -#if PRINT_HW_TIME thread_local float hw_time; +#if PRINT_HW_TIME + thread_local float hw_time; CNRT_CALL(cnrtPlaceNotifier(notifier_start_, que)); #endif CNML_CALL(cnmlComputeFusionOpForward_V3(fusion_op_, diff --git a/lite/kernels/mlu/subgraph_compute.h b/lite/kernels/mlu/subgraph_compute.h index 7a4328b3b33851f8575661a79c07706bc5c2351e..6b956520976d52d627bf015cc5c0d9af99edb7a2 100644 --- a/lite/kernels/mlu/subgraph_compute.h +++ b/lite/kernels/mlu/subgraph_compute.h @@ -84,32 +84,6 @@ class SubgraphEngine : public subgraph::Engine { return true; } - int Build() { - // In order to attach all of the ops of the block desc, we need to build - // the original program firstly. - BuildOriginProgram(); - // Run InferShape() of all of ops, and convert Paddle ops to MLU IR graph - build_device_program_status_ = BuildDeviceProgram(); - return build_device_program_status_; - } - - int Launch() { - // Rebuild device program when the shapes of input tensors have been - // changed. - if (subgraph::CHECK_SUCCESS(build_device_program_status_) && - subgraph::CHECK_REBUILD_WHEN_SHAPE_CHANGED( - build_device_program_status_) && - InputShapeChanged()) { - Build(); - } - if (subgraph::CHECK_FAILED(build_device_program_status_)) { - LaunchOriginProgram(); - } else { - LaunchDeviceProgram(); - } - return 0; - } - protected: int BuildDeviceProgram() override { int status = 0;