Skip to content

Commit

Permalink
Fix IBP support for BoundSlice
Browse files Browse the repository at this point in the history
While slice is monotone, it have multiple parameters and can not use the default IBP method implemented in the base class
  • Loading branch information
hx507 committed Oct 17, 2021
1 parent 319252b commit bdeaf84
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion auto_LiRPA/bound_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -4266,7 +4266,7 @@ def __init__(self, input_name, name, ori_name, attr, inputs, output_index, optio
self.start = attr["starts"][0] if "starts" in attr else None
self.end = attr["ends"][0] if "ends" in attr else None
self.axes = attr["axes"][0] if "axes" in attr else None
self.use_default_ibp = True
self.use_default_ibp = False

# Older Pytorch version only passes steps as input.
@Bound.save_io_shape
Expand All @@ -4290,6 +4290,11 @@ def forward(self, x, start=None, end=None, axes=None, steps=1):
if steps == -1:
final = torch.flip(final, dims=tuple(axes))
return final

def interval_propagate(self, *v):
lb = tuple(map(lambda x:x[0],v))
ub = tuple(map(lambda x:x[1],v))
return Interval.make_interval(self.forward(*lb), self.forward(*ub))

def infer_batch_dim(self, batch_size, *x):
if x[0] == -1:
Expand Down

0 comments on commit bdeaf84

Please sign in to comment.