-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2ff0cd
commit 9760d57
Showing
7 changed files
with
193 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// Copyright © 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache 2.0 | ||
// | ||
|
||
#include "intel_npu_acceleration_library/common.h" | ||
|
||
namespace intel_npu_acceleration_library { | ||
|
||
/** | ||
* @brief Class representing a NPU tensor | ||
* | ||
*/ | ||
class Tensor { | ||
private: | ||
ov::intel_npu::level_zero::ZeroBufferTensor _remote_tensor; | ||
void* data_ptr; | ||
|
||
public: | ||
/** | ||
* @brief Construct a new Tensor object | ||
* | ||
* @param dtype tensor datatype | ||
* @param shape tensor shape | ||
* @param data pointer to tensor data | ||
* @param tensor_type tensor type. Choices between INPUT, OUTPUT, BINDED | ||
* @param device target device for the tensor | ||
*/ | ||
Tensor(ov::element::Type_t dtype, ov::Shape shape, void* data, | ||
ov::intel_npu::TensorType tensor_type = ov::intel_npu::TensorType::INPUT, std::string device = "NPU") { | ||
ov::Core core; | ||
auto context = core.get_default_context(device).as<ov::intel_npu::level_zero::ZeroContext>(); | ||
_remote_tensor = context.create_l0_host_tensor(dtype, shape, tensor_type); | ||
data_ptr = _remote_tensor.get(); | ||
std::memcpy(data_ptr, data, _remote_tensor.get_byte_size()); | ||
} | ||
|
||
/** | ||
* @brief Get the data pointer | ||
* | ||
* @return void* | ||
*/ | ||
void* data() { | ||
return data_ptr; | ||
} | ||
}; | ||
|
||
} // namespace intel_npu_acceleration_library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters