Commit e2f0eed9 authored by xiabo's avatar xiabo
Browse files

测试用例修改

原因:
np.allclose(a, b, rtol)使用,计算误差是(a-b)的误差在(atol + rtol*b.abs())以内,但用例中b的值有0,误差就是atol了,atol默认是10的-8.
修改:
把atol根据用例改为传入的误差*10-3.
parent b1294f57
......@@ -85,7 +85,7 @@ def get_version_add(sha: Optional[str] = None) -> str:
lines=[]
with open(add_version_path, 'r',encoding='utf-8') as file:
lines = file.readlines()
lines[2] = "__dcu_version__ = '2.0.0+{}'\n".format(version)
lines[2] = "__dcu_version__ = '2.0.1+{}'\n".format(version)
with open(add_version_path, encoding="utf-8",mode="w") as file:
file.writelines(lines)
file.close()
......
......@@ -75,20 +75,20 @@ class TestDeformconv:
out.backward(torch.ones_like(out))
assert np.allclose(out.data.detach().cpu().numpy(), repeated_gt_out,
threshold)
threshold, threshold*1e-3)
assert np.allclose(x.grad.detach().cpu().numpy(), repeated_gt_x_grad,
threshold)
threshold, threshold*1e-3)
# the batch size of the input is increased which results in
# a larger gradient so we need to divide by the batch_size
assert np.allclose(
model.conv_offset.weight.grad.detach().cpu().numpy() / batch_size,
gt_offset_weight_grad, threshold)
gt_offset_weight_grad, threshold, threshold*1e-3)
assert np.allclose(
model.conv_offset.bias.grad.detach().cpu().numpy() / batch_size,
gt_offset_bias_grad, threshold)
gt_offset_bias_grad, threshold, threshold*1e-3)
assert np.allclose(
model.weight.grad.detach().cpu().numpy() / batch_size,
gt_deform_weight_grad, threshold)
gt_deform_weight_grad, threshold, threshold*1e-3)
from mmcv.ops import DeformConv2d
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment