Home
last modified time | relevance | path

Searched refs:grad (Results 1 – 25 of 383) sorted by relevance

12345678910>>...16

/third_party/mindspore/mindspore/nn/wrap/
Dgrad_reducer.py83 def _tensors_allreduce(degree, mean, allgather, allreduce, allreduce_filter, grad): argument
99 grad = allreduce(grad)
101 grad = F.tensor_mul(grad, F.cast(degree, F.dtype(grad)))
102 return grad
103 return grad
107 def _tensors_allreduce_post(degree, mean, allreduce_filter, grad): argument
124 grad = F.tensor_mul(grad, F.cast(degree, F.dtype(grad)))
125 return grad
126 return grad
130 def _tensors_allreduce_ps(degree, mean, allgather, allreduce, allreduce_filter, grad, ps_parameter): argument
[all …]
Dloss_scale.py33 def tensor_grad_scale(scale, grad): argument
34 return grad * F.cast(reciprocal(scale), F.dtype(grad))
38 def tensor_grad_scale_row_tensor(scale, grad): argument
39 return RowTensor(grad.indices,
40 grad.values * F.cast(reciprocal(scale), F.dtype(grad.values)),
41 grad.dense_shape)
48 def _tensor_grad_overflow(grad): argument
49 return grad_overflow(grad)
53 def _tensor_grad_overflow_row_tensor(grad): argument
54 return grad_overflow(grad.values)
[all …]
/third_party/mindspore/tests/ut/python/optimizer/
Dtest_bprop_mindir.py53 self.grad = ops.GradOperation(get_all=True)
57 gout = self.grad(self.network)(*inputs)
70 grad = GradNet(relu)
71 grad.compile(x)
90 grad = GradNet(relu)
91 grad.compile(x)
97 grad = GradNet(identity)
98 grad.compile(x)
104 grad = GradNet(range_net)
105 grad.compile(x)
[all …]
/third_party/mindspore/mindspore/ccsrc/backend/kernel_compiler/gpu/cuda_impl/
Dgather_grad.cu23 __global__ void GatherGradKernel(const size_t num, const T *index, const S *grad, S *output, in GatherGradKernel() argument
41 MsAtomicAdd(output + read_id, grad[id]); in GatherGradKernel()
56 void GatherGrad(const T *index, const S *grad, S *output, const size_t dim_before_axis, in GatherGrad() argument
63 GatherGradKernel<<<GET_BLOCKS(size), GET_THREADS, 0, stream>>>(size, index, grad, output, in GatherGrad()
69 template void GatherGrad<int, double>(const int *index, const double *grad, double *output,
73 template void GatherGrad<int64_t, double>(const int64_t *index, const double *grad, double *output,
77 template void GatherGrad<int, float>(const int *index, const float *grad, float *output,
81 template void GatherGrad<int64_t, float>(const int64_t *index, const float *grad, float *output,
85 template void GatherGrad<int, half>(const int *index, const half *grad, half *output,
89 template void GatherGrad<int64_t, half>(const int64_t *index, const half *grad, half *output,
[all …]
Dsparse_cross_entropy_cuda_impl.cu42 float *grad) { in CalCrossEntropyGradKernel() argument
46 grad[i * class_num + j] = (logits[i * class_num + j] - 1) / batch_size; in CalCrossEntropyGradKernel()
48 grad[i * class_num + j] = logits[i * class_num + j] / batch_size; in CalCrossEntropyGradKernel()
63 …EntropyGrad(const float *logits, T *labels, const int batch_size, const int class_num, float *grad, in CalCrossEntropyGrad() argument
66 … class_num, grad); in CalCrossEntropyGrad()
75 float *grad, cudaStream_t cuda_stream);
77 … const int class_num, float *grad, cudaStream_t cuda_stream);
/third_party/mindspore/tests/st/gradient/
Dtest_jvp_graph.py22 from mindspore.nn.grad import Jvp
56 primal, grad = Jvp(net)(x, v)
58 assert np.allclose(grad.asnumpy(), expect_grad.asnumpy())
70 primal, grad = Jvp(net)(x, v)
72 assert np.allclose(grad.asnumpy(), expect_grad.asnumpy())
86 primal, grad = Jvp(net)(x, v)
91 assert isinstance(grad, tuple)
92 assert len(grad) == 2
93 assert np.allclose(grad[0].asnumpy(), expect_grad_0.asnumpy())
94 assert np.allclose(grad[1].asnumpy(), expect_grad_1.asnumpy())
[all …]
Dtest_jvp_pynative.py22 from mindspore.nn.grad import Jvp
55 primal, grad = Jvp(net)(x, v)
57 assert np.allclose(grad.asnumpy(), expect_grad.asnumpy())
69 primal, grad = Jvp(net)(x, v)
71 assert np.allclose(grad.asnumpy(), expect_grad.asnumpy())
85 primal, grad = Jvp(net)(x, v)
90 assert isinstance(grad, tuple)
91 assert len(grad) == 2
92 assert np.allclose(grad[0].asnumpy(), expect_grad_0.asnumpy())
93 assert np.allclose(grad[1].asnumpy(), expect_grad_1.asnumpy())
[all …]
Dtest_vjp_pynative.py21 from mindspore.nn.grad import Vjp
45 primal, grad = Vjp(net)(x, v)
47 assert np.allclose(grad.asnumpy(), expect_grad.asnumpy())
63 primal, grad = Vjp(net)(x, y, (v, v))
68 assert isinstance(grad, tuple)
69 assert len(grad) == 2
70 assert np.allclose(grad[0].asnumpy(), expect_grad_0.asnumpy())
71 assert np.allclose(grad[1].asnumpy(), expect_grad_1.asnumpy())
Dtest_vjp_graph.py21 from mindspore.nn.grad import Vjp
45 primal, grad = Vjp(net)(x, v)
47 assert np.allclose(grad.asnumpy(), expect_grad.asnumpy())
63 primal, grad = Vjp(net)(x, y, (v, v))
68 assert isinstance(grad, tuple)
69 assert len(grad) == 2
70 assert np.allclose(grad[0].asnumpy(), expect_grad_0.asnumpy())
71 assert np.allclose(grad[1].asnumpy(), expect_grad_1.asnumpy())
/third_party/skia/tests/
DShaderOpacityTest.cpp61 auto grad = SkGradientShader::MakeLinear(pts, colors, pos, count, mode); in test_gradient() local
62 REPORTER_ASSERT(reporter, grad); in test_gradient()
63 REPORTER_ASSERT(reporter, grad->isOpaque()); in test_gradient()
68 grad = SkGradientShader::MakeLinear(pts, colors, pos, count, mode); in test_gradient()
69 REPORTER_ASSERT(reporter, grad); in test_gradient()
70 REPORTER_ASSERT(reporter, !grad->isOpaque()); in test_gradient()
75 grad = SkGradientShader::MakeLinear(pts, colors, pos, count, mode); in test_gradient()
76 REPORTER_ASSERT(reporter, grad); in test_gradient()
77 REPORTER_ASSERT(reporter, !grad->isOpaque()); in test_gradient()
82 grad = SkGradientShader::MakeLinear(pts, colors, pos, count, mode); in test_gradient()
[all …]
/third_party/flutter/skia/tests/
DShaderOpacityTest.cpp58 auto grad = SkGradientShader::MakeLinear(pts, colors, pos, count, mode); in test_gradient() local
59 REPORTER_ASSERT(reporter, grad); in test_gradient()
60 REPORTER_ASSERT(reporter, grad->isOpaque()); in test_gradient()
65 grad = SkGradientShader::MakeLinear(pts, colors, pos, count, mode); in test_gradient()
66 REPORTER_ASSERT(reporter, grad); in test_gradient()
67 REPORTER_ASSERT(reporter, !grad->isOpaque()); in test_gradient()
72 grad = SkGradientShader::MakeLinear(pts, colors, pos, count, mode); in test_gradient()
73 REPORTER_ASSERT(reporter, grad); in test_gradient()
74 REPORTER_ASSERT(reporter, !grad->isOpaque()); in test_gradient()
79 grad = SkGradientShader::MakeLinear(pts, colors, pos, count, mode); in test_gradient()
[all …]
/third_party/mindspore/tests/st/auto_monad/
Dtest_effect_optimizer.py34 def construct(self, beta1_power, beta2_power, lr, beta1, beta2, epsilon, grad): argument
36 beta2_power, lr, beta1, beta2, epsilon, grad)
56 grad = Tensor(np.random.rand(3, 3, 3).astype(np.float32))
58 beta1_power, beta2_power, lr, beta1, beta2, epsilon, grad)
71 def construct(self, beta1_power, lr, beta1, beta2, epsilon, grad): argument
73 beta1_power, lr, beta1, beta2, epsilon, grad)
92 grad = Tensor(np.random.rand(3, 3).astype(np.float32))
93 new_var, new_m, new_v = net(beta1_power, lr, beta1, beta2, epsilon, grad)
106 def construct(self, lr, rho, epsilon, grad): argument
108 self.accum_update, lr, rho, epsilon, grad)
[all …]
/third_party/mindspore/tests/st/high_grad/
Dtest_highgrad_train.py30 def __init__(self, grad, network, wrt_params=False, real_inputs_count=None): argument
33 self.grad = grad
34 self.sens_param = self.grad.sens_param
43 return self.grad(self.network, self.params)(*inputs)
44 return self.grad(self.network)(*inputs)
49 return self.grad(self.network, self.params)(*real_inputs, sense_param_inputs)
50 return self.grad(self.network)(*real_inputs, sense_param_inputs)
59 super().__init__(grad=GradOperation(sens_param=sens_param),
82 def __init__(self, grad, loss): argument
84 self.grad = grad
[all …]
/third_party/mindspore/mindspore/ops/_grad_experimental/
Dgrad_nn_ops.py31grad = ctc_loss_grad(dout[1], log_probs, targets, input_lengths, target_lengths, out[0], out[1])
32 grad = transpose(grad, (1, 0, 2))
33 return grad, zeros_like(targets), zeros_like(input_lengths), zeros_like(target_lengths)
41 grad = G.SoftMarginLossGrad(reduction=self.reduction)
44 dx = grad(predict, label, dout)
45 dy = grad(label, predict, dout)
66 grad = G.HShrinkGrad(self.lambd)
69 dx = grad(gradients, features)
/third_party/mindspore/tests/st/pynative/dynamic_shape/
Dtest_pynative_control_flow.py32 self.grad = P.GradOperation(get_all=True, get_by_list=True, sens_param=sens)
37 out = self.grad(self.net, self.params)(*x)
89 grad = torch.from_numpy(np.ones_like(out_good.detach().numpy()).astype(np.float32))
90 out_good.backward(gradient=grad)
92 assert np.allclose(torch_input.grad.numpy(), backout[0][0].asnumpy(), 0.01, 0.01)
93 assert np.allclose(comparenet.weight.grad.numpy(), backout[1][0].asnumpy(), 0.01, 0.01)
101 torch_input.grad.zero_()
103 grad = torch.from_numpy(np.ones_like(out_good.detach().numpy()).astype(np.float32))
104 out_good.backward(gradient=grad)
106 assert np.allclose(torch_input.grad.numpy(), backout[0][0].asnumpy(), 0.01, 0.01)
[all …]
/third_party/mindspore/tests/st/ops/gpu/
Dtest_gather_grad_op.py44 grad = Tensor(np.array([[0.9031, 0.0890, 0.2779, 0.3198, 0.5710],
50 output = grad_net(x, index, grad)
63 grad = Tensor(np.array([[0.9031, 0.0890, 0.2779, 0.3198, 0.5710],
69 output = grad_net(x, index, grad)
82 grad = Tensor(np.array([[0.9031, 0.0890, 0.2779, 0.3198, 0.5710],
88 output = grad_net(x, index, grad)
101 grad = Tensor(np.array([[0.9031, 0.0890, 0.2779, 0.3198, 0.5710],
107 output = grad_net(x, index, grad)
120 grad = Tensor(np.array([[0.9031, 0.0890, 0.2779, 0.3198, 0.5710],
124 output = G.GatherDGrad(dim, x_shape)(index, grad)
[all …]
Dtest_sparse_apply_proximal_adagrad_op.py36 def construct(self, grad, indices): argument
37 … self.sparse_apply_proximal_adagrad(self.var, self.accum, self.lr, self.l1, self.l2, grad, indices)
40 def add_testcase(var, accum, lr, l1, l2, grad, indices): argument
42 return net(grad, indices)
53 grad = Tensor(np.ones(9).reshape(3, 3).astype(np.float32) * 8)
55 output1, output2 = add_testcase(var, accum, lr, l1, l2, grad, indices)
74 grad = Tensor(np.ones(9).reshape(3, 3).astype(np.float32) * 8)
77 net(grad, indices)
96 grad = Tensor(np.ones(9).reshape(3, 3).astype(np.float32) * 8)
98 output1, output2 = add_testcase(var, accum, lr, l1, l2, grad, indices)
[all …]
/third_party/mindspore/tests/mindspore_test_framework/utils/
Dbprop_util.py37 self.grad = grad_op
47 return self.grad(self.func, self.params)(*inputs, self.sens)
49 return self.grad(self.func, self.params)(*inputs)
51 return self.grad(self.func)(*inputs, self.sens)
53 return self.grad(self.func)(*inputs)
89 grad = Bprop(func, wrt_params, params, grad_op, grads_wrt_outputs)
95 return grad(*inputs)
100 return grad(*inputs)
/third_party/mindspore/mindspore/ccsrc/transform/graph_ir/op_declare/
Dnn_training_ops_declare.cc22 …{1, INPUT_DESC(var)}, {2, INPUT_DESC(accum)}, {3, INPUT_DESC(lr)}, {4, INPUT_DESC(grad)}, {5, INPU…
45 {10, INPUT_DESC(grad)}};
54 {10, INPUT_DESC(grad)}};
65 …radD) = {{1, INPUT_DESC(var)}, {2, INPUT_DESC(accum)}, {3, INPUT_DESC(lr)}, {4, INPUT_DESC(grad)}};
72 …dV2D) = {{1, INPUT_DESC(var)}, {2, INPUT_DESC(accum)}, {3, INPUT_DESC(lr)}, {4, INPUT_DESC(grad)}};
82 {7, INPUT_DESC(grad)}};
89 {1, INPUT_DESC(var)}, {2, INPUT_DESC(accum)}, {3, INPUT_DESC(grad)}, {4, INPUT_DESC(indices)}};
107 {7, INPUT_DESC(grad)}};
115 … {7, INPUT_DESC(beta2)}, {8, INPUT_DESC(epsilon)}, {9, INPUT_DESC(grad)}};
129 {7, INPUT_DESC(grad)}};
[all …]
/third_party/mindspore/tests/st/ops/cpu/
Dtest_gather_d_grad_op.py41 self.grad = GradOperation(get_all=True, sens_param=True)
46 return self.grad(self.network)(inputx, index, output_grad)
59 grad = NetGatherDGrad(gatherd)
61 output_grad = grad(Tensor(x), Tensor(index), Tensor(dout))
77 grad = NetGatherDGrad(gatherd)
79 output_grad = grad(Tensor(x), Tensor(index), Tensor(dout))
95 grad = NetGatherDGrad(gatherd)
97 output_grad = grad(Tensor(x), Tensor(index), Tensor(dout))
113 grad = NetGatherDGrad(gatherd)
115 output = grad(Tensor(x), Tensor(index), Tensor(dout))
Dtest_softplus_grad_op.py40 self.grad = C.GradOperation(get_all=True, sens_param=True)
44 gout = self.grad(self.network)(input_data, sens)
60 grad = Grad(net)
62 output = grad(x_ms, dy_ms)
75 grad = Grad(net)
76 output = grad(Tensor(x_np), Tensor(dy_np))
89 grad = Grad(net)
90 output = grad(Tensor(x_np), Tensor(dy_np))
/third_party/mindspore/tests/ut/python/ops/
Dtest_dynamic_shape.py36 def construct(self, grad, indices): argument
37 … self.sparse_apply_proximal_adagrad(self.var, self.accum, self.lr, self.l1, self.l2, grad, indices)
49 def construct(self, grad, inp): argument
52 new_grad = self.cast(new_grad, mstype.float32) + grad
56 grad = Tensor(np.random.rand(1, 80).astype(np.float32))
58 net(grad, indices)
70 def construct(self, grad, indices): argument
71 out = self.sparse_apply_ftrl(self.var, self.accum, self.linear, grad, indices)
83 def construct(self, grad, inp): argument
86 new_grad = self.cast(new_grad, mstype.float32) + grad
[all …]
/third_party/mindspore/tests/ut/python/pynative_mode/
Dtest_graph_param_cases.py32 def __init__(self, grad, network, wrt_params=False, real_inputs_count=None): argument
35 self.grad = grad
36 self.sens_param = self.grad.sens_param
45 return self.grad(self.network, self.params)(*inputs)
48 return self.grad(self.network, self.params)(*real_inputs, sense_param_inputs)
51 return self.grad(self.network)(*inputs)
54 return self.grad(self.network)(*real_inputs, sense_param_inputs)
63 super().__init__(grad=C.GradOperation(sens_param=sens_param),
73 super().__init__(grad=C.GradOperation(get_all=True, sens_param=sens_param),
/third_party/boost/libs/yap/example/
Dautodiff_example.cpp305 vector<double> grad; in BOOST_AUTO_TEST_CASE() local
306 double val1 = grad_reverse(root,list,grad); in BOOST_AUTO_TEST_CASE()
311 CHECK_CLOSE(grad[i],x1g[i]); in BOOST_AUTO_TEST_CASE()
334 vector<double> grad; in BOOST_AUTO_TEST_CASE() local
335 grad_reverse(root,nodes,grad); in BOOST_AUTO_TEST_CASE()
339 CHECK_CLOSE(grad[0],x1g); in BOOST_AUTO_TEST_CASE()
354 vector<double> grad; in BOOST_AUTO_TEST_CASE() local
355 double val = grad_reverse(x1,nodes,grad); in BOOST_AUTO_TEST_CASE()
356 CHECK_CLOSE(grad[0],1); in BOOST_AUTO_TEST_CASE()
365 grad.clear(); in BOOST_AUTO_TEST_CASE()
[all …]
/third_party/mindspore/tests/st/pynative/ms_function/
Dtest_pynative_ms_function.py49 grad = P.GradOperation(get_all=True, get_by_list=True, sens_param=False)
50 out_grad = grad(ConvBnReLU)(inputs)
82 grad = P.GradOperation(get_all=True, get_by_list=True, sens_param=False)
84 grad_first = grad(net, ParameterTuple(net.trainable_params()))(inputs)
90 grad_second = grad(net, ParameterTuple(net.trainable_params()))(inputs)
139 grad = P.GradOperation(get_all=True, get_by_list=True, sens_param=False)
141 grad_first = grad(net, ParameterTuple(net.trainable_params()))(inputs)
148 grad_second = grad(net, ParameterTuple(net.trainable_params()))(inputs)
194 grad = P.GradOperation(get_all=True, get_by_list=True, sens_param=False)
196 grad_first = grad(net, ParameterTuple(net.trainable_params()))(inputs)
[all …]

12345678910>>...16