fix fill_constant shape with -1 and enhance cross_entropy test=develop (#20722)

revert-20712-fix_depthwise_conv
Aurelius84 5 years ago committed by GitHub
parent 48a774c713
commit 74a28f5ea4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -136,8 +136,8 @@ class CrossEntropyGradientOpBase : public framework::OperatorWithKernel {
"Input(Y@Grad) and Input(Y) should have the same rank.");
bool check = true;
if ((!ctx->IsRuntime()) && (framework::product(x_dims) <= 0 ||
framework::product(label_dims) <= 0)) {
if ((!ctx->IsRuntime()) &&
(framework::product(x_dims) <= 0 || framework::product(dy_dims) <= 0)) {
check = false;
}

@ -1251,7 +1251,7 @@ def calc_gradient(targets, inputs, target_gradients=None, no_grad_set=None):
op_desc = _create_op_desc_("fill_constant",
{"ShapeTensor": [target_shape.name]},
{"Out": [grad_name]}, {
"shape": [],
"shape": target.shape,
"value": 1.0,
"dtype": target.dtype,
})

Loading…
Cancel
Save