Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CustomDevice] fix amp op list #56176

Merged
merged 1 commit into from
Aug 11, 2023
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
16 changes: 1 addition & 15 deletions paddle/fluid/imperative/amp_auto_cast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ OpSupportedInfos(const std::string& place,
{"GPU", &platform::is_gpu_place},
{"CPU", &platform::is_cpu_place},
{"XPU", &platform::is_xpu_place},
{"CUSTOM_DEVICE", &platform::is_custom_place},
};
PADDLE_ENFORCE_NE(
is_target_place.count(query_place),
Expand All @@ -76,12 +77,6 @@ OpSupportedInfos(const std::string& place,
}
}

#ifdef PADDLE_WITH_CUSTOM_DEVICE
auto is_custom_place = [&](const std::string& place) {
return is_target_place.count(place) && place != "CPU" && place != "GPU" &&
place != "XPU";
};
#endif
auto phi_kernels = phi::KernelFactory::Instance().kernels();
for (auto& kernel_pair : phi_kernels) {
auto op_type = phi::TransToFluidOpName(kernel_pair.first);
Expand All @@ -90,15 +85,6 @@ OpSupportedInfos(const std::string& place,
all_ops.count(op_type) == 0) {
continue;
}
#ifdef PADDLE_WITH_CUSTOM_DEVICE
if (info_pair.first.backend() == phi::Backend::CUSTOM) {
if (is_custom_place(query_place)) {
VLOG(4) << op_type << " " << supported_ops.size();
supported_ops.emplace(op_type);
}
continue;
}
#endif
if (is_target_place[query_place](
phi::TransToPhiPlace(info_pair.first.backend(), false))) {
VLOG(8) << op_type << " " << supported_ops.size();
Expand Down
5 changes: 5 additions & 0 deletions python/paddle/static/amp/fp16_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import copy
import logging

import paddle
from paddle.amp.amp_lists import (
EXTRA_BLACK_LIST,
FP16_BLACK_LIST,
Expand Down Expand Up @@ -94,6 +95,10 @@ def _get_sys_unsupported_list(dtype):
device = None
if core.is_compiled_with_xpu():
device = 'XPU'
elif isinstance(
paddle.framework._current_expected_place(), paddle.CustomPlace
):
device = 'CUSTOM_DEVICE'
else:
device = 'GPU'
all_ops, _, sys_unsupported_list = core.op_supported_infos(device, var_type)
Expand Down