Home
last modified time | relevance | path

Searched refs:graph_builder (Results 1 – 25 of 56) sorted by relevance

123

/third_party/mindspore/mindspore/_extends/graph_kernel/expanders/
Dlayernorm_grad.py25 def _expand(self, graph_builder): argument
34 x = graph_builder.emit('Cast', [x], attrs={'dst_type': 'float32'})
35 dy = graph_builder.emit('Cast', [dy], attrs={'dst_type': 'float32'})
36 variance = graph_builder.emit('Cast', [variance], attrs={'dst_type': 'float32'})
37 mean = graph_builder.emit('Cast', [mean], attrs={'dst_type': 'float32'})
38 gamma = graph_builder.emit('Cast', [gamma], attrs={'dst_type': 'float32'})
53 eps = graph_builder.value(x.dtype, epsilon)
54 const_neg_half = graph_builder.value(x.dtype, -0.5)
55 const_neg_two = graph_builder.value(x.dtype, -2.0)
56 const_two = graph_builder.value(x.dtype, 2.0)
[all …]
Dlamb_apply_optimizer_assign.py23 def _expand(self, graph_builder): argument
29 square_grad = graph_builder.emit('Mul', [grad, grad])
30 mul_3_result = graph_builder.emit('Mul', [square_grad, one_minus_beta_2])
31 mul_2_result = graph_builder.emit('Mul', [inputv, beta_2])
32 next_v = graph_builder.emit('Add', [mul_2_result, mul_3_result])
35 mul_0_result = graph_builder.emit('Mul', [inputm, beta_1])
36 mul_1_result = graph_builder.emit('Mul', [grad, one_minus_beta_1])
37 next_m = graph_builder.emit('Add', [mul_0_result, mul_1_result])
40 const_one = graph_builder.value(beta_2.dtype, 1)
42 beta_1_tensor = graph_builder.emit('BroadcastTo', [beta_1], attrs={'shape': shape})
[all …]
Dbatchnorm.py28 def _expand(self, graph_builder): argument
35 epsilon_v = graph_builder.value(input_scale.dtype, self.attrs['epsilon'])
43 input_x = graph_builder.emit('Cast', [input_x], attrs={'dst_type': input_x_new_type})
47 res_y, mean_res, variance_res, mean_muls, y_sqrt_rec = self._bn_train(graph_builder)
49 res_y = graph_builder.emit('Cast', [res_y], attrs={'dst_type': input_x_ori_type})
53 input_mean = graph_builder.emit(
55 input_scale = graph_builder.emit(
57 input_offset = graph_builder.emit(
59 x_sub = graph_builder.emit('Sub', [input_x, input_mean])
60 x_sub_mul = graph_builder.emit('Mul', [input_scale, x_sub])
[all …]
Dgelu_grad.py26 def _expand(self, graph_builder): argument
36 const_csvalue = graph_builder.value(input_dy.dtype, self.CSVALUE)
37 … const_csvalue_sqrt_two_div_pi = graph_builder.value(input_dy.dtype, self.CSVALUE_SQRT_TWO_DIV_PI)
38 const_csvalue_tri = graph_builder.value(input_dy.dtype, self.CSVALUE_TRI)
39 const_one = graph_builder.value(input_dy.dtype, 1)
40 const_half = graph_builder.value(input_dy.dtype, 0.5)
43 mul_double = graph_builder.emit('Mul', [input_x, input_x])
44 mul_double_mul_tri = graph_builder.emit('Mul', [const_csvalue_tri, mul_double])
45 mul_add_one = graph_builder.emit('Add', [const_one, mul_double_mul_tri])
46 mul_right = graph_builder.emit('Mul', [const_csvalue_sqrt_two_div_pi, mul_add_one])
[all …]
Dlamb_apply_weight_assign.py23 def _expand(self, graph_builder): argument
30 data_min = graph_builder.value(dtype, 2**(-126))
32 data_min = graph_builder.value(dtype, 2*(-24))
36 const_zero = graph_builder.value(dtype, 0)
37 const_one = graph_builder.value(dtype, 1)
42 g_norm_greater_res = graph_builder.emit('Greater', [g_norm, const_zero])
43 g_norm_res = graph_builder.emit('Cast', [g_norm_greater_res], attrs={'dst_type': dtype})
45 g_norm = graph_builder.emit('Add', [g_norm, data_min])
46 w_norm_g_norm = graph_builder.emit('RealDiv', [w_norm, g_norm])
48 g_norm_value_1 = graph_builder.emit('Mul', [g_norm_res, w_norm_g_norm])
[all …]
Dbatchnorm_grad.py28 def _expand(self, graph_builder): argument
46 input_x = graph_builder.emit('Cast', [input_x], attrs={'dst_type': 'float32'})
48 input_dy = graph_builder.emit('Cast', [input_dy], attrs={'dst_type': 'float32'})
50 num_rec_v = graph_builder.value(input_scale.dtype, num_rec)
51 …dbeta = graph_builder.emit('ReduceSum', [input_dy], attrs={'reduce_axis': reduce_axis, 'keep_dims'…
57 epsilon_v = graph_builder.value(input_scale.dtype, self.attrs['epsilon'])
58 var_add = graph_builder.emit('Add', [input_save_inv_variance, epsilon_v])
59 sqrt_var_eps = graph_builder.emit('Sqrt', [var_add])
61 scalar_one_v = graph_builder.value(input_scale.dtype, scalar_one)
62 inv_variance = graph_builder.emit('RealDiv', [scalar_one_v, sqrt_var_eps])
[all …]
Dfused_adam_weight_decay.py23 def _expand(self, graph_builder): argument
27 beta_1_mul_m = graph_builder.emit('Mul', [beta_1, m])
28 one_sub_beta_1_mul_grad = graph_builder.emit('Mul', [one_sub_beta_1, gradient])
29 next_m = graph_builder.emit('Add', [beta_1_mul_m, one_sub_beta_1_mul_grad])
30 beta_2_mul_v = graph_builder.emit('Mul', [beta_2, v])
31 grad_square = graph_builder.emit('Mul', [gradient, gradient])
32 one_sub_beta_2_mul_grad_square = graph_builder.emit('Mul', [one_sub_beta_2, grad_square])
33 next_v = graph_builder.emit('Add', [beta_2_mul_v, one_sub_beta_2_mul_grad_square])
34 sqrt_next_v = graph_builder.emit('Sqrt', [next_v])
35 sqrt_next_v_add_eps = graph_builder.emit('Add', [sqrt_next_v, eps])
[all …]
Dlayernorm.py27 def _expand(self, graph_builder): argument
35 input_x = graph_builder.emit('Cast', [input_x], attrs={'dst_type': 'float32'})
36 input_gamma = graph_builder.emit('Cast', [input_gamma], attrs={'dst_type': 'float32'})
37 input_beta = graph_builder.emit('Cast', [input_beta], attrs={'dst_type': 'float32'})
62 mean_cof_v = graph_builder.value(input_x.dtype, mean_cof)
65 mean_red = graph_builder.emit('ReduceSum', [input_x],
67 mean = graph_builder.emit('Mul', [mean_red, mean_cof_v])
69 mean = graph_builder.emit('Reshape', [mean], attrs={'shape': ori_reduced_shape_x})
72 variance_sub = graph_builder.emit('Sub', [input_x, mean])
73 variance_mul = graph_builder.emit('Mul', [variance_sub, variance_sub])
[all …]
Dfused_adam.py23 def _expand(self, graph_builder): argument
26 beta_1_mul_m = graph_builder.emit('Mul', [beta_1, m])
27 one_sub_beta_1_mul_grad = graph_builder.emit('Mul', [one_sub_beta_1, gradient])
28 next_m = graph_builder.emit('Add', [beta_1_mul_m, one_sub_beta_1_mul_grad])
29 beta_2_mul_v = graph_builder.emit('Mul', [beta_2, v])
30 grad_square = graph_builder.emit('Mul', [gradient, gradient])
31 one_sub_beta_2_mul_grad_square = graph_builder.emit('Mul', [one_sub_beta_2, grad_square])
32 next_v = graph_builder.emit('Add', [beta_2_mul_v, one_sub_beta_2_mul_grad_square])
33 sqrt_next_v = graph_builder.emit('Sqrt', [next_v])
34 sqrt_next_v_add_eps = graph_builder.emit('Add', [sqrt_next_v, eps])
[all …]
Dgelu.py24 def _expand(self, graph_builder): argument
32 mul_0 = graph_builder.emit('Mul', [input_x, input_x])
33 pow_0 = graph_builder.emit('Mul', [mul_0, input_x])
34 const_csvalue = graph_builder.value(pow_0.dtype, self.CSVALUE)
35 mul_1 = graph_builder.emit('Mul', [pow_0, const_csvalue])
36 tanh_res = graph_builder.emit('Add', [input_x, mul_1])
37 … const_csvalue_sqrt_two_div_pi = graph_builder.value(tanh_res.dtype, self.CSVALUE_SQRT_TWO_DIV_PI)
38 y = graph_builder.emit('Mul', [tanh_res, const_csvalue_sqrt_two_div_pi])
41 tanh_y = graph_builder.emit('Tanh', [y])
42 const_one = graph_builder.value(tanh_y.dtype, 1)
[all …]
Dsoftmax_cross_entropy_with_logits.py24 def _expand(self, graph_builder): argument
29 … max_x = graph_builder.emit('ReduceMax', [logits], attrs={'reduce_axis': axis, 'keep_dims': True})
30 data_sub = graph_builder.emit('Sub', [logits, max_x])
31 data_exp = graph_builder.emit('Exp', [data_sub])
32 …data_expsum = graph_builder.emit('ReduceSum', [data_exp], attrs={'reduce_axis': axis, 'keep_dims':…
33 data_softmax = graph_builder.emit('RealDiv', [data_exp, data_expsum])
34 const_eps = graph_builder.value(logits.dtype, 0.000001)
35 data_softmax_safety = graph_builder.emit("Maximum", [data_softmax, const_eps])
36 softmax_log = graph_builder.emit('Log', [data_softmax_safety])
37 label_mul_log = graph_builder.emit('Mul', [label, softmax_log])
[all …]
Dsigmoid_cross_entropy_with_logits.py23 def _expand(self, graph_builder): argument
30 const_one = graph_builder.value(logits.dtype, 1.0)
31 const_zero = graph_builder.value(logits.dtype, 0.0)
32 max_logits = graph_builder.emit('Maximum', [logits, const_zero])
33 logits_mul_labels = graph_builder.emit('Mul', [logits, labels])
34 abs_logits = graph_builder.emit('Abs', [logits])
35 neg_abs_logits = graph_builder.emit('Neg', [abs_logits])
36 exp_neg_abs_logits = graph_builder.emit('Exp', [neg_abs_logits])
37 one_add_exp_neg_abs_logits = graph_builder.emit('Add', [const_one, exp_neg_abs_logits])
38 log_one_add_exp_neg_abs_logits = graph_builder.emit('Log', [one_add_exp_neg_abs_logits])
[all …]
Dsoftmax.py27 def _expand(self, graph_builder): argument
47 input_x_f16 = graph_builder.emit('Cast', [input_x], attrs={'dst_type': 'float16'})
48 …max_x_f16 = graph_builder.emit('ReduceMax', [input_x_f16], attrs={'reduce_axis': axis, 'keep_dims'…
49 max_x = graph_builder.emit('Cast', [max_x_f16], attrs={'dst_type': ori_dtype})
51 … max_x = graph_builder.emit('ReduceMax', [input_x], attrs={'reduce_axis': axis, 'keep_dims': True})
54 max_x = graph_builder.emit('Cast', [max_x], attrs={'dst_type': "float32"})
55 input_x = graph_builder.emit('Cast', [input_x], attrs={'dst_type': "float32"})
58 max_x = graph_builder.emit('Reshape', [max_x], attrs={'shape': ori_reduced_shape})
59 data_sub = graph_builder.emit('Sub', [input_x, max_x])
60 data_exp = graph_builder.emit('Exp', [data_sub])
[all …]
Derfc.py22 def _expand(self, graph_builder): argument
26 const_one = graph_builder.value("float32", 1)
27 input_x = graph_builder.emit('Cast', [input_x], attrs={'dst_type': "float32"})
28 erf_result = graph_builder.emit('Erf', [input_x])
29 result = graph_builder.emit('Sub', [const_one, erf_result])
30 result = graph_builder.emit('Cast', [result], attrs={'dst_type': "float16"})
32 const_one = graph_builder.value(input_x.dtype, 1)
33 erf_result = graph_builder.emit('Erf', [input_x])
34 result = graph_builder.emit('Sub', [const_one, erf_result])
Dlogsoftmax.py25 def _expand(self, graph_builder): argument
35 input_x_f16 = graph_builder.emit('Cast', [input_x], attrs={'dst_type': 'float16'})
36 …max_x_f16 = graph_builder.emit('ReduceMax', [input_x_f16], attrs={'reduce_axis': axis, 'keep_dims'…
37 max_x = graph_builder.emit('Cast', [max_x_f16], attrs={'dst_type': ori_dtype})
39 … max_x = graph_builder.emit('ReduceMax', [input_x], attrs={'reduce_axis': axis, 'keep_dims': True})
40 data_sub = graph_builder.emit('Sub', [input_x, max_x])
41 data_exp = graph_builder.emit('Exp', [data_sub])
42 …data_expsum = graph_builder.emit('ReduceSum', [data_exp], attrs={'reduce_axis': axis, 'keep_dims':…
43 log_expsum = graph_builder.emit('Log', [data_expsum])
44 result = graph_builder.emit('Sub', [data_sub, log_expsum])
Dsigmoid_cross_entropy_with_logits_grad.py23 def _expand(self, graph_builder): argument
28 const_one = graph_builder.value(logits.dtype, 1.0)
29 neg_x = graph_builder.emit('Neg', [logits])
30 exp_neg_x = graph_builder.emit('Exp', [neg_x])
31 add_exp = graph_builder.emit('Add', [const_one, exp_neg_x])
32 sigmoid_res = graph_builder.emit('RealDiv', [const_one, add_exp])
33 sigmoid_res_sub_label = graph_builder.emit('Sub', [sigmoid_res, label])
34 res = graph_builder.emit('Mul', [sigmoid_res_sub_label, dout])
Dgkdropout.py24 def _expand(self, graph_builder): argument
28 r_keep_prob = graph_builder.value(input_x.dtype, 1.0 / keep_prob)
29 keep_prob = graph_builder.value(input_x.dtype, keep_prob)
32 input_mask = graph_builder.emit('Cast', [input_mask], attrs={'dst_type': input_x.dtype})
33 mask = graph_builder.emit('LessEqual', [input_mask, keep_prob]) # output is bool type
34 mask = graph_builder.emit('Cast', [mask], attrs={'dst_type': input_x.dtype})
37 result = graph_builder.emit('Mul', [r_keep_prob, input_x])
38 result = graph_builder.emit('Mul', [result, mask])
Dmaximum_grad.py30 def _expand(self, graph_builder): argument
32 ge_result = graph_builder.emit('GreaterEqual', [input_x, input_y])
33 ge_result = graph_builder.emit('Cast', [ge_result], attrs={'dst_type': input_x.dtype})
34 dx = graph_builder.emit('Mul', [ge_result, input_dout])
35 dy = graph_builder.emit('Sub', [input_dout, dx])
40 …dx_reduce = graph_builder.emit('ReduceSum', [dx], attrs={'reduce_axis': reduce_axis_x, 'keep_dims'…
42 dx_out = graph_builder.emit('Reshape', [dx_reduce], attrs={'shape': input_x.shape})
49 …dy_reduce = graph_builder.emit('ReduceSum', [dy], attrs={'reduce_axis': reduce_axis_y, 'keep_dims'…
51 dy_out = graph_builder.emit('Reshape', [dy_reduce], attrs={'shape': input_y.shape})
Dminimum_grad.py29 def _expand(self, graph_builder): argument
32 le_result = graph_builder.emit('LessEqual', [input_x, input_y])
33 le_result = graph_builder.emit('Cast', [le_result], attrs={'dst_type': input_x.dtype})
34 dx = graph_builder.emit('Mul', [le_result, input_dout])
35 dy = graph_builder.emit('Sub', [input_dout, dx])
43 …dx_reduce = graph_builder.emit('ReduceSum', [dx], attrs={'reduce_axis': reduce_axis_x, 'keep_dims'…
45 dx_out = graph_builder.emit('Reshape', [dx_reduce], attrs={'shape': input_x.shape})
52 …dy_reduce = graph_builder.emit('ReduceSum', [dy], attrs={'reduce_axis': reduce_axis_y, 'keep_dims'…
54 dy_out = graph_builder.emit('Reshape', [dy_reduce], attrs={'shape': input_y.shape})
Dsigmoid.py22 def _expand(self, graph_builder): argument
26 const_one = graph_builder.value(input_x.dtype, 1.0)
27 neg_x = graph_builder.emit('Neg', [input_x])
28 exp_neg_x = graph_builder.emit('Exp', [neg_x])
29 add_exp = graph_builder.emit('Add', [const_one, exp_neg_x])
30 res = graph_builder.emit('RealDiv', [const_one, add_exp])
/third_party/mindspore/mindspore/_extends/graph_kernel/expanders/complex/
Ddiv.py24 def _expand(self, graph_builder): argument
27 x_real = graph_builder.emit('CReal', [input_x])
28 y_real = graph_builder.emit('CReal', [input_y])
29 x_imag = graph_builder.emit('CImag', [input_x])
30 y_imag = graph_builder.emit('CImag', [input_y])
31 squre_y_real = graph_builder.emit('Mul', [y_real, y_real])
32 squre_y_imag = graph_builder.emit('Mul', [y_imag, y_imag])
33 final_denominator = graph_builder.emit('Add', [squre_y_real, squre_y_imag])
34 x_real_mul_y_real = graph_builder.emit('Mul', [x_real, y_real])
35 x_imag_mul_y_imag = graph_builder.emit('Mul', [x_imag, y_imag])
[all …]
Dmul.py24 def _expand(self, graph_builder): argument
27 x_real = graph_builder.emit('CReal', [input_x])
28 y_real = graph_builder.emit('CReal', [input_y])
29 x_imag = graph_builder.emit('CImag', [input_x])
30 y_imag = graph_builder.emit('CImag', [input_y])
31 x_real_mul_y_real = graph_builder.emit('Mul', [x_real, y_real])
32 x_imag_mul_y_imag = graph_builder.emit('Mul', [x_imag, y_imag])
33 x_real_mul_y_imag = graph_builder.emit('Mul', [x_real, y_imag])
34 x_imag_mul_y_real = graph_builder.emit('Mul', [x_imag, y_real])
35 result_real = graph_builder.emit('Sub', [x_real_mul_y_real, x_imag_mul_y_imag])
[all …]
Dadd.py24 def _expand(self, graph_builder): argument
26 x_real = graph_builder.emit('CReal', [input_x])
27 y_real = graph_builder.emit('CReal', [input_y])
28 x_imag = graph_builder.emit('CImag', [input_x])
29 y_imag = graph_builder.emit('CImag', [input_y])
30 result_real = graph_builder.emit('Add', [x_real, y_real])
31 result_imag = graph_builder.emit('Add', [x_imag, y_imag])
32 result = graph_builder.emit('Complex', [result_real, result_imag])
Dsub.py24 def _expand(self, graph_builder): argument
26 x_real = graph_builder.emit('CReal', [input_x])
27 y_real = graph_builder.emit('CReal', [input_y])
28 x_imag = graph_builder.emit('CImag', [input_x])
29 y_imag = graph_builder.emit('CImag', [input_y])
30 result_real = graph_builder.emit('Sub', [x_real, y_real])
31 result_imag = graph_builder.emit('Sub', [x_imag, y_imag])
32 result = graph_builder.emit('Complex', [result_real, result_imag])
Dabs.py22 def _expand(self, graph_builder): argument
24 x_real = graph_builder.emit('CReal', [input_x])
25 x_imag = graph_builder.emit('CImag', [input_x])
26 squre_x_real = graph_builder.emit('Mul', [x_real, x_real])
27 squre_x_imag = graph_builder.emit('Mul', [x_imag, x_imag])
28 squre_sum = graph_builder.emit('Add', [squre_x_real, squre_x_imag])
29 result = graph_builder.emit('Sqrt', [squre_sum])

123