Skip to content

Conversation

@ankitm3k
Copy link

@ankitm3k ankitm3k commented Dec 19, 2025

Description

Fixes OpenVINO EP compatibility with OpenVINO 2026.0 by updating tensor data access patterns to use raw untyped data() accessor instead of templated data<T>().

Motivation & Context

OpenVINO 2026.0 introduced two breaking changes for ov::Tensor data access:

  1. Read-only memory-mapped tensors: Memory-mapped tensors from ov::read_tensor_data() now use ReadOnlyViewTensor which throws when calling the templated data<T>() method.

  2. Sub-byte element types (i4/u4): Tensors with INT4 or UINT4 element types fail the is_pointer_representable check when calling data<uint8_t>().

Resolves Runtime Errors

Error 1 - Read-only tensor access:

Exception during initialization: Exception from src/core/src/runtime/tensor.cpp:117:
Exception from src/inference/src/dev/make_tensor.cpp:178:
Can not access non-const pointer use e.g. 'static_cast<const ov::Tensor&>.data(element_type)'

Error 2 - Sub-byte type access:

Exception during initialization: Exception from src/core/src/runtime/tensor.cpp:117:
Tensor data with element type i4, is not representable as pointer to u8

Changes

Updated tensor data access in 3 files to use raw untyped data() accessor:

File Description
ov_shared_context.cc Memory-mapped weights and host tensor access for sub-byte types
ov_bin_manager.cc Binary cache stream buffer and mapped blob access
ov_allocator.cc NPU host tensor allocation

Before:

const_cast<char*>(tensor.data<char>());

After:

const_cast<void*>(static_cast<const ov::Tensor&>(tensor).data())

The untyped data() accessor:

  • Works on read-only tensors when accessed via const reference
  • Bypasses is_pointer_representable check for sub-byte types (i4/u4)
  • Follows the pattern used in OpenVINO's own codebase (see ov::op::v0::Constant constructor)

JIRA: https://jira.devtools.intel.com/browse/CVS-178227

@ankitm3k ankitm3k requested a review from sfatimar December 19, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants