--- ./onnxruntime/core/framework/tensorprotoutils.h.origin	2025-03-10 01:29:00.185990219 +0000
+++ ./onnxruntime/core/framework/tensorprotoutils.h	2025-03-10 01:31:26.116008381 +0000
@@ -25,12 +25,18 @@
 namespace utils {
 /**
  * This function is used to convert the endianess of Tensor data.
+ * If ext_data_buf is provided, then this buffer content's endianess
+ * will be changed.
  * Mostly, will be used in big endian system to support the model file
  * generated on little endian system.
- * @param initializer       given initializer tensor
+ * @param tensor_proto given initializer tensor
+ * @param ext_data_buf optional externl data buffer
+ * @param ext_data_len optional externl data buffer length
  * @returns                 None
  */
-void ConvertRawDataInTensorProto(ONNX_NAMESPACE::TensorProto* initializer);
+void ConvertRawDataInTensorProto(ONNX_NAMESPACE::TensorProto* tensor_proto,
+                                 void* ext_data_buf = NULL,
+                                 size_t ext_data_len = 0);
 
 /**
  * Wrapper function for set_raw_data.
--- ./onnxruntime/core/framework/session_state_utils.cc.origin	2025-03-10 01:26:39.846007302 +0000
+++ ./onnxruntime/core/framework/session_state_utils.cc	2025-03-10 01:27:08.816008638 +0000
@@ -81,6 +81,12 @@
                                                        ext_data_buf, ext_data_len, ext_data_deleter,
                                                        buffered_tensor));
 
+  if constexpr (endian::native != endian::little) {
+    if (!proto_path.empty() && (proto_path.compare(onnxruntime::utils::kTensorProtoMemoryAddressTag) != 0)) {
+      utils::ConvertRawDataInTensorProto(const_cast<ONNX_NAMESPACE::TensorProto*>(&tensor_proto), ext_data_buf, ext_data_len);
+    }
+  }
+
   // NB: creating a do-nothing allocator per tensor is wasteful; can perhaps be
   // avoided if the Tensor class implements the do-nothing behavior when given a
   // nullptr for the allocator argument
--- ./onnxruntime/core/framework/tensorprotoutils.cc.origin	2025-03-10 01:39:19.539326274 +0000
+++ ./onnxruntime/core/framework/tensorprotoutils.cc	2025-03-10 01:39:30.310296211 +0000
@@ -265,10 +265,15 @@
   tensor_proto.set_raw_data(std::move(param));
 }
 
-void ConvertRawDataInTensorProto(TensorProto* tensor) {
+void ConvertRawDataInTensorProto(TensorProto* tensor,
+                                 void* ext_data_buf,
+                                 size_t ext_data_len) {
   size_t element_size = 1;
   char* bytes = NULL;
   size_t num_elements = 0;
+  if (ext_data_buf && !ext_data_len) {
+    return;
+  }
   switch (tensor->data_type()) {
     case TensorProto_DataType_FLOAT:
       bytes = reinterpret_cast<char*>(tensor->mutable_float_data()->mutable_data());
@@ -332,6 +337,14 @@
     num_elements = (tensor->raw_data().size()) / element_size;
     bytes = const_cast<char*>(tensor->mutable_raw_data()->c_str());
   }
+  if (element_size == 1) {
+    return;
+  }
+  if (ext_data_buf) {
+    ORT_ENFORCE(ext_data_len % element_size == 0);
+    num_elements = ext_data_len / element_size;
+    bytes = reinterpret_cast<char*>(ext_data_buf);
+  }
   for (size_t i = 0; i < num_elements; ++i) {
     char* start_byte = bytes + i * element_size;
     char* end_byte = start_byte + element_size - 1;
