Sundaydream's picture
Core ML conversion of Confucius4-R2T2 for the Apple Neural Engine
ad8b997 verified
Raw History Blame Contribute Delete
4.52 kB
program(1.3)
[buildInfo = dict<string, string>({{"coremlc-component-MIL", "3520.4.1"}, {"coremlc-version", "3520.5.1.2"}})]
{
func main<ios18>(tensor<fp16, [1, 64, 2048]> hidden) {
tensor<fp16, [1, 64, 2048]> var_4_cast_fp16 = abs(x = hidden)[name = string("op_4_cast_fp16")];
bool var_7 = const()[name = string("op_7"), val = bool(true)];
tensor<int32, [1]> var_8_axes_0 = const()[name = string("op_8_axes_0"), val = tensor<int32, [1]>([-1])];
tensor<fp16, [1, 64, 1]> var_8_cast_fp16 = reduce_max(axes = var_8_axes_0, keep_dims = var_7, x = var_4_cast_fp16)[name = string("op_8_cast_fp16")];
fp16 var_9_to_fp16 = const()[name = string("op_9_to_fp16"), val = fp16(0x1.47cp-7)];
fp16 const_0_to_fp16 = const()[name = string("const_0_to_fp16"), val = fp16(inf)];
tensor<fp16, [1, 64, 1]> clip_0_cast_fp16 = clip(alpha = var_9_to_fp16, beta = const_0_to_fp16, x = var_8_cast_fp16)[name = string("clip_0_cast_fp16")];
tensor<fp16, [1, 64, 2048]> y_cast_fp16 = real_div(x = hidden, y = clip_0_cast_fp16)[name = string("y_cast_fp16")];
tensor<fp16, [1, 64, 2048]> var_13_cast_fp16 = mul(x = y_cast_fp16, y = y_cast_fp16)[name = string("op_13_cast_fp16")];
tensor<int32, [1]> var_18_axes_0 = const()[name = string("op_18_axes_0"), val = tensor<int32, [1]>([-1])];
bool var_18_keep_dims_0 = const()[name = string("op_18_keep_dims_0"), val = bool(true)];
tensor<fp16, [1, 64, 1]> var_18_cast_fp16 = reduce_mean(axes = var_18_axes_0, keep_dims = var_18_keep_dims_0, x = var_13_cast_fp16)[name = string("op_18_cast_fp16")];
tensor<fp16, [1, 64, 1]> var_19_cast_fp16 = mul(x = clip_0_cast_fp16, y = clip_0_cast_fp16)[name = string("op_19_cast_fp16")];
fp32 var_20_epsilon_0 = const()[name = string("op_20_epsilon_0"), val = fp32(0x1.a36e2ep-14)];
tensor<fp16, [1, 64, 1]> var_20_cast_fp16 = inverse(epsilon = var_20_epsilon_0, x = var_19_cast_fp16)[name = string("op_20_cast_fp16")];
fp16 var_21_to_fp16 = const()[name = string("op_21_to_fp16"), val = fp16(0x1.1p-20)];
tensor<fp16, [1, 64, 1]> var_22_cast_fp16 = mul(x = var_20_cast_fp16, y = var_21_to_fp16)[name = string("op_22_cast_fp16")];
tensor<fp16, [1, 64, 1]> var_24_cast_fp16 = add(x = var_18_cast_fp16, y = var_22_cast_fp16)[name = string("op_24_cast_fp16")];
fp32 var_25_epsilon_0 = const()[name = string("op_25_epsilon_0"), val = fp32(0x1.197998p-40)];
tensor<fp16, [1, 64, 1]> var_25_cast_fp16 = rsqrt(epsilon = var_25_epsilon_0, x = var_24_cast_fp16)[name = string("op_25_cast_fp16")];
tensor<fp16, [1, 64, 2048]> var_26_cast_fp16 = mul(x = y_cast_fp16, y = var_25_cast_fp16)[name = string("op_26_cast_fp16")];
tensor<fp16, [2048]> norm_to_fp16 = const()[name = string("norm_to_fp16"), val = tensor<fp16, [2048]>(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(64)))];
tensor<fp16, [1, 64, 2048]> input_cast_fp16 = mul(x = var_26_cast_fp16, y = norm_to_fp16)[name = string("input_cast_fp16")];
tensor<fp16, [151936, 2048]> lm_head_weight_to_fp16_quantized = constexpr_blockwise_shift_scale(data = tensor<int8, [151936, 2048]>(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(4224))), scale = tensor<fp16, [151936, 1]>(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(311169216))))[name = string("lm_head_weight_to_fp16_quantized")];
tensor<fp16, [151936]> linear_0_bias_0_to_fp16 = const()[name = string("linear_0_bias_0_to_fp16"), val = tensor<fp16, [151936]>(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(311473152)))];
tensor<fp16, [1, 64, 151936]> linear_0_cast_fp16 = linear(bias = linear_0_bias_0_to_fp16, weight = lm_head_weight_to_fp16_quantized, x = input_cast_fp16)[name = string("linear_0_cast_fp16")];
int32 var_33_axis_0 = const()[name = string("op_33_axis_0"), val = int32(-1)];
bool var_33_keep_dims_0 = const()[name = string("op_33_keep_dims_0"), val = bool(false)];
string var_33_output_dtype_0 = const()[name = string("op_33_output_dtype_0"), val = string("int32")];
tensor<int32, [1, 64]> ids = reduce_argmax(axis = var_33_axis_0, keep_dims = var_33_keep_dims_0, output_dtype = var_33_output_dtype_0, x = linear_0_cast_fp16)[name = string("op_33_cast_fp16")];
} -> (ids);
}