From f99e4911436cbf061f6a5759188b47e8179e6529 Mon Sep 17 00:00:00 2001
From: Sanggyu Lee <takepencil@naver.com>
Date: Thu, 16 May 2024 10:29:00 +0900
Subject: [PATCH] [onert/api] Make a clone circle in nnfw_train_export_circle
 (#13001)

It is a missing code segment.
It makes a copy of original circle before exporting circle.

ONE-DCO-1.0-Signed-off-by: Sanggyu Lee <sg5.lee@samsung.com>
---
 runtime/onert/api/nnfw/src/nnfw_api_internal.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/runtime/onert/api/nnfw/src/nnfw_api_internal.cc b/runtime/onert/api/nnfw/src/nnfw_api_internal.cc
index c24186fae0f..ec60e137d67 100644
--- a/runtime/onert/api/nnfw/src/nnfw_api_internal.cc
+++ b/runtime/onert/api/nnfw/src/nnfw_api_internal.cc
@@ -1674,6 +1674,10 @@ NNFW_STATUS nnfw_session::train_export_circle(const char *path)
     size_t _buf_sz = 0;
   };
 
+  std::ifstream src(_model_path, std::ios::binary);
+  std::ofstream dst(path, std::ios::binary);
+  dst << src.rdbuf();
+
   MMappedFile mmapfile(path);
   if (!mmapfile.ensure_mmap())
     return NNFW_STATUS_ERROR;