Skip to content

Commit

Permalink
Update false positive case.
Browse files Browse the repository at this point in the history
  • Loading branch information
wzh99 committed Nov 1, 2022
1 parent 8047004 commit ea8965b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions bug/false_positive/conv_bn_tan.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

code = """
#[version = "0.0.5"]
def @main(%x0: Tensor[(14, 1, 11, 7), float16], %x2: Tensor[(5, 1, 3, 1), float16], %x3: Tensor[(5), float16], %x4: Tensor[(5), float16], %x5: Tensor[(5), float16], %x6: Tensor[(5), float16]) -> (Tensor[(14, 5, 5, 3), float16],) {
%0 = nn.avg_pool2d(%x0, pool_size=[3, 3], strides=[2, 1], dilation=[1, 2], padding=[0, 0, 0, 0], count_include_pad=True) /* from_string */ /* ty=Tensor[(14, 1, 5, 3), float16] */;
%1 = nn.conv2d(%0, %x2, strides=[1, 2], padding=[1, 1, 1, 2], dilation=[1, 2], channels=5, kernel_size=[3, 1]) /* from_string */ /* ty=Tensor[(14, 5, 5, 3), float16] */;
%2 = nn.batch_norm(%1, %x3, %x4, %x5, %x6, center=False, scale=False) /* from_string */ /* ty=(Tensor[(14, 5, 5, 3), float16], Tensor[(5), float16], Tensor[(5), float16]) */;
%3 = %2.0;
%4 = tan(%3) /* from_string */ /* ty=Tensor[(14, 5, 5, 3), float16] */;
(%4,)
def @main(%x0: Tensor[(14, 1, 11, 7), float16], %x2: Tensor[(5, 1, 3, 1), float16],
%x3: Tensor[(5), float16], %x4: Tensor[(5), float16], %x5: Tensor[(5), float16],
%x6: Tensor[(5), float16]) -> Tensor[(14, 5, 5, 4), float16] {
%0 = nn.conv2d(%x0, %x2, strides=[2, 2], padding=[0, 0, 0, 0], dilation=[1, 1]);
%1 = nn.batch_norm(%0, %x3, %x4, %x5, %x6, axis=1, center=False, scale=False);
tan(%1.0)
}
"""

Expand All @@ -31,7 +30,10 @@ def @main(%x0: Tensor[(14, 1, 11, 7), float16], %x2: Tensor[(5, 1, 3, 1), float1
gmod = GraphModule(lib['default'](cpu()))
gmod.run(**inputs)
opt_out = gmod.get_output(0).numpy()

diff = np.abs(opt_out - ref_out)
print(f'{np.unravel_index(np.nanargmax(diff), ref_out.shape)}: {np.nanmax(diff)}')
rel_diff = diff / ref_out
print(f'{np.unravel_index(np.nanargmax(rel_diff), ref_out.shape)}: {np.nanmax(rel_diff)}')
max_idx = np.unravel_index(np.nanargmax(diff), ref_out.shape)
print('pos:', max_idx)
ref_elem, opt_elem = ref_out[max_idx], opt_out[max_idx]
print('ref:', ref_elem, 'opt:', opt_elem)
print('abs_err:', np.abs(ref_elem - opt_elem), 'rel_err:', np.abs(ref_elem - opt_elem) / ref_elem)

0 comments on commit ea8965b

Please sign in to comment.