Skip to content

Commit

Permalink
Change string ctor
Browse files Browse the repository at this point in the history
Signed-off-by: p-wysocki <[email protected]>
  • Loading branch information
p-wysocki committed Jan 8, 2025
1 parent 26e5fe9 commit 668629a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/bindings/python/src/pyopenvino/core/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ py::array bytes_array_from_tensor(ov::Tensor&& t) {
OPENVINO_THROW("Tensor's type must be a string!");
}
auto data = t.data<std::string>();
std::cout << "[C++] bytes_array_from_tensor\n";
for (size_t i = 0; i < t.get_size(); ++i) {
std::cout << "String " << i << ": " << data[i] << " (bytes: ";
for (unsigned char c : data[i]) {
std::cout << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(c) << " ";
}
std::cout << ")" << std::endl;
}
auto max_element = std::max_element(data, data + t.get_size(), [](const std::string& x, const std::string& y) {
return x.length() < y.length();
});
Expand Down Expand Up @@ -177,7 +185,7 @@ void fill_tensor_from_bytes(ov::Tensor& tensor, py::array& array) {
auto data = tensor.data<std::string>();
for (size_t i = 0; i < tensor.get_size(); ++i) {
const char* ptr = reinterpret_cast<const char*>(buf.ptr) + (i * buf.itemsize);
data[i] = std::string(ptr, buf.ndim == 0 ? buf.itemsize : buf.strides[0]);
data[i] = std::string(ptr, strnlen(ptr, buf.itemsize));
}
}

Expand Down

0 comments on commit 668629a

Please sign in to comment.