Skip to content

Commit

Permalink
support default value in intlist (#6201)
Browse files Browse the repository at this point in the history
* support default value in intlist

* fix comment

Co-authored-by: oneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com>
  • Loading branch information
MARD1NO and oneflow-ci-bot authored Sep 9, 2021
1 parent ec0b68c commit 26c12d0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/functional/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,14 @@ def __init__(self, fmt, keyword_only=False):
sp = self._name.find("=")
if sp != -1:
self._default_value = _normalize(self._name[sp + 1 :])
if self._default_value == "None":
if self._type.endswith("List"):
_value_list = [
self._default_value for i in range(self._size)
] # For int32List[2] = 1, _value_list will be [1, 1]
self._default_cpp_value = (
"{" + ", ".join(_value_list) + "}"
) # [1, 1] -> "{1, 1}"
elif self._default_value == "None":
self._optional = True
self._default_cpp_value = ""
elif self._default_value in value_aliases:
Expand Down

0 comments on commit 26c12d0

Please sign in to comment.