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
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