Skip to content

Commit 71c9269

Browse files
praaszCopilot
andauthored
Fix compile error for Tensor::data() (#3009)
## Description - Fix compilation issuesr with updated ov::Tensor::data() member. for OV 26.0 to fix build issues. - No test update, functionality not changed. - No docs update required. Blocked PR: - openvinotoolkit/openvino#32569 <!--- Jira ticket number (e.g., 123). Delete if there's no ticket. Don't include full link or project name. --> Ticket: CVS-174872 ## Checklist: - [x] Tests have been updated or added to cover the new code <!--- If the change isn't maintenance related, update the tests at https://github.com/openvinotoolkit/openvino.genai/tree/master/tests or explain in the description why the tests don't need an update. --> - [x] This patch fully addresses the ticket. <!--- If follow-up pull requests are needed, specify in description. --> - [x] I have made corresponding changes to the documentation --------- Signed-off-by: Raasz, Pawel <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent aed499a commit 71c9269

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/cpp/src/lora/adapter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ struct AutoSafetensor: public safetensors_File {
9999
// The memory block will be deallocated when the last Constant is destroyed.
100100
ConstantMap safetensor_to_constant_map(const ov::Tensor& safetensor) {
101101
AutoSafetensor safe_tensors_file{};
102-
103-
OPENVINO_ASSERT(safetensors_file_init(safetensor.data<char>(), safetensor.get_byte_size(), &safe_tensors_file) == nullptr,
102+
// Intentionally discard const qualifier used as read only in safetensors_file_init
103+
auto safetensor_data = const_cast<char*>(safetensor.data<char>());
104+
OPENVINO_ASSERT(safetensors_file_init(safetensor_data, safetensor.get_byte_size(), &safe_tensors_file) == nullptr,
104105
"Cannot parse safetensor as a Safetensors file format. Safetensors file format is supported only"
105106
);
106107

src/cpp/src/speculative_decoding/speculative_decoding_stateful.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ std::variant<int64_t, std::vector<int64_t>>
338338

339339
auto sample_token = [&](const ov::Tensor& logits, std::size_t idx) {
340340
size_t sequence_offset = idx * vocab_size;
341-
float* logits_data = logits.data<float>() + sequence_offset;
341+
const auto logits_data = logits.data<float>() + sequence_offset;
342342
return std::max_element(logits_data, logits_data + vocab_size) - logits_data;
343343
};
344344

0 commit comments

Comments
 (0)