Skip to content

Commit

Permalink
fix hip
Browse files Browse the repository at this point in the history
  • Loading branch information
ForFishes committed Dec 23, 2021
1 parent 26a0bb3 commit 581b1a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion paddle/fluid/framework/data_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct DataTypeTrait<void> {
_ForEachDataTypeHelper_(callback, int, INT32); \
_ForEachDataTypeHelper_(callback, int64_t, INT64);

// It's only for DataParallel in HIP
// It's only for DataParallel in HIP, bf16 not support in HIP.
#define _ForEachDataTypeForHIP_(callback) \
_ForEachDataTypeHelper_(callback, float, FP32); \
_ForEachDataTypeHelper_(callback, ::paddle::platform::float16, FP16); \
Expand Down
4 changes: 4 additions & 0 deletions paddle/fluid/imperative/reducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ void Group::DivNRanks(const platform::DeviceContext &context, int64_t nranks) {
VLOG(4) << "before div 2" << *tensor;
VLOG(4) << "NDiv for cpu devices : rank = " << nranks;
#ifdef PADDLE_WITH_HIP
if (dtype_ == paddle::framework::proto::VarType_Type_BF16) {
PADDLE_THROW(paddle::platform::errors::Fatal(
"Unsupport BF16 in DataParallel for now"));
}
framework::VisitDataTypeForHIP(
dtype_, DivNRanksForAllReduce<platform::CPUDeviceContext>(
tensor, nranks, context));
Expand Down
4 changes: 4 additions & 0 deletions paddle/fluid/imperative/reducer.cu
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ namespace imperative {
void Group::DivNRanks(framework::Tensor *tensor, int64_t nranks,
const platform::DeviceContext &context) {
#ifdef PADDLE_WITH_HIP
if (dtype_ == paddle::framework::proto::VarType_Type_BF16) {
PADDLE_THROW(paddle::platform::errors::Fatal(
"Unsupport BF16 in DataParallel for now"));
}
framework::VisitDataTypeForHIP(
dtype_, DivNRanksForAllReduce<platform::CUDADeviceContext>(tensor, nranks,
context));
Expand Down

1 comment on commit 581b1a2

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

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

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.