diff --git a/Control/AthOnnxruntimeUtils/AthOnnxruntimeUtils/ATLAS_CHECK_THREAD_SAFETY b/Control/AthOnnxruntimeUtils/AthOnnxruntimeUtils/ATLAS_CHECK_THREAD_SAFETY
new file mode 100644
index 0000000000000000000000000000000000000000..584871312ff47294e79fe6b60a5656ef2df1202b
--- /dev/null
+++ b/Control/AthOnnxruntimeUtils/AthOnnxruntimeUtils/ATLAS_CHECK_THREAD_SAFETY
@@ -0,0 +1 @@
+Control/AthOnnxruntimeUtils
diff --git a/Control/AthOnnxruntimeUtils/AthOnnxruntimeUtils/FlattenInput.h b/Control/AthOnnxruntimeUtils/AthOnnxruntimeUtils/FlattenInput.h
new file mode 100644
index 0000000000000000000000000000000000000000..0a4abfaf797012965de5ee8461d28d8c6c2c45af
--- /dev/null
+++ b/Control/AthOnnxruntimeUtils/AthOnnxruntimeUtils/FlattenInput.h
@@ -0,0 +1,29 @@
+// Dear emacs, this is -*- c++ -*-
+// Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+#ifndef FlattenInput_H
+#define FlattenInput_H
+
+#include <string>
+#include <iostream> 
+#include <fstream>
+#include <arpa/inet.h>
+#include <vector>
+#include <iterator>
+
+
+namespace AthONNX {
+ template<typename T>
+ inline std::vector<T> FlattenInput2D_1D( std::vector<std::vector<T>> features, int size){
+    std::vector<float> Flatten1D(size);
+    for(std::size_t r=0;r<features.size();++r){
+      int n_cols = features[r].size();
+      for(int c=0;c<n_cols;++c){
+        float a = float(features[r][c]);
+        Flatten1D[r*n_cols+c] = a;
+      }
+    }
+   return Flatten1D;
+  }
+
+}
+#endif
diff --git a/Control/AthOnnxruntimeUtils/CMakeLists.txt b/Control/AthOnnxruntimeUtils/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..4889ec32ea928507ae6a10b6d9e9c247fd37107e
--- /dev/null
+++ b/Control/AthOnnxruntimeUtils/CMakeLists.txt
@@ -0,0 +1,11 @@
+# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+
+# Declare the package's name.
+atlas_subdir( AthOnnxruntimeUtils )
+
+# Component(s) in the package.
+atlas_add_library( AthOnnxruntimeUtilsLib
+   INTERFACE
+   PUBLIC_HEADERS AthOnnxruntimeUtils
+   LINK_LIBRARIES AthenaKernel GaudiKernel )
+
diff --git a/Control/AthenaExamples/AthExOnnxRuntime/CMakeLists.txt b/Control/AthenaExamples/AthExOnnxRuntime/CMakeLists.txt
index 2cf4c6266bf76455785f1d518a18c77a02562daf..5aa822732907986932fb9b7c2ca0fa696234cb17 100644
--- a/Control/AthenaExamples/AthExOnnxRuntime/CMakeLists.txt
+++ b/Control/AthenaExamples/AthExOnnxRuntime/CMakeLists.txt
@@ -13,7 +13,7 @@ atlas_add_library( AthExOnnxRuntimeLib
 atlas_add_component( AthExOnnxRuntime
    src/*.h src/*.cxx src/components/*.cxx
    INCLUDE_DIRS ${ONNXRUNTIME_INCLUDE_DIRS}
-   LINK_LIBRARIES ${ONNXRUNTIME_LIBRARIES} AthExOnnxRuntimeLib AthenaBaseComps GaudiKernel PathResolver AthOnnxruntimeServiceLib)
+   LINK_LIBRARIES ${ONNXRUNTIME_LIBRARIES} AthExOnnxRuntimeLib AthenaBaseComps GaudiKernel PathResolver AthOnnxruntimeServiceLib AthOnnxruntimeUtilsLib)
 
 # Install files from the package.
 atlas_install_joboptions( share/*.py )
diff --git a/Control/AthenaExamples/AthExOnnxRuntime/share/AthExOnnxRuntime_jobOptions.py b/Control/AthenaExamples/AthExOnnxRuntime/share/AthExOnnxRuntime_jobOptions.py
index ac1beaef5aeb13e9bd1ac3bf12cb308e5face1a4..65db94b13e03e60151e2bcb8e3b65565ba1195b2 100644
--- a/Control/AthenaExamples/AthExOnnxRuntime/share/AthExOnnxRuntime_jobOptions.py
+++ b/Control/AthenaExamples/AthExOnnxRuntime/share/AthExOnnxRuntime_jobOptions.py
@@ -20,6 +20,7 @@ AthONNX.TestSample = randint(0, 9999)
 AthONNX.DoBatches = False
 AthONNX.NumberOfBatches = 1
 AthONNX.SizeOfBatch = 1
+AthONNX.OutputLevel = DEBUG
 
 # Run for 10 "events".
 theApp.EvtMax = 2
diff --git a/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModel.cxx b/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModel.cxx
index 90bcb63839f9de589f086631310ee8b0b796fff1..98edd86c7d1951bd0c00afe4e472459081556c5c 100644
--- a/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModel.cxx
+++ b/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModel.cxx
@@ -5,15 +5,17 @@
 
 // Framework include(s).
 #include "PathResolver/PathResolver.h"
+#include "AthOnnxruntimeUtils/FlattenInput.h"
 
+//class AthONNX::FlattenInput;
 namespace AthONNX {
 
    //*******************************************************************
    // for reading MNIST images
-   std::vector<std::vector<float>> read_mnist_pixel(const std::string &full_path) //function to load test images
+   std::vector<std::vector<std::vector<float>>> read_mnist_pixel_notFlat(const std::string &full_path) //function to load test images
    {
-     std::vector<std::vector<float>> input_tensor_values;
-     input_tensor_values.resize(10000, std::vector<float>(28*28*1));  
+     std::vector<std::vector<std::vector<float>>> input_tensor_values;
+     input_tensor_values.resize(10000, std::vector<std::vector<float> >(28,std::vector<float>(28)));
      std::ifstream file (full_path.c_str(), std::ios::binary);
      int magic_number=0;
      int number_of_images=0;
@@ -29,15 +31,15 @@ namespace AthONNX {
      n_cols= ntohl(n_cols);
      for(int i=0;i<number_of_images;++i)
      {
-        for(int r=0;r<n_rows;++r)
+      	for(int r=0;r<n_rows;++r)
         {
            for(int c=0;c<n_cols;++c)
            {
              unsigned char temp=0;
              file.read((char*)&temp,sizeof(temp));
-             input_tensor_values[i][r*n_cols+c]= float(temp)/255;
+             input_tensor_values[i][r][c]= float(temp)/255;
            }
-        }
+	}
      }
      return input_tensor_values;
    }
@@ -95,9 +97,9 @@ namespace AthONNX {
                                                     modelFileName.c_str(),
                                                     sessionOptions );
       ATH_MSG_INFO( "Created the ONNX Runtime session" );
-      m_input_tensor_values = read_mnist_pixel(pixelFileName);
-      m_output_tensor_values = read_mnist_label(labelFileName);
-
+      m_input_tensor_values_notFlat = read_mnist_pixel_notFlat(pixelFileName);
+      std::vector<std::vector<float>> c = m_input_tensor_values_notFlat[0];
+      m_output_tensor_values = read_mnist_label(labelFileName);    
       // Return gracefully.
       return StatusCode::SUCCESS;
    }
@@ -164,17 +166,18 @@ namespace AthONNX {
      	output_node_dims[0] = 1;
  
        /***************** Choose an example sample randomly ****************************/  
-     	std::vector<float> input_tensor_values = m_input_tensor_values[m_testSample];
+     	std::vector<std::vector<float>> input_tensor_values = m_input_tensor_values_notFlat[m_testSample];
+        std::vector<float> flatten = AthONNX::FlattenInput2D_1D(input_tensor_values, 784);
         // Output label of corresponding m_input_tensor_values[m_testSample]; e.g 0, 1, 2, 3 etc
         int output_tensor_values = m_output_tensor_values[m_testSample];
        
         // For a check that the sample dimension is fully flatten (1x28x28 = 784)
-     	ATH_MSG_DEBUG("Size of Input tensor: "<<input_tensor_values.size()); 
+        ATH_MSG_DEBUG("Size of Flatten Input tensor: "<<flatten.size());
 
      	/************** Create input tensor object from input data values to feed into your model *********************/
      	Ort::Value input_tensor = Ort::Value::CreateTensor<float>(memory_info, 
-                                                                  input_tensor_values.data(), 
-                                                                  input_tensor_values.size(),  /*** 1x28x28 = 784 ***/ 
+                                                                  flatten.data(), 
+                                                                  flatten.size(),  /*** 1x28x28 = 784 ***/ 
                                                                   input_node_dims.data(), 
                                                                   input_node_dims.size());     /*** [1, 28, 28] = 3 ***/
 
@@ -226,14 +229,15 @@ namespace AthONNX {
      	output_node_dims[0] = m_sizeOfBatch;   
      
 	/************************** process multiple batches ********************************/
+        int l =0; /****** variable for distributing rows in m_input_tensor_values_notFlat equally into batches*****/ 
      	for (int i = 0; i < m_numberOfBatches; i++) {
      		ATH_MSG_DEBUG("Processing batch #" << i);
       		std::vector<float> batch_input_tensor_values;
-  
-      		for (int j = 0; j < m_sizeOfBatch; j++) {
-
+      		for (int j = l; j < l+m_sizeOfBatch; j++) {
+                         
+                        std::vector<float> flattened_input = AthONNX::FlattenInput2D_1D(m_input_tensor_values_notFlat[j],784);
                         /******************For each batch we need a flattened (5 x 28 x 28 = 3920) 1D array******************************/
-        		batch_input_tensor_values.insert(batch_input_tensor_values.end(),m_input_tensor_values[j].begin(),m_input_tensor_values[j].end());
+        		batch_input_tensor_values.insert(batch_input_tensor_values.end(), flattened_input.begin(), flattened_input.end());
         	}   
 
         	Ort::Value batch_input_tensors = Ort::Value::CreateTensor<float>(memory_info,
@@ -263,9 +267,9 @@ namespace AthONNX {
         	float* floatarr = batch_output_tensors.front().GetTensorMutableData<float>();
      
      		// show  true label for the test input
-		for(int i = 0; i<m_sizeOfBatch; i++){
+		for(int i = l; i<l+m_sizeOfBatch; i++){
      			ATH_MSG_INFO("Label for the input test data  = "<<m_output_tensor_values[i]);
-                	int k = i*10;
+                	int k = (i-l)*10;
                 	float max = -999;
                 	int max_index = 0;
      			for (int j =k ; j < k+10; j++){
@@ -276,8 +280,8 @@ namespace AthONNX {
        				}
      			}
     	       	ATH_MSG_INFO("Class: "<<max_index-k<<" has the highest score: "<<floatarr[max_index]);
-      		} 
-
+       		} 
+           l = l+m_sizeOfBatch;
           }
      } // else/m_doBatches == True codition ends
     // Return gracefully.
diff --git a/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModel.h b/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModel.h
index 59e0fc5933e604e5a793aeb88479fe107d8989a9..e4a3c0424cee7c433e1f18044e9b1804d3851322 100644
--- a/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModel.h
+++ b/Control/AthenaExamples/AthExOnnxRuntime/src/EvaluateModel.h
@@ -5,7 +5,6 @@
 
 // Local include(s).
 #include "AthOnnxruntimeService/IONNXRuntimeSvc.h"
-
 // Framework include(s).
 #include "AthenaBaseComps/AthReentrantAlgorithm.h"
 #include "GaudiKernel/ServiceHandle.h"
@@ -79,7 +78,7 @@ namespace AthONNX {
 
       /// The "session" of ONNX Runtime that we'll be using
       std::unique_ptr< Ort::Session > m_session;
-      std::vector<std::vector<float>> m_input_tensor_values;
+      std::vector<std::vector<std::vector<float>>> m_input_tensor_values_notFlat;
       std::vector<int> m_output_tensor_values;
 
    }; // class EvaluateModel