Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions paddle/fluid/distributed/collective/bkcl_tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,29 @@ std::string SerializeBKCLUniqueId(const BKCLUniqueId& bkclID) {
return oss.str();
}

std::string BKCLDTypeToString(BKCLDataType dtype) {
#define PD_BKCL_DTYPE_TO_STR(__bkcl_dtype, __str_dtype) \
if (dtype == __bkcl_dtype) return __str_dtype;
PD_BKCL_DTYPE_TO_STR(BKCL_FLOAT, "float32");
PD_BKCL_DTYPE_TO_STR(BKCL_FLOAT16, "float16");
PD_BKCL_DTYPE_TO_STR(BKCL_BFLOAT16, "bfloat16");
PD_BKCL_DTYPE_TO_STR(BKCL_FLOAT64, "float64");
PD_BKCL_DTYPE_TO_STR(BKCL_UINT8, "uint8");
PD_BKCL_DTYPE_TO_STR(BKCL_INT32, "int32");
PD_BKCL_DTYPE_TO_STR(BKCL_INT64, "int64");

#undef PD_BKCL_DTYPE_TO_STR
PADDLE_THROW(phi::errors::InvalidArgument(
"This datatype %d in nccl is not supported.", static_cast<int>(dtype)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nccl -> bkcl

}

std::string BKCLRedTypeToString(BKCLOp op) {
if (op == BKCL_ADD) return "SUM";
if (op == BKCL_PRODUCT) return "PROD";
if (op == BKCL_MIN) return "MIN";
if (op == BKCL_MAX) return "MAX";
return "UDF_" + std::to_string(op);
}

} // namespace distributed
} // namespace paddle
2 changes: 2 additions & 0 deletions paddle/fluid/distributed/collective/bkcl_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class XPUEventManager {

BKCLOp ToBKCLRedType(ReduceOp reduction);
std::string SerializeBKCLUniqueId(const BKCLUniqueId& bkclId);
std::string BKCLDTypeToString(BKCLDataType dtype);
std::string BKCLRedTypeToString(BKCLOp op);

} // namespace distributed
} // namespace paddle
Loading