From 6a8c595fc3ca8005e2d08387354553835c64e951 Mon Sep 17 00:00:00 2001
From: 雾聪 <wucong.lyb@alibaba-inc.com>
Date: 星期二, 26 三月 2024 17:41:34 +0800
Subject: [PATCH] add log for torch

---
 runtime/onnxruntime/src/paraformer-torch.cpp |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/runtime/onnxruntime/src/paraformer-torch.cpp b/runtime/onnxruntime/src/paraformer-torch.cpp
index bdfd0ee..7cac291 100644
--- a/runtime/onnxruntime/src/paraformer-torch.cpp
+++ b/runtime/onnxruntime/src/paraformer-torch.cpp
@@ -45,8 +45,15 @@
     #ifdef USE_IPEX
     torch::jit::setTensorExprFuserEnabled(false);
     #endif
-    torch::jit::script::Module model = torch::jit::load(am_model, device);
-    model_ = std::make_shared<TorchModule>(std::move(model));    
+
+    try {
+        torch::jit::script::Module model = torch::jit::load(am_model, device);
+        model_ = std::make_shared<TorchModule>(std::move(model)); 
+        LOG(INFO) << "Successfully load model from " << am_model;
+    } catch (std::exception const &e) {
+        LOG(ERROR) << "Error when load am model: " << e.what();
+        exit(-1);
+    }
 }
 
 void ParaformerTorch::InitLm(const std::string &lm_file, 

--
Gitblit v1.9.1