|
|
|
@ -21,6 +21,7 @@ limitations under the License. */
|
|
|
|
|
#include "paddle/fluid/framework/ir/graph.h"
|
|
|
|
|
#include "paddle/fluid/framework/ir/node.h"
|
|
|
|
|
#include "paddle/fluid/framework/program_desc.h"
|
|
|
|
|
#include "paddle/fluid/platform/port.h"
|
|
|
|
|
#include "paddle/fluid/platform/variant.h"
|
|
|
|
|
|
|
|
|
|
namespace paddle {
|
|
|
|
@ -172,6 +173,7 @@ struct PassRegistrar : public Registrar {
|
|
|
|
|
__test_global_namespace_##uniq_name##__>::value, \
|
|
|
|
|
msg)
|
|
|
|
|
|
|
|
|
|
#if !defined(_WIN32)
|
|
|
|
|
// Register a new pass that can be applied on the IR.
|
|
|
|
|
#define REGISTER_PASS(pass_type, pass_class) \
|
|
|
|
|
STATIC_ASSERT_PASS_GLOBAL_NAMESPACE( \
|
|
|
|
@ -194,7 +196,32 @@ struct PassRegistrar : public Registrar {
|
|
|
|
|
extern int TouchPassRegistrar_##pass_type(); \
|
|
|
|
|
static int use_pass_itself_##pass_type##_ __attribute__((unused)) = \
|
|
|
|
|
TouchPassRegistrar_##pass_type()
|
|
|
|
|
#else
|
|
|
|
|
// windows version of __attribute__((unused))
|
|
|
|
|
#define UNUSED(x) __pragma(warning(suppress : 4100)) x
|
|
|
|
|
#define REGISTER_PASS(pass_type, pass_class) \
|
|
|
|
|
STATIC_ASSERT_PASS_GLOBAL_NAMESPACE( \
|
|
|
|
|
__reg_pass__##pass_type, \
|
|
|
|
|
"REGISTER_PASS must be called in global namespace"); \
|
|
|
|
|
static ::paddle::framework::ir::PassRegistrar<pass_class> \
|
|
|
|
|
__pass_registrar_##pass_type##__(#pass_type); \
|
|
|
|
|
int TouchPassRegistrar_##pass_type() { \
|
|
|
|
|
__pass_registrar_##pass_type##__.Touch(); \
|
|
|
|
|
return 0; \
|
|
|
|
|
} \
|
|
|
|
|
static ::paddle::framework::ir::PassRegistrar<pass_class> UNUSED( \
|
|
|
|
|
&__pass_tmp_registrar_##pass_type##__) = \
|
|
|
|
|
__pass_registrar_##pass_type##__
|
|
|
|
|
|
|
|
|
|
#define USE_PASS(pass_type) \
|
|
|
|
|
STATIC_ASSERT_PASS_GLOBAL_NAMESPACE( \
|
|
|
|
|
__use_pass_itself_##pass_type, \
|
|
|
|
|
"USE_PASS must be called in global namespace"); \
|
|
|
|
|
extern int TouchPassRegistrar_##pass_type(); \
|
|
|
|
|
static int UNUSED(use_pass_itself_##pass_type##_) = \
|
|
|
|
|
TouchPassRegistrar_##pass_type()
|
|
|
|
|
|
|
|
|
|
#endif // !_WIN32
|
|
|
|
|
} // namespace ir
|
|
|
|
|
} // namespace framework
|
|
|
|
|
} // namespace paddle
|
|
|
|
|