Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions python/tvm/script/ir_builder/relax/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def output(*vars: Tuple[Var]) -> None:
def call_packed(
func: py_str,
*args: Expr,
sinfo_args: Union[StructInfo, List[StructInfo]],
sinfo_args: Optional[Union[StructInfo, List[StructInfo]]] = None,
**kwargs: Any,
) -> Call:
"""Create a relax Call, which calls a packed function.
Expand All @@ -340,7 +340,7 @@ def call_packed(
The name of extern function.
*args : Expr
The arguments.
sinfo_args: Union[StructInfo, List[StructInfo]]
sinfo_args: Optional[Union[StructInfo, List[StructInfo]]]
The list of structure info arguments.
kwargs: Expr
The keyword arguments.
Expand All @@ -352,7 +352,7 @@ def call_packed(
"""
op = ExternFunc(func)
if sinfo_args is None:
raise ValueError("R.call_packed is required to have type_args")
sinfo_args = []
if isinstance(sinfo_args, py_tuple): # type: ignore
sinfo_args = list(sinfo_args)
elif not isinstance(sinfo_args, list):
Expand Down
22 changes: 22 additions & 0 deletions tests/python/relax/test_tvmscript_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,28 @@ def foo(x: R.Tensor((32, 32), "float32")) -> R.Tensor:
_check(foo, bb.get()["foo"])


def test_call_packed_without_sinfo_args():
@R.function
def foo(x: R.Object) -> R.Object:
z = R.call_packed("test", x)
return z

x = relax.Var("x", R.Object())
bb = relax.BlockBuilder()
with bb.function("foo", (x)):
z = bb.emit(
relax.Call(
relax.ExternFunc("test"),
(x,),
None,
sinfo_args=[],
)
)
bb.emit_func_output(z)

_check(foo, bb.get()["foo"])


def test_annotation():
@R.function
def foo(
Expand Down