|
|
@ -11,7 +11,7 @@
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
# limitations under the License.
|
|
|
|
"""Evaluation for U2 model."""
|
|
|
|
"""Quantzation U2 model."""
|
|
|
|
import paddle
|
|
|
|
import paddle
|
|
|
|
from kaldiio import ReadHelper
|
|
|
|
from kaldiio import ReadHelper
|
|
|
|
from paddleslim import PTQ
|
|
|
|
from paddleslim import PTQ
|
|
|
@ -159,17 +159,12 @@ class U2Infer():
|
|
|
|
|
|
|
|
|
|
|
|
# jit save
|
|
|
|
# jit save
|
|
|
|
logger.info(f"export save: {self.args.export_path}")
|
|
|
|
logger.info(f"export save: {self.args.export_path}")
|
|
|
|
config = {
|
|
|
|
self.ptq.save_quantized_model(
|
|
|
|
'is_static': True,
|
|
|
|
self.model,
|
|
|
|
'combine_params': True,
|
|
|
|
self.args.export_path,
|
|
|
|
'skip_forward': True
|
|
|
|
postprocess=False,
|
|
|
|
}
|
|
|
|
combine_params=True,
|
|
|
|
self.ptq.save_quantized_model(self.model, self.args.export_path)
|
|
|
|
skip_forward=True)
|
|
|
|
# paddle.jit.save(
|
|
|
|
|
|
|
|
# self.model,
|
|
|
|
|
|
|
|
# self.args.export_path,
|
|
|
|
|
|
|
|
# combine_params=True,
|
|
|
|
|
|
|
|
# skip_forward=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(config, args):
|
|
|
|
def main(config, args):
|
|
|
@ -191,7 +186,7 @@ if __name__ == "__main__":
|
|
|
|
parser.add_argument(
|
|
|
|
parser.add_argument(
|
|
|
|
"--export_path",
|
|
|
|
"--export_path",
|
|
|
|
type=str,
|
|
|
|
type=str,
|
|
|
|
default='export',
|
|
|
|
default='export.jit.quant',
|
|
|
|
help="path of the input audio file")
|
|
|
|
help="path of the input audio file")
|
|
|
|
args = parser.parse_args()
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|