File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ const char *AllocationTypeStr(AllocationType type) {
3737 return " xpu" ;
3838 case AllocationType::IPU:
3939 return " ipu" ;
40+ case AllocationType::CUSTOM:
41+ return " custom_device" ;
4042 default :
4143 PD_THROW (" Invalid phi device type." );
4244 return {};
Original file line number Diff line number Diff line change @@ -304,7 +304,25 @@ template const XPUStorageProperties& DenseTensor::storage_properties() const;
304304#endif
305305
306306bool DenseTensor::storage_properties_initialized () const {
307- return storage_properties_ != nullptr ;
307+ if (storage_properties_ == nullptr ) {
308+ return false ;
309+ } else if (NPUStorageProperties::classof (storage_properties_.get ())) {
310+ return place ().GetType () == AllocationType::CUSTOM;
311+ #ifdef PADDLE_WITH_XPU
312+ } else if (XPUStorageProperties::classof (storage_properties_.get ())) {
313+ return place ().GetType () == AllocationType::XPU;
314+ #endif
315+ #ifdef PADDLE_WITH_DNNL
316+ } else if (OneDNNStorageProperties::classof (storage_properties_.get ())) {
317+ return place ().GetType () == AllocationType::CPU;
318+ #endif
319+ } else {
320+ PADDLE_THROW (
321+ phi::errors::InvalidArgument (" The type of storage_properties [%s] is "
322+ " inconsistent with tensor place [%s]" ,
323+ storage_properties_->type_info ().name (),
324+ AllocationTypeStr (place ().GetType ())));
325+ }
308326}
309327
310328void DenseTensor::set_storage_properties (
You can’t perform that action at this time.
0 commit comments