Skip to content

Commit

Permalink
Add method for checking memory address changes in the zero tensor
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Pereanu <bogdan.pereanu@intel.com>
  • Loading branch information
pereanub committed Jan 8, 2025
1 parent ac35818 commit f505588
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 240 deletions.
18 changes: 4 additions & 14 deletions src/plugins/intel_npu/src/backend/include/zero_infer_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@
#include "zero_pipeline.hpp"
#include "zero_profiling.hpp"
#include "zero_remote_tensor.hpp"
#include "zero_tensor.hpp"

namespace intel_npu {

struct TensorInfo {
bool tensorCreatedLocally;
uint64_t originalMemoryId;
};

class ZeroInferRequest final : public SyncInferRequest {
public:
explicit ZeroInferRequest(const std::shared_ptr<ZeroInitStructsHolder>& initStructs,
Expand Down Expand Up @@ -67,12 +63,9 @@ class ZeroInferRequest final : public SyncInferRequest {
std::shared_ptr<ov::ITensor>& get_level_zero_input(size_t index, size_t tensorNo = 0) const;
std::vector<std::shared_ptr<ov::ITensor>>& get_level_zero_inputs(size_t index) const;

std::shared_ptr<ov::ITensor> allocate_tensor(
const IODescriptor& descriptor,
const size_t index,
const bool isInput,
const ov::Allocator& allocator = {},
const std::optional<std::size_t> batchSize = std::nullopt) const override;
std::shared_ptr<ov::ITensor> create_tensor(ov::element::Type type,
const ov::Shape& shape,
const ov::Allocator& allocator = {}) const override;

const std::shared_ptr<ZeroInitStructsHolder> _initStructs;
const std::shared_ptr<IGraph> _graph;
Expand All @@ -84,9 +77,6 @@ class ZeroInferRequest final : public SyncInferRequest {
mutable std::vector<std::vector<std::shared_ptr<ov::ITensor>>> _levelZeroInputTensors;
mutable std::vector<std::shared_ptr<ov::ITensor>> _levelZeroOutputTensors;

mutable std::vector<TensorInfo> _levelZeroInputTensorInfo;
mutable std::vector<TensorInfo> _levelZeroOutputTensorInfo;

ze_device_properties_t _properties = {};
std::shared_ptr<const zeroMemory::HostMemAllocator> _inputAllocator;
std::shared_ptr<const zeroMemory::HostMemAllocator> _outputAllocator;
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
#include "intel_npu/common/igraph.hpp"
#include "intel_npu/utils/zero/zero_utils.hpp"
#include "intel_npu/utils/zero/zero_wrappers.hpp"
#include "openvino/runtime/itensor.hpp"
#include "zero_memory.hpp"
#include "zero_profiling.hpp"
#include "zero_tensor.hpp"

namespace intel_npu {

struct Pipeline {
public:
Pipeline(const Config& config,
const std::shared_ptr<ZeroInitStructsHolder>& initStructs,
const std::shared_ptr<ZeroInitStructsHolder>& init_structs,
const std::shared_ptr<IGraph>& graph,
zeroProfiling::ProfilingPool& profiling_pool,
zeroProfiling::ProfilingQuery& profiling_query,
const std::shared_ptr<zeroProfiling::NpuInferProfiling>& npu_profiling,
const std::vector<std::vector<std::shared_ptr<ov::ITensor>>>& inputTensorsData,
const std::vector<std::shared_ptr<ov::ITensor>>& outputTensorsData,
const std::vector<std::vector<std::shared_ptr<ov::ITensor>>>& input_tensors_data,
const std::vector<std::shared_ptr<ov::ITensor>>& output_tensors_data,
uint32_t group_ordinal);

Pipeline(const Pipeline&) = delete;
Expand All @@ -33,8 +33,8 @@ struct Pipeline {
void pull();
void reset() const;

void updateCommandList(const void* data, size_t byte_size, uint32_t index);
void updateCommandList(const void* data, uint32_t index, size_t commandListIndex);
void updateCommandList(uint32_t arg_index, const void* arg_data, size_t byte_size);
void updateCommandListIndex(uint32_t arg_index, const void* arg_data, size_t command_list_index);

protected:
std::shared_ptr<IGraph> _graph;
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/intel_npu/src/backend/include/zero_tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ZeroTensor final : public ov::ITensor {
const ov::Shape& shape,
const ov::Allocator& allocator);

void* data(const ov::element::Type& element_type) const override;
void* data(const ov::element::Type& type = {}) const override;

const ov::element::Type& get_element_type() const override;

Expand All @@ -32,6 +32,9 @@ class ZeroTensor final : public ov::ITensor {

const ov::Strides& get_strides() const override;

bool memory_address_changed();
void reset_memory_flag();

~ZeroTensor();

private:
Expand All @@ -51,6 +54,7 @@ class ZeroTensor final : public ov::ITensor {
mutable std::once_flag _strides_once;
ov::Allocator _allocator;
void* _ptr = nullptr;
bool _reset_tensor_memory = false;
};

} // namespace intel_npu
Loading

0 comments on commit f505588

Please sign in to comment.