Skip to content

Commit

Permalink
store parameter values as static shapes during constraint generation (p…
Browse files Browse the repository at this point in the history
…ytorch#82742)

Parameter values are static tensor shapes. With this assumption, we will store those values as static tensor shapes when generating constraints for placeholders.
Pull Request resolved: pytorch#82742
Approved by: https://github.com/jansel
  • Loading branch information
migeed-z authored and pytorchmergebot committed Aug 3, 2022
1 parent 1f29a5f commit 6d7b761
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,16 @@ def generate_constraints_node(self, n: Node, counter):
if n.op == 'placeholder':
x, counter = gen_tvar(counter)
self.symbol_dict[n] = x
n.type = Dyn if not (isinstance(n.type, TensorType) or n.type == Dyn) else n.type

if n.type != Dyn and (not isinstance(n.type, TensorType)):

if n.type == torch.nn.parameter.Parameter:
# since we have a parameter, the shape must be static
assert 'example_value' in n.meta
n.type = TensorType(n.meta['example_value'].size())
else:
n.type = Dyn

c1 = BinConstraintT(n.type, x, op_precision)
c2 = BinConstraintT(x, MAX_TENSOR_RANK, op_leq)
return [c1, c2], counter
Expand Down

0 comments on commit 6d7b761

Please sign in to comment.