From d342c642fa7eae3d90cf543c28b153cf5dbd0722 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期三, 10 一月 2024 17:43:50 +0800
Subject: [PATCH] Merge branch 'funasr1.0' of github.com:alibaba-damo-academy/FunASR into funasr1.0 add

---
 runtime/python/onnxruntime/funasr_onnx/utils/utils.py |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/runtime/python/onnxruntime/funasr_onnx/utils/utils.py b/runtime/python/onnxruntime/funasr_onnx/utils/utils.py
index cf74200..260a85e 100644
--- a/runtime/python/onnxruntime/funasr_onnx/utils/utils.py
+++ b/runtime/python/onnxruntime/funasr_onnx/utils/utils.py
@@ -2,12 +2,10 @@
 
 import functools
 import logging
-import pickle
 from pathlib import Path
 from typing import Any, Dict, Iterable, List, NamedTuple, Set, Tuple, Union
 
 import re
-import torch
 import numpy as np
 import yaml
 try:
@@ -27,14 +25,15 @@
     n_batch = len(xs)
     if max_len is None:
         max_len = max(x.size(0) for x in xs)
-    pad = xs[0].new(n_batch, max_len, *xs[0].size()[1:]).fill_(pad_value)
-
+    # pad = xs[0].new(n_batch, max_len, *xs[0].size()[1:]).fill_(pad_value)
+    # numpy format
+    pad = (np.zeros((n_batch, max_len)) + pad_value).astype(np.int32)
     for i in range(n_batch):
-        pad[i, : xs[i].size(0)] = xs[i]
+        pad[i, : xs[i].shape[0]] = xs[i]
 
     return pad
 
-
+'''
 def make_pad_mask(lengths, xs=None, length_dim=-1, maxlen=None):
     if length_dim == 0:
         raise ValueError("length_dim cannot be 0: {}".format(length_dim))
@@ -67,7 +66,7 @@
         )
         mask = mask[ind].expand_as(xs).to(xs.device)
     return mask
-
+'''
 
 class TokenIDConverter():
     def __init__(self, token_list: Union[List, str],

--
Gitblit v1.9.1