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

[NPU] fix storage_properties type mismatch with OneDNN and NPU #60566

Merged
merged 1 commit into from
Jan 10, 2024
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
2 changes: 2 additions & 0 deletions paddle/phi/common/place.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const char *AllocationTypeStr(AllocationType type) {
return "xpu";
case AllocationType::IPU:
return "ipu";
case AllocationType::CUSTOM:
return "custom_device";
default:
PD_THROW("Invalid phi device type.");
return {};
Expand Down
20 changes: 19 additions & 1 deletion paddle/phi/core/dense_tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,25 @@ template const XPUStorageProperties& DenseTensor::storage_properties() const;
#endif

bool DenseTensor::storage_properties_initialized() const {
return storage_properties_ != nullptr;
if (storage_properties_ == nullptr) {
return false;
} else if (NPUStorageProperties::classof(storage_properties_.get())) {
return place().GetType() == AllocationType::CUSTOM;
#ifdef PADDLE_WITH_XPU
} else if (XPUStorageProperties::classof(storage_properties_.get())) {
return place().GetType() == AllocationType::XPU;
#endif
#ifdef PADDLE_WITH_DNNL
} else if (OneDNNStorageProperties::classof(storage_properties_.get())) {
return place().GetType() == AllocationType::CPU;
#endif
} else {
PADDLE_THROW(
phi::errors::InvalidArgument("The type of storage_properties [%s] is "
"inconsistent with tensor place [%s]",
storage_properties_->type_info().name(),
AllocationTypeStr(place().GetType())));
}
}

void DenseTensor::set_storage_properties(
Expand Down