Skip to content

Commit

Permalink
polish kernel type str (#42791)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenwhql authored May 17, 2022
1 parent fd14069 commit d368637
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions paddle/fluid/framework/op_kernel_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ class OpKernelType {

inline std::ostream& operator<<(std::ostream& os,
const OpKernelType& kernel_key) {
os << "data_type[" << kernel_key.data_type_ << "]:data_layout["
<< kernel_key.data_layout_ << "]:place[" << kernel_key.place_
<< "]:library_type[" << kernel_key.library_type_ << "]";
os << "{data_type[" << kernel_key.data_type_ << "]; data_layout["
<< kernel_key.data_layout_ << "]; place[" << kernel_key.place_
<< "]; library_type[" << kernel_key.library_type_ << "]}";
return os;
}

Expand Down
9 changes: 4 additions & 5 deletions paddle/fluid/framework/op_kernel_type_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ TEST(OpKernelType, ToString) {
LibraryType::kCUDNN);

ASSERT_EQ(paddle::framework::KernelTypeToString(op_kernel_type),
"data_type[float]:data_layout[NCHW]:place[Place(cpu)]:library_type["
"CUDNN]");
"{data_type[float]; data_layout[NCHW]; place[Place(cpu)]; "
"library_type[CUDNN]}");

using CUDAPlace = paddle::platform::CUDAPlace;
OpKernelType op_kernel_type2(DataType::FP16, CUDAPlace(0), DataLayout::kNCHW,
LibraryType::kCUDNN);
ASSERT_EQ(paddle::framework::KernelTypeToString(op_kernel_type2),
"data_type[::paddle::platform::float16]:data_layout[NCHW]:place["
"Place(gpu:0)]:library_"
"type[CUDNN]");
"{data_type[::paddle::platform::float16]; data_layout[NCHW]; "
"place[Place(gpu:0)]; library_type[CUDNN]}");
}

TEST(OpKernelType, Hash) {
Expand Down

0 comments on commit d368637

Please sign in to comment.