From 70645e48072bf193fbf069949f1d2b10fddac8a3 Mon Sep 17 00:00:00 2001
From: pointerhacker <145901472+pointerhacker@users.noreply.github.com>
Date: 星期二, 15 十月 2024 17:50:51 +0800
Subject: [PATCH] 数据并行可能导致的模型训练报错 (#2139)
---
runtime/onnxruntime/src/phone-set.cpp | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/runtime/onnxruntime/src/phone-set.cpp b/runtime/onnxruntime/src/phone-set.cpp
index 167fa01..60eb101 100644
--- a/runtime/onnxruntime/src/phone-set.cpp
+++ b/runtime/onnxruntime/src/phone-set.cpp
@@ -13,7 +13,7 @@
namespace funasr {
PhoneSet::PhoneSet(const char *filename) {
ifstream in(filename);
- LoadPhoneSetFromYaml(filename);
+ LoadPhoneSetFromJson(filename);
}
PhoneSet::~PhoneSet()
{
@@ -35,6 +35,25 @@
}
}
+void PhoneSet::LoadPhoneSetFromJson(const char* filename) {
+ nlohmann::json json_array;
+ std::ifstream file(filename);
+ if (file.is_open()) {
+ file >> json_array;
+ file.close();
+ } else {
+ LOG(INFO) << "Error loading token file, token file error or not exist.";
+ exit(-1);
+ }
+
+ int id = 0;
+ for (const auto& element : json_array) {
+ phone_.push_back(element);
+ phn2Id_.emplace(element, id);
+ id++;
+ }
+}
+
int PhoneSet::Size() const {
return phone_.size();
}
--
Gitblit v1.9.1