combine batch_size_like.cc into batch_size_like.h
Created by: luotao1
If we build batch_size_like
independently, it is not in GLOB_OP_LIB
.
https://github.com/PaddlePaddle/Paddle/blob/62fe2f28a19a1c67f0234e35a1f302bda3f3b2c1/paddle/fluid/operators/CMakeLists.txt#L183-L186
https://github.com/PaddlePaddle/Paddle/blob/62fe2f28a19a1c67f0234e35a1f302bda3f3b2c1/paddle/fluid/operators/CMakeLists.txt#L200
where GLOB_OP_LIB
is used to create fluid static library.
https://github.com/PaddlePaddle/Paddle/blob/90648f336d0a73630d0a862259a4f73ab3c9fe8c/paddle/fluid/inference/CMakeLists.txt#L7-L8
If we use this fluid static library in an independent example (see #7827 and https://github.com/luotao1/fluid_inference_example), the building error is
/home/luotao02/PaddleRoot/paddle/fluid/inference/libpaddle_fluid.a(fill_constant_batch_size_like_op.cc.o): In function `paddle::operators::FillConstantBatchSizeLikeOpMaker::FillConstantBatchSizeLikeOpMaker(paddle::framework::proto::OpProto*, paddle::framework::OpAttrChecker*)':
fill_constant_batch_size_like_op.cc:(.text._ZN6paddle9operators32FillConstantBatchSizeLikeOpMakerC2EPNS_9framework5proto7OpProtoEPNS2_13OpAttrCheckerE[_ZN6paddle9operators32FillConstantBatchSizeLikeOpMakerC5EPNS_9framework5proto7OpProtoEPNS2_13OpAttrCheckerE]+0x1c): undefined reference to `paddle::operators::BatchSizeLikeOpMaker::BatchSizeLikeOpMaker(paddle::framework::proto::OpProto*, paddle::framework::OpAttrChecker*)'
/home/luotao02/PaddleRoot/paddle/fluid/inference/libpaddle_fluid.a(fill_constant_batch_size_like_op.cc.o):(.data.rel.ro._ZTIN6paddle9operators27FillConstantBatchSizeLikeOpE[_ZTIN6paddle9operators27FillConstantBatchSizeLikeOpE]+0x10): undefined reference to `typeinfo for paddle::operators::BatchSizeLikeOp'
/home/luotao02/PaddleRoot/paddle/fluid/inference/libpaddle_fluid.a(fill_constant_batch_size_like_op.cc.o):(.data.rel.ro._ZTVN6paddle9operators27FillConstantBatchSizeLikeOpE[_ZTVN6paddle9operators27FillConstantBatchSizeLikeOpE]+0x58): undefined reference to `paddle::operators::BatchSizeLikeOp::InferShape(paddle::framework::InferShapeContext*) const'
/home/luotao02/PaddleRoot/paddle/fluid/inference/libpaddle_fluid.a(fill_constant_batch_size_like_op.cc.o):(.data.rel.ro._ZTV39_OpClass_fill_constant_batch_size_like_[_ZTV39_OpClass_fill_constant_batch_size_like_]+0x58): undefined reference to `paddle::operators::BatchSizeLikeOp::InferShape(paddle::framework::InferShapeContext*) const'
gaussian_random_batch_size_like_op.cc:(.text._ZN6paddle9operators34GaussianRandomBatchSizeLikeOpMakerC2EPNS_9framework5proto7OpProtoEPNS2_13OpAttrCheckerE[_ZN6paddle9operators34GaussianRandomBatchSizeLikeOpMakerC5EPNS_9framework5proto7OpProtoEPNS2_13OpAttrCheckerE]+0x1c): undefined reference to `paddle::operators::BatchSizeLikeOpMaker::BatchSizeLikeOpMaker(paddle::framework::proto::OpProto*, paddle::framework::OpAttrChecker*)'
/home/luotao02/PaddleRoot/paddle/fluid/inference/libpaddle_fluid.a(gaussian_random_batch_size_like_op.cc.o):(.data.rel.ro._ZTIN6paddle9operators29GaussianRandomBatchSizeLikeOpE[_ZTIN6paddle9operators29GaussianRandomBatchSizeLikeOpE]+0x10): undefined reference to `typeinfo for paddle::operators::BatchSizeLikeOp'
/home/luotao02/PaddleRoot/paddle/fluid/inference/libpaddle_fluid.a(gaussian_random_batch_size_like_op.cc.o):(.data.rel.ro._ZTVN6paddle9operators29GaussianRandomBatchSizeLikeOpE[_ZTVN6paddle9operators29GaussianRandomBatchSizeLikeOpE]+0x58): undefined reference to `paddle::operators::BatchSizeLikeOp::InferShape(paddle::framework::InferShapeContext*) const'
/home/luotao02/PaddleRoot/paddle/fluid/inference/libpaddle_fluid.a(gaussian_random_batch_size_like_op.cc.o):(.data.rel.ro._ZTV41_OpClass_gaussian_random_batch_size_like_[_ZTV41_OpClass_gaussian_random_batch_size_like_]+0x58): undefined reference to `paddle::operators::BatchSizeLikeOp::InferShape(paddle::framework::InferShapeContext*) const'
/home/luotao02/PaddleRoot/paddle/fluid/inference/libpaddle_fluid.a(uniform_random_batch_size_like_op.cc.o): In function `paddle::operators::UniformRandomBatchSizeLikeOpMaker::UniformRandomBatchSizeLikeOpMaker(paddle::framework::proto::OpProto*, paddle::framework::OpAttrChecker*)':
uniform_random_batch_size_like_op.cc:(.text._ZN6paddle9operators33UniformRandomBatchSizeLikeOpMakerC2EPNS_9framework5proto7OpProtoEPNS2_13OpAttrCheckerE[_ZN6paddle9operators33UniformRandomBatchSizeLikeOpMakerC5EPNS_9framework5proto7OpProtoEPNS2_13OpAttrCheckerE]+0x1c): undefined reference to `paddle::operators::BatchSizeLikeOpMaker::BatchSizeLikeOpMaker(paddle::framework::proto::OpProto*, paddle::framework::OpAttrChecker*)'
/home/luotao02/PaddleRoot/paddle/fluid/inference/libpaddle_fluid.a(uniform_random_batch_size_like_op.cc.o):(.data.rel.ro._ZTIN6paddle9operators28UniformRandomBatchSizeLikeOpE[_ZTIN6paddle9operators28UniformRandomBatchSizeLikeOpE]+0x10): undefined reference to `typeinfo for paddle::operators::BatchSizeLikeOp'
/home/luotao02/PaddleRoot/paddle/fluid/inference/libpaddle_fluid.a(uniform_random_batch_size_like_op.cc.o):(.data.rel.ro._ZTVN6paddle9operators28UniformRandomBatchSizeLikeOpE[_ZTVN6paddle9operators28UniformRandomBatchSizeLikeOpE]+0x58): undefined reference to `paddle::operators::BatchSizeLikeOp::InferShape(paddle::framework::InferShapeContext*) const'
/home/luotao02/PaddleRoot/paddle/fluid/inference/libpaddle_fluid.a(uniform_random_batch_size_like_op.cc.o):(.data.rel.ro._ZTV40_OpClass_uniform_random_batch_size_like_[_ZTV40_OpClass_uniform_random_batch_size_like_]+0x58): undefined reference to `paddle::operators::BatchSizeLikeOp::InferShape(paddle::framework::InferShapeContext*) const'
Thus, we could combine batch_size_like.cc into batch_size_like.h, and remove cc_library(batch_size_like SRCS batch_size_like.cc DEPS op_registry)
in operator/CMakelists.txt.