alexwengg's picture
Add SenseVoiceSmall CoreML (preprocessor fp32 + encoder fp16/ANE + fp32 fallback + vocab + card)
f992cca verified
program(1.0)
[buildInfo = dict<tensor<string, []>, tensor<string, []>>({{"coremlc-component-MIL", "3520.4.1"}, {"coremlc-version", "3520.5.1"}, {"coremltools-component-torch", "2.5.1"}, {"coremltools-source-dialect", "TorchScript"}, {"coremltools-version", "8.3.0"}})]
{
func main<ios17>(tensor<fp32, [1, ?]> waveform) [FlexibleShapeInformation = tuple<tuple<tensor<string, []>, dict<tensor<string, []>, tensor<int32, [?]>>>, tuple<tensor<string, []>, dict<tensor<string, []>, list<tensor<int32, [2]>, ?>>>>((("DefaultShapes", {{"waveform", [1, 88747]}}), ("RangeDims", {{"waveform", [[1, 1], [3200, 480000]]}})))] {
tensor<fp32, [560]> cmvn_inv_std = const()[name = tensor<string, []>("cmvn_inv_std"), val = tensor<fp32, [560]>(BLOBFILE(path = tensor<string, []>("@model_path/weights/weight.bin"), offset = tensor<uint64, []>(64)))];
tensor<fp32, [560]> cmvn_neg_mean = const()[name = tensor<string, []>("cmvn_neg_mean"), val = tensor<fp32, [560]>(BLOBFILE(path = tensor<string, []>("@model_path/weights/weight.bin"), offset = tensor<uint64, []>(2368)))];
tensor<fp32, [560, 80, 7]> lfr_kernel = const()[name = tensor<string, []>("lfr_kernel"), val = tensor<fp32, [560, 80, 7]>(BLOBFILE(path = tensor<string, []>("@model_path/weights/weight.bin"), offset = tensor<uint64, []>(4672)))];
tensor<fp32, [400]> window = const()[name = tensor<string, []>("window"), val = tensor<fp32, [400]>(BLOBFILE(path = tensor<string, []>("@model_path/weights/weight.bin"), offset = tensor<uint64, []>(1259136)))];
tensor<fp32, [400, 1, 400]> frame_kernel = const()[name = tensor<string, []>("frame_kernel"), val = tensor<fp32, [400, 1, 400]>(BLOBFILE(path = tensor<string, []>("@model_path/weights/weight.bin"), offset = tensor<uint64, []>(1260800)))];
tensor<int32, [1]> var_11_axes_0 = const()[name = tensor<string, []>("op_11_axes_0"), val = tensor<int32, [1]>([1])];
tensor<fp32, [1, 1, ?]> var_11 = expand_dims(axes = var_11_axes_0, x = waveform)[name = tensor<string, []>("op_11")];
tensor<string, []> var_27_pad_type_0 = const()[name = tensor<string, []>("op_27_pad_type_0"), val = tensor<string, []>("valid")];
tensor<int32, [1]> var_27_strides_0 = const()[name = tensor<string, []>("op_27_strides_0"), val = tensor<int32, [1]>([160])];
tensor<int32, [2]> var_27_pad_0 = const()[name = tensor<string, []>("op_27_pad_0"), val = tensor<int32, [2]>([0, 0])];
tensor<int32, [1]> var_27_dilations_0 = const()[name = tensor<string, []>("op_27_dilations_0"), val = tensor<int32, [1]>([1])];
tensor<int32, []> var_27_groups_0 = const()[name = tensor<string, []>("op_27_groups_0"), val = tensor<int32, []>(1)];
tensor<fp32, [1, 400, ?]> var_27 = conv(dilations = var_27_dilations_0, groups = var_27_groups_0, pad = var_27_pad_0, pad_type = var_27_pad_type_0, strides = var_27_strides_0, weight = frame_kernel, x = var_11)[name = tensor<string, []>("op_27")];
tensor<int32, [3]> var_30_begin_0 = const()[name = tensor<string, []>("op_30_begin_0"), val = tensor<int32, [3]>([0, 0, 0])];
tensor<int32, [3]> var_30_end_0 = const()[name = tensor<string, []>("op_30_end_0"), val = tensor<int32, [3]>([1, 400, 0])];
tensor<bool, [3]> var_30_end_mask_0 = const()[name = tensor<string, []>("op_30_end_mask_0"), val = tensor<bool, [3]>([false, true, true])];
tensor<bool, [3]> var_30_squeeze_mask_0 = const()[name = tensor<string, []>("op_30_squeeze_mask_0"), val = tensor<bool, [3]>([true, false, false])];
tensor<fp32, [400, ?]> var_30 = slice_by_index(begin = var_30_begin_0, end = var_30_end_0, end_mask = var_30_end_mask_0, squeeze_mask = var_30_squeeze_mask_0, x = var_27)[name = tensor<string, []>("op_30")];
tensor<int32, [2]> frames_1_perm_0 = const()[name = tensor<string, []>("frames_1_perm_0"), val = tensor<int32, [2]>([1, 0])];
tensor<int32, [1]> var_36_axes_0 = const()[name = tensor<string, []>("op_36_axes_0"), val = tensor<int32, [1]>([1])];
tensor<bool, []> var_36_keep_dims_0 = const()[name = tensor<string, []>("op_36_keep_dims_0"), val = tensor<bool, []>(true)];
tensor<fp32, [?, 400]> frames_1 = transpose(perm = frames_1_perm_0, x = var_30)[name = tensor<string, []>("transpose_5")];
tensor<fp32, [?, 1]> var_36 = reduce_mean(axes = var_36_axes_0, keep_dims = var_36_keep_dims_0, x = frames_1)[name = tensor<string, []>("op_36")];
tensor<fp32, [?, 400]> frames_3 = sub(x = frames_1, y = var_36)[name = tensor<string, []>("frames_3")];
tensor<int32, [2]> var_48_begin_0 = const()[name = tensor<string, []>("op_48_begin_0"), val = tensor<int32, [2]>([0, 0])];
tensor<int32, [2]> var_48_end_0 = const()[name = tensor<string, []>("op_48_end_0"), val = tensor<int32, [2]>([0, 1])];
tensor<bool, [2]> var_48_end_mask_0 = const()[name = tensor<string, []>("op_48_end_mask_0"), val = tensor<bool, [2]>([true, false])];
tensor<fp32, [?, 1]> var_48 = slice_by_index(begin = var_48_begin_0, end = var_48_end_0, end_mask = var_48_end_mask_0, x = frames_3)[name = tensor<string, []>("op_48")];
tensor<int32, [2]> var_58_begin_0 = const()[name = tensor<string, []>("op_58_begin_0"), val = tensor<int32, [2]>([0, 0])];
tensor<int32, [2]> var_58_end_0 = const()[name = tensor<string, []>("op_58_end_0"), val = tensor<int32, [2]>([0, 399])];
tensor<bool, [2]> var_58_end_mask_0 = const()[name = tensor<string, []>("op_58_end_mask_0"), val = tensor<bool, [2]>([true, false])];
tensor<fp32, [?, 399]> var_58 = slice_by_index(begin = var_58_begin_0, end = var_58_end_0, end_mask = var_58_end_mask_0, x = frames_3)[name = tensor<string, []>("op_58")];
tensor<int32, []> var_60 = const()[name = tensor<string, []>("op_60"), val = tensor<int32, []>(1)];
tensor<bool, []> shifted_interleave_0 = const()[name = tensor<string, []>("shifted_interleave_0"), val = tensor<bool, []>(false)];
tensor<fp32, [?, 400]> shifted = concat(axis = var_60, interleave = shifted_interleave_0, values = (var_48, var_58))[name = tensor<string, []>("shifted")];
tensor<fp32, []> var_62 = const()[name = tensor<string, []>("op_62"), val = tensor<fp32, []>(0x1.f0a3d8p-1)];
tensor<fp32, [?, 400]> var_63 = mul(x = shifted, y = var_62)[name = tensor<string, []>("op_63")];
tensor<fp32, [?, 400]> frames_5 = sub(x = frames_3, y = var_63)[name = tensor<string, []>("frames_5")];
tensor<fp32, [?, 400]> input = mul(x = frames_5, y = window)[name = tensor<string, []>("input")];
tensor<fp32, []> const_0 = const()[name = tensor<string, []>("const_0"), val = tensor<fp32, []>(0x0p+0)];
tensor<int32, [4]> frames_pad_0 = const()[name = tensor<string, []>("frames_pad_0"), val = tensor<int32, [4]>([0, 0, 0, 112])];
tensor<string, []> frames_mode_0 = const()[name = tensor<string, []>("frames_mode_0"), val = tensor<string, []>("constant")];
tensor<fp32, [?, 512]> frames = pad(constant_val = const_0, mode = frames_mode_0, pad = frames_pad_0, x = input)[name = tensor<string, []>("frames")];
tensor<fp32, [257, 512]> transpose_0 = const()[name = tensor<string, []>("transpose_0"), val = tensor<fp32, [257, 512]>(BLOBFILE(path = tensor<string, []>("@model_path/weights/weight.bin"), offset = tensor<uint64, []>(1900864)))];
tensor<fp32, [257]> re_bias_0 = const()[name = tensor<string, []>("re_bias_0"), val = tensor<fp32, [257]>(BLOBFILE(path = tensor<string, []>("@model_path/weights/weight.bin"), offset = tensor<uint64, []>(2427264)))];
tensor<fp32, [?, 257]> re = linear(bias = re_bias_0, weight = transpose_0, x = frames)[name = tensor<string, []>("re")];
tensor<fp32, [257, 512]> transpose_1 = const()[name = tensor<string, []>("transpose_1"), val = tensor<fp32, [257, 512]>(BLOBFILE(path = tensor<string, []>("@model_path/weights/weight.bin"), offset = tensor<uint64, []>(2428416)))];
tensor<fp32, [?, 257]> im = linear(bias = re_bias_0, weight = transpose_1, x = frames)[name = tensor<string, []>("im")];
tensor<fp32, [?, 257]> var_75 = mul(x = re, y = re)[name = tensor<string, []>("op_75")];
tensor<fp32, [?, 257]> var_76 = mul(x = im, y = im)[name = tensor<string, []>("op_76")];
tensor<fp32, [?, 257]> power = add(x = var_75, y = var_76)[name = tensor<string, []>("power")];
tensor<fp32, [80, 257]> transpose_2 = const()[name = tensor<string, []>("transpose_2"), val = tensor<fp32, [80, 257]>(BLOBFILE(path = tensor<string, []>("@model_path/weights/weight.bin"), offset = tensor<uint64, []>(2954816)))];
tensor<fp32, [80]> mel_energies_bias_0 = const()[name = tensor<string, []>("mel_energies_bias_0"), val = tensor<fp32, [80]>(BLOBFILE(path = tensor<string, []>("@model_path/weights/weight.bin"), offset = tensor<uint64, []>(3037120)))];
tensor<fp32, [?, 80]> mel_energies = linear(bias = mel_energies_bias_0, weight = transpose_2, x = power)[name = tensor<string, []>("mel_energies")];
tensor<fp32, []> var_80 = const()[name = tensor<string, []>("op_80"), val = tensor<fp32, []>(0x1p-23)];
tensor<fp32, []> const_1 = const()[name = tensor<string, []>("const_1"), val = tensor<fp32, []>(0x1.fffffep+127)];
tensor<fp32, [?, 80]> clip_0 = clip(alpha = var_80, beta = const_1, x = mel_energies)[name = tensor<string, []>("clip_0")];
tensor<fp32, []> fbank_1_epsilon_0 = const()[name = tensor<string, []>("fbank_1_epsilon_0"), val = tensor<fp32, []>(0x1p-149)];
tensor<fp32, [?, 80]> fbank_1 = log(epsilon = fbank_1_epsilon_0, x = clip_0)[name = tensor<string, []>("fbank_1")];
tensor<int32, [2]> var_88_begin_0 = const()[name = tensor<string, []>("op_88_begin_0"), val = tensor<int32, [2]>([0, 0])];
tensor<int32, [2]> var_88_end_0 = const()[name = tensor<string, []>("op_88_end_0"), val = tensor<int32, [2]>([1, 80])];
tensor<bool, [2]> var_88_end_mask_0 = const()[name = tensor<string, []>("op_88_end_mask_0"), val = tensor<bool, [2]>([false, true])];
tensor<fp32, [1, 80]> var_88 = slice_by_index(begin = var_88_begin_0, end = var_88_end_0, end_mask = var_88_end_mask_0, x = fbank_1)[name = tensor<string, []>("op_88")];
tensor<int32, [2]> var_91 = const()[name = tensor<string, []>("op_91"), val = tensor<int32, [2]>([3, 1])];
tensor<fp32, [3, 80]> var_92 = tile(reps = var_91, x = var_88)[name = tensor<string, []>("op_92")];
tensor<int32, [2]> var_97_begin_0 = const()[name = tensor<string, []>("op_97_begin_0"), val = tensor<int32, [2]>([-1, 0])];
tensor<int32, [2]> var_97_end_0 = const()[name = tensor<string, []>("op_97_end_0"), val = tensor<int32, [2]>([0, 80])];
tensor<bool, [2]> var_97_end_mask_0 = const()[name = tensor<string, []>("op_97_end_mask_0"), val = tensor<bool, [2]>([true, true])];
tensor<fp32, [1, 80]> var_97 = slice_by_index(begin = var_97_begin_0, end = var_97_end_0, end_mask = var_97_end_mask_0, x = fbank_1)[name = tensor<string, []>("op_97")];
tensor<int32, [2]> var_100 = const()[name = tensor<string, []>("op_100"), val = tensor<int32, [2]>([7, 1])];
tensor<fp32, [7, 80]> var_101 = tile(reps = var_100, x = var_97)[name = tensor<string, []>("op_101")];
tensor<int32, []> var_103 = const()[name = tensor<string, []>("op_103"), val = tensor<int32, []>(0)];
tensor<bool, []> fbank_interleave_0 = const()[name = tensor<string, []>("fbank_interleave_0"), val = tensor<bool, []>(false)];
tensor<fp32, [?, 80]> fbank = concat(axis = var_103, interleave = fbank_interleave_0, values = (var_92, fbank_1, var_101))[name = tensor<string, []>("fbank")];
tensor<int32, [2]> var_105_perm_0 = const()[name = tensor<string, []>("op_105_perm_0"), val = tensor<int32, [2]>([1, 0])];
tensor<int32, [1]> var_107_axes_0 = const()[name = tensor<string, []>("op_107_axes_0"), val = tensor<int32, [1]>([0])];
tensor<fp32, [80, ?]> var_105 = transpose(perm = var_105_perm_0, x = fbank)[name = tensor<string, []>("transpose_4")];
tensor<fp32, [1, 80, ?]> var_107 = expand_dims(axes = var_107_axes_0, x = var_105)[name = tensor<string, []>("op_107")];
tensor<string, []> var_123_pad_type_0 = const()[name = tensor<string, []>("op_123_pad_type_0"), val = tensor<string, []>("valid")];
tensor<int32, [1]> var_123_strides_0 = const()[name = tensor<string, []>("op_123_strides_0"), val = tensor<int32, [1]>([6])];
tensor<int32, [2]> var_123_pad_0 = const()[name = tensor<string, []>("op_123_pad_0"), val = tensor<int32, [2]>([0, 0])];
tensor<int32, [1]> var_123_dilations_0 = const()[name = tensor<string, []>("op_123_dilations_0"), val = tensor<int32, [1]>([1])];
tensor<int32, []> var_123_groups_0 = const()[name = tensor<string, []>("op_123_groups_0"), val = tensor<int32, []>(1)];
tensor<fp32, [1, 560, ?]> var_123 = conv(dilations = var_123_dilations_0, groups = var_123_groups_0, pad = var_123_pad_0, pad_type = var_123_pad_type_0, strides = var_123_strides_0, weight = lfr_kernel, x = var_107)[name = tensor<string, []>("op_123")];
tensor<int32, [3]> var_126_begin_0 = const()[name = tensor<string, []>("op_126_begin_0"), val = tensor<int32, [3]>([0, 0, 0])];
tensor<int32, [3]> var_126_end_0 = const()[name = tensor<string, []>("op_126_end_0"), val = tensor<int32, [3]>([1, 560, 0])];
tensor<bool, [3]> var_126_end_mask_0 = const()[name = tensor<string, []>("op_126_end_mask_0"), val = tensor<bool, [3]>([false, true, true])];
tensor<bool, [3]> var_126_squeeze_mask_0 = const()[name = tensor<string, []>("op_126_squeeze_mask_0"), val = tensor<bool, [3]>([true, false, false])];
tensor<fp32, [560, ?]> var_126 = slice_by_index(begin = var_126_begin_0, end = var_126_end_0, end_mask = var_126_end_mask_0, squeeze_mask = var_126_squeeze_mask_0, x = var_123)[name = tensor<string, []>("op_126")];
tensor<int32, [2]> lfr_perm_0 = const()[name = tensor<string, []>("lfr_perm_0"), val = tensor<int32, [2]>([1, 0])];
tensor<fp32, [?, 560]> lfr = transpose(perm = lfr_perm_0, x = var_126)[name = tensor<string, []>("transpose_3")];
tensor<fp32, [?, 560]> var_129 = add(x = lfr, y = cmvn_neg_mean)[name = tensor<string, []>("op_129")];
tensor<fp32, [?, 560]> feats = mul(x = var_129, y = cmvn_inv_std)[name = tensor<string, []>("feats")];
tensor<int32, [1]> var_132_axes_0 = const()[name = tensor<string, []>("op_132_axes_0"), val = tensor<int32, [1]>([0])];
tensor<fp32, [1, ?, 560]> features = expand_dims(axes = var_132_axes_0, x = feats)[name = tensor<string, []>("op_132")];
} -> (features);
}