Skip to content

Commit a91086f

Browse files
committed
[VitisAI] Recognize native-endian in-memory address tag in process_ext_address
ORT marks initializers whose data lives in an in-process memory buffer with one of two location sentinels: the original little-endian tag "*/_ORT_MEM_ADDR_/*" (kTensorProtoLittleEndianMemoryAddressTag) and the newer native-endian tag "*/_ORT_NATIVE_ENDIAN_MEM_ADDR_/*" (kTensorProtoNativeEndianMemoryAddressTag). Since #27404, TensorToTensorProto() emits the native-endian tag by default, but the VitisAI EP's process_ext_address only matched the little-endian tag. As a result, in-memory initializers (e.g. quantized weights moved out of the TensorProto during graph optimization) are no longer detected by model_clone, fall through to the verbatim-copy branch, and carry the in-memory marker into the cloned model protobuf. After #28709 added an explicit ORT_ENFORCE in Graph::Graph rejecting in-memory address markers in deserialized protobufs, this now aborts model compilation with: Initializer '...' references an ORT in-memory address marker, which is not allowed in a model protobuf. Both tags encode the buffer address in the 'offset' field; on little-endian hosts (the only platform this EP targets) the byte layout is identical, so they are decoded the same way. Recognizing both tags restores the pre-1.27 behavior of converting these initializers to a lightweight reference during model_clone.
1 parent ba45260 commit a91086f

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

onnxruntime/core/providers/vitisai/imp/tensor_proto.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,17 @@ gsl::span<const char> process_ext_address(const ONNX_NAMESPACE::TensorProto& ten
3131
// checksum = (size_t)std::strtoull(data.mutable_value()->data(), &end, 10);
3232
}
3333
}
34-
if (file == "*/_ORT_MEM_ADDR_/*") {
34+
// ORT marks initializers whose data lives in an in-process memory buffer
35+
// (e.g. weights moved out of the TensorProto during graph optimization) with
36+
// one of two sentinels in the 'location' field. The original little-endian
37+
// tag is still emitted for some paths, but newer ORT defaults to the
38+
// native-endian tag (see TensorToTensorProto / kTensorProtoNativeEndianMemoryAddressTag).
39+
// Both encode the buffer address in the 'offset' field; on little-endian
40+
// hosts (the only platform this EP targets) the bytes are identical, so we
41+
// decode them the same way. Recognizing only the little-endian tag would let
42+
// native-endian-tagged initializers slip through model_clone and trip ORT's
43+
// "in-memory address marker not allowed in a model protobuf" check.
44+
if (file == "*/_ORT_MEM_ADDR_/*" || file == "*/_ORT_NATIVE_ENDIAN_MEM_ADDR_/*") {
3545
auto addr = reinterpret_cast<const char*>(offset);
3646
return {addr, size};
3747
}

0 commit comments

Comments
 (0)