Skip to content

Commit 866819a

Browse files
authored
[compiler opt]change_cc_test_old (#59477)
* chang_cc_test_old * chang_cc_test_old * chang_cc_test_old * chang_cc_test_old * chang_cc_test_old * chang_cc_test_old * update * update * update * update * chang_cc_test_old * chang_cc_test_old * chang_cc_test_old * chang_cc_test_old * chang_cc_test_old * chang_cc_test_old * update * update * update * update * update * update * update * update * update * update * update * update * update * fix * update * update * fix bug in windows * fix windows bug * Update CMakeLists.txt * fix * Update CMakeLists.txt * fix * fix * Update CMakeLists.txt * Update CMakeLists.txt * fix win-infer * Update CMakeLists.txt * fix win infer
1 parent 99a281b commit 866819a

File tree

10 files changed

+70
-50
lines changed

10 files changed

+70
-50
lines changed

cmake/generic.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,8 @@ function(paddle_test_build TARGET_NAME)
595595
add_executable(${TARGET_NAME} ${paddle_test_SRCS})
596596
get_property(paddle_lib GLOBAL PROPERTY PADDLE_LIB_NAME)
597597
target_link_libraries(${TARGET_NAME} $<TARGET_LINKER_FILE:${paddle_lib}>
598-
${paddle_test_DEPS} paddle_gtest_main_new)
599-
add_dependencies(${TARGET_NAME} ${paddle_lib} ${paddle_test_DEPS}
598+
${paddle_test_DEPS} common paddle_gtest_main_new)
599+
add_dependencies(${TARGET_NAME} ${paddle_lib} ${paddle_test_DEPS} common
600600
paddle_gtest_main_new)
601601
if(WITH_SHARED_PHI)
602602
target_link_libraries(${TARGET_NAME} $<TARGET_LINKER_FILE:phi>)

paddle/fluid/inference/utils/CMakeLists.txt

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,14 @@ cc_library(
1212
SRCS model_utils.cc
1313
DEPS proto_desc enforce common)
1414

15-
cc_test_old(
16-
infer_io_utils_tester
17-
SRCS
18-
io_utils_tester.cc
19-
DEPS
20-
infer_io_utils
21-
fleet_executor
22-
parallel_executor
23-
python)
15+
cc_library(table_printer SRCS table_printer.cc)
16+
paddle_test(test_table_printer SRCS table_printer_tester.cc)
17+
18+
proto_library(shape_range_info_proto SRCS shape_range_info.proto)
2419

2520
if(WITH_ONNXRUNTIME AND WIN32)
2621
# Copy onnxruntime for some c++ test in Windows, since the test will
2722
# be build only in CI, so suppose the generator in Windows is Ninja.
28-
copy_onnx(infer_io_utils_tester)
23+
copy_onnx(test_benchmark)
24+
copy_onnx(test_table_printer)
2925
endif()
30-
31-
cc_library(table_printer SRCS table_printer.cc)
32-
paddle_test(test_table_printer SRCS table_printer_tester.cc)
33-
34-
proto_library(shape_range_info_proto SRCS shape_range_info.proto)

paddle/fluid/inference/utils/io_utils.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,37 @@ namespace inference {
3030

3131
constexpr uint32_t kCurPDTensorVersion = 0;
3232

33-
void SerializePDTensorToStream(std::ostream* os, const PaddleTensor& tensor);
34-
void DeserializePDTensorToStream(std::istream& is, PaddleTensor* tensor);
33+
TEST_API void SerializePDTensorToStream(std::ostream* os,
34+
const PaddleTensor& tensor);
35+
TEST_API void DeserializePDTensorToStream(std::istream& is,
36+
PaddleTensor* tensor);
3537

36-
void SerializePDTensorsToStream(std::ostream* os,
37-
const std::vector<PaddleTensor>& tensors);
38-
void DeserializePDTensorsToStream(std::istream& is,
39-
std::vector<PaddleTensor>* tensors);
38+
TEST_API void SerializePDTensorsToStream(
39+
std::ostream* os, const std::vector<PaddleTensor>& tensors);
40+
TEST_API void DeserializePDTensorsToStream(std::istream& is,
41+
std::vector<PaddleTensor>* tensors);
4042

41-
void SerializePDTensorsToFile(const std::string& path,
42-
const std::vector<PaddleTensor>& tensors);
43-
void DeserializePDTensorsToFile(const std::string& path,
44-
std::vector<PaddleTensor>* tensors);
45-
void SerializeShapeRangeInfo(
43+
TEST_API void SerializePDTensorsToFile(
44+
const std::string& path, const std::vector<PaddleTensor>& tensors);
45+
TEST_API void DeserializePDTensorsToFile(const std::string& path,
46+
std::vector<PaddleTensor>* tensors);
47+
TEST_API void SerializeShapeRangeInfo(
4648
const std::string& path,
4749
const std::map<std::string, std::vector<int32_t>>& min_shape,
4850
const std::map<std::string, std::vector<int32_t>>& max_shape,
4951
const std::map<std::string, std::vector<int32_t>>& opt_shape,
5052
const std::map<std::string, std::vector<int32_t>>& min_value,
5153
const std::map<std::string, std::vector<int32_t>>& max_value,
5254
const std::map<std::string, std::vector<int32_t>>& opt_value);
53-
void DeserializeShapeRangeInfo(
55+
TEST_API void DeserializeShapeRangeInfo(
5456
const std::string& path,
5557
std::map<std::string, std::vector<int32_t>>* min_shape,
5658
std::map<std::string, std::vector<int32_t>>* max_shape,
5759
std::map<std::string, std::vector<int32_t>>* opt_shape,
5860
std::map<std::string, std::vector<int32_t>>* min_value,
5961
std::map<std::string, std::vector<int32_t>>* max_value,
6062
std::map<std::string, std::vector<int32_t>>* opt_value);
61-
void UpdateShapeRangeInfo(
63+
TEST_API void UpdateShapeRangeInfo(
6264
const std::string& path,
6365
const std::map<std::string, std::vector<int32_t>>& min_shape,
6466
const std::map<std::string, std::vector<int32_t>>& max_shape,

paddle/phi/common/place.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class TEST_API CustomRegisteredDeviceMap {
5555
const char* AllocationTypeStr(AllocationType type);
5656

5757
/// \brief The place is used to specify where the data is stored.
58-
class PADDLE_API Place {
58+
class TEST_API Place {
5959
public:
6060
Place()
6161
: device(0), alloc_type_(AllocationType::UNDEFINED), device_type_id_(0) {}

test/cpp/fluid/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
add_subdirectory(benchmark)
22
add_subdirectory(framework)
3+
4+
add_subdirectory(inference)
5+
36
if(WITH_CINN)
47
add_subdirectory(cinn)
58
endif()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(utils)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
if(WITH_TESTING)
2+
if(NOT APPLE)
3+
inference_base_test(
4+
infer_io_utils_tester SRCS io_utils_tester.cc
5+
DEPS
6+
paddle_inference_shared
7+
common
8+
)
9+
endif()
10+
endif()
11+
12+
if(WITH_ONNXRUNTIME AND WIN32)
13+
# Copy onnxruntime for some c++ test in Windows, since the test will
14+
# be build only in CI, so suppose the generator in Windows is Ninja.
15+
copy_onnx(infer_io_utils_tester)
16+
endif()

test/cpp/pir/core/CMakeLists.txt

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
cc_test(
2-
type_test
3-
SRCS type_test.cc
4-
DEPS pir op_dialect_vjp)
5-
cc_test_old(ir_attribute_test SRCS ir_attribute_test.cc DEPS pir gtest)
6-
cc_test_old(ir_value_test SRCS ir_value_test.cc DEPS pir gtest)
7-
cc_test_old(
1+
paddle_test(type_test SRCS type_test.cc DEPS pir op_dialect_vjp)
2+
paddle_test(ir_attribute_test SRCS ir_attribute_test.cc DEPS pir)
3+
paddle_test(ir_value_test SRCS ir_value_test.cc DEPS pir)
4+
paddle_test(
85
ir_op_test
96
SRCS
107
ir_op_test.cc
118
DEPS
129
pir
1310
test_dialect
1411
op_dialect_vjp)
15-
cc_test_old(ir_region_test SRCS ir_region_test.cc DEPS pir gtest)
16-
cc_test_old(ir_builder_test SRCS ir_builder_test.cc DEPS pir gtest)
12+
paddle_test(ir_region_test SRCS ir_region_test.cc DEPS pir)
13+
paddle_test(ir_builder_test SRCS ir_builder_test.cc DEPS pir)
1714
cc_test_old(
1815
ir_program_test
1916
SRCS
@@ -134,14 +131,8 @@ cc_test_old(
134131
gtest
135132
pir)
136133

137-
cc_test_old(
138-
block_argument_test
139-
SRCS
140-
block_argument_test.cc
141-
DEPS
142-
test_dialect
143-
gtest
144-
pir)
134+
paddle_test(block_argument_test SRCS block_argument_test.cc DEPS test_dialect
135+
pir)
145136

146137
if(WITH_ONNXRUNTIME AND WIN32)
147138
# Copy onnxruntime for some c++ test in Windows, since the test will

test/cpp/pir/core/ir_value_test.cc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,33 @@
1414

1515
#include <gtest/gtest.h>
1616

17+
#include "paddle/fluid/pir/dialect/operator/ir/op_type.h"
1718
#include "paddle/pir/core/attribute.h"
1819
#include "paddle/pir/core/builtin_attribute.h"
20+
#include "paddle/pir/core/builtin_type.h"
1921
#include "paddle/pir/core/ir_context.h"
2022
#include "paddle/pir/core/operation.h"
21-
22-
#include "test/cpp/pir/tools/test_pir_utils.h"
23+
#include "paddle/pir/dialect/shape/utils/shape_utils.h"
2324

2425
// This unittest is used to test the construction interfaces of value class and
2526
// operation. The constructed test scenario is: a = OP1(); b = OP2(); c = OP3(a,
2627
// b); d, e, f, g, h, i, j = OP4(a, c);
28+
namespace test {
29+
30+
pir::AttributeMap CreateAttributeMap(
31+
const std::vector<std::string> &attribute_names,
32+
const std::vector<std::string> &attributes) {
33+
pir::IrContext *ctx = pir::IrContext::Instance();
34+
pir::AttributeMap attr_map;
35+
for (size_t i = 0; i < attribute_names.size(); i++) {
36+
pir::Attribute attr_value = pir::StrAttribute::get(ctx, attributes[i]);
37+
attr_map.insert(
38+
std::pair<std::string, pir::Attribute>(attribute_names[i], attr_value));
39+
}
40+
return attr_map;
41+
}
2742

43+
} // namespace test
2844
TEST(value_test, value_test) {
2945
pir::IrContext *ctx = pir::IrContext::Instance();
3046
// 1. Construct OP1: a = OP1()

0 commit comments

Comments
 (0)