From 821decb9c954819b95c4b94424dc97c009902cbc Mon Sep 17 00:00:00 2001
From: Hashim Sharif <hsharif3@tyler.cs.illinois.edu>
Date: Wed, 13 Nov 2019 20:52:26 -0600
Subject: [PATCH] Bug Fix for freeing FP16 gpu data

---
 .../tensor_runtime/include/tensor_utils.cu    | 21 ++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/tensor_utils.cu b/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/tensor_utils.cu
index fc5fa87283..c65fd8b016 100644
--- a/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/tensor_utils.cu
+++ b/llvm/projects/hpvm-tensor-rt/tensor_runtime/include/tensor_utils.cu
@@ -63,6 +63,20 @@ struct Tensor* getRuntimeTensor(struct Tensor* hpvm_tensor){
 */
 
 
+/*void freeCudaPtr(void* cuda_ptr){
+
+  int i;
+  for(i = 0; i < tensors_ptr.size(); i++){
+    if(tensors_ptr[i] == cuda_ptr)
+      break;   
+  }
+
+  tensors_ptr.erase(tensors_ptr.begin()+i);
+  cudaFree(cuda_ptr);
+}
+*/
+
+
 void freeTensor(void* tensor_ptr){
 
   Tensor* tensor = (Tensor*) tensor_ptr;
@@ -536,9 +550,10 @@ void convertToFP32_offline(struct Tensor* tensor){
   h2f((half*) tensor->gpu_half_data, tensor->num_elems, (float*) tensor->gpu_data);
 
   tensor->cur_type = float_type;
-  
-  cudaFree(tensor->gpu_half_data);
-  tensor->gpu_half_data = NULL;
+
+  //freeCudaPtr(tensor->gpu_half_data);
+  //cudaFree(tensor->gpu_half_data);
+  //tensor->gpu_half_data = NULL;
 }
 
 
-- 
GitLab