| 915 | |
| 916 | |
| 917 | def __dynamic_template_api(input_x, input_gamma, input_beta, output_y, output_mean, output_variance, |
| 918 | begin_norm_axis, begin_params_axis, epsilon, kernel_name, impl_mode): |
| 919 | # when all reduce axis, or reduce axis non aligned or reduced mte data less one block etc. single-core cases will |
| 920 | # transfer dynamic template to use multi-core |
| 921 | input_x, input_gamma, input_beta = layer_norm_unify.set_range(input_x, input_gamma, input_beta) |
| 922 | context_ops = tbe_context.op_context.get_context() |
| 923 | if context_ops is not None: |
| 924 | context_ops.set_op_mode("static") |
| 925 | context_ops.add_addition("is_static", True) |
| 926 | dyn.layer_norm(input_x, input_gamma, input_beta, |
| 927 | output_y, output_mean, output_variance, |
| 928 | begin_norm_axis, begin_params_axis, |
| 929 | epsilon, kernel_name, impl_mode) |
| 930 | else: |
| 931 | with tbe_context.op_context.OpContext("static"): |
| 932 | tbe_context.op_context.get_context().add_addition("is_static", True) |
| 933 | dyn.layer_norm(input_x, input_gamma, input_beta, |
| 934 | output_y, output_mean, output_variance, |
| 935 | begin_norm_axis, begin_params_axis, |
| 936 | epsilon, kernel_name, impl_mode) |