Skip to content

Commit

Permalink
[NPU] Fix High CPU overhead in ZeroHostTensor::data (#28603)
Browse files Browse the repository at this point in the history
### Details:
 - *High CPU overhead in ZeroHostTensor::data*

### Tickets:
 - *CVS-160977*

Signed-off-by: Bogdan Pereanu <[email protected]>
  • Loading branch information
pereanub authored Jan 22, 2025
1 parent a7ef4f8 commit 5203351
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ZeroHostTensor : public ov::ITensor {
std::shared_ptr<ZeroRemoteTensor> get_impl() const;

private:
std::shared_ptr<ZeroRemoteTensor> m_impl;
std::shared_ptr<ZeroRemoteTensor> _impl;
};

} // namespace intel_npu
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class ZeroRemoteTensor final : public RemoteTensor {
ov::intel_npu::MemType mem_type = ov::intel_npu::MemType::L0_INTERNAL_BUF,
void* mem = nullptr);

void* get_original_memory() const;

~ZeroRemoteTensor() override;

private:
Expand Down
31 changes: 13 additions & 18 deletions src/plugins/intel_npu/src/backend/src/zero_host_tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,36 @@ ZeroHostTensor::ZeroHostTensor(const std::shared_ptr<ov::IRemoteContext>& contex
const ov::element::Type element_type,
const ov::Shape& shape,
const Config& config)
: m_impl(std::make_shared<ZeroRemoteTensor>(context,
init_structs,
element_type,
shape,
config,
ov::intel_npu::TensorType::BINDED,
ov::intel_npu::MemType::L0_INTERNAL_BUF)) {}
: _impl(std::make_shared<ZeroRemoteTensor>(context,
init_structs,
element_type,
shape,
config,
ov::intel_npu::TensorType::BINDED,
ov::intel_npu::MemType::L0_INTERNAL_BUF)) {}

void* ZeroHostTensor::data(const ov::element::Type&) const {
auto itrHandle = m_impl->get_properties().find(ov::intel_npu::mem_handle.name());
if (itrHandle == m_impl->get_properties().end()) {
OPENVINO_THROW("No parameter ", ov::intel_npu::mem_handle.name(), " found in parameters map");
}

return ov::Any(itrHandle->second).as<void*>();
return _impl->get_original_memory();
}

const ov::element::Type& ZeroHostTensor::get_element_type() const {
return m_impl->get_element_type();
return _impl->get_element_type();
}

const ov::Shape& ZeroHostTensor::get_shape() const {
return m_impl->get_shape();
return _impl->get_shape();
}

const ov::Strides& ZeroHostTensor::get_strides() const {
return m_impl->get_strides();
return _impl->get_strides();
}

void ZeroHostTensor::set_shape(ov::Shape new_shape) {
m_impl->set_shape(new_shape);
_impl->set_shape(new_shape);
}

std::shared_ptr<ZeroRemoteTensor> ZeroHostTensor::get_impl() const {
return m_impl;
return _impl;
}

} // namespace intel_npu
4 changes: 4 additions & 0 deletions src/plugins/intel_npu/src/backend/src/zero_remote_tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,8 @@ void ZeroRemoteTensor::update_properties() {
}
}

void* ZeroRemoteTensor::get_original_memory() const {
return _data;
}

} // namespace intel_npu

0 comments on commit 5203351

Please sign in to comment.