slyubomirsky commented on code in PR #15577:
URL: https://github.com/apache/tvm/pull/15577#discussion_r1307943143
##########
python/tvm/relax/struct_info.py:
##########
@@ -42,14 +43,68 @@ class PrimStructInfo(StructInfo):
Parameters
----------
- dtype : str
- The data type of the prim value.
+ dtype_or_expr : Union[str, DataType, PrimExpr]
+
+ The data type of the prim value, or a known expression for the prim
+ value.
"""
+ value: Optional[PrimExpr]
dtype: str
- def __init__(self, dtype: str, span: Span = None) -> None:
- self.__init_handle_by_constructor__(_ffi_api.PrimStructInfo, dtype,
span) # type: ignore
+ def __init__(
+ self,
+ dtype: Optional[Union[str, DataType]] = None,
+ value: Optional[Union[int, float, PrimExpr]] = None,
+ span: Span = None,
+ ) -> None:
+ # Guard against incorrect usage. For backwards compatibility,
+ # the dtype and value are in the opposite order from most
+ # usages. While PrimStructInfo could take a single positional
+ # argument and check the type, this would require an API
+ # difference from TVMScript's PrimProxy, which cannot.
+ # (PrimProxy uses string arguments for datatype, and also for
+ # inline variable definitions when used in a function
+ # signature, and requires separate arguments to distinguish
+ # the two cases.)
Review Comment:
Very user-friendly touch :)
##########
python/tvm/relax/struct_info.py:
##########
@@ -42,14 +43,68 @@ class PrimStructInfo(StructInfo):
Parameters
----------
- dtype : str
- The data type of the prim value.
+ dtype_or_expr : Union[str, DataType, PrimExpr]
+
+ The data type of the prim value, or a known expression for the prim
+ value.
"""
+ value: Optional[PrimExpr]
dtype: str
- def __init__(self, dtype: str, span: Span = None) -> None:
- self.__init_handle_by_constructor__(_ffi_api.PrimStructInfo, dtype,
span) # type: ignore
+ def __init__(
+ self,
+ dtype: Optional[Union[str, DataType]] = None,
+ value: Optional[Union[int, float, PrimExpr]] = None,
+ span: Span = None,
+ ) -> None:
+ # Guard against incorrect usage. For backwards compatibility,
+ # the dtype and value are in the opposite order from most
+ # usages. While PrimStructInfo could take a single positional
+ # argument and check the type, this would require an API
+ # difference from TVMScript's PrimProxy, which cannot.
+ # (PrimProxy uses string arguments for datatype, and also for
+ # inline variable definitions when used in a function
+ # signature, and requires separate arguments to distinguish
+ # the two cases.)
Review Comment:
Very user-friendly touch :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]