()
| 347 | |
| 348 | |
| 349 | def test_call_packed(): |
| 350 | # test case from test_parser |
| 351 | @R.function(pure=False) |
| 352 | def f( |
| 353 | x: R.Tensor((32, "m"), "float32"), |
| 354 | y: R.Tensor(("m",), "float32"), |
| 355 | r: R.Tensor(dtype="int64"), |
| 356 | ) -> R.Object: |
| 357 | m = T.int64() |
| 358 | z: R.Tensor((32, m), "float32") = R.multiply(x, y) |
| 359 | w: R.Tensor(ndim=2) = R.multiply(z, z) |
| 360 | q: R.Tensor = R.add(w, w) |
| 361 | t = R.add(w, z) |
| 362 | sh: R.Shape = R.shape_of(t) |
| 363 | o: R.Object = R.call_packed( |
| 364 | "contrib.tensor_array_stack", x, y, sinfo_args=R.Object(), test_attr=True |
| 365 | ) |
| 366 | return o |
| 367 | |
| 368 | # checking that the call_packed call is turned into a call to an extern func |
| 369 | f_str = strip_whitespace( |
| 370 | dump_ast( |
| 371 | f, |
| 372 | include_struct_info_annotations=False, |
| 373 | include_call_attrs=True, |
| 374 | ) |
| 375 | ) |
| 376 | |
| 377 | # the function has an annotated return type |
| 378 | assert "ret_struct_info=ObjectStructInfo()" in f_str |
| 379 | # the purity attribute is set to false |
| 380 | assert "is_pure=False" |
| 381 | |
| 382 | assert isinstance(f.body, rx.SeqExpr) |
| 383 | extern_call = f.body.blocks[0].bindings[-1].value |
| 384 | extern_call_text = dump_ast( |
| 385 | extern_call, |
| 386 | include_struct_info_annotations=False, |
| 387 | include_call_attrs=True, |
| 388 | ) |
| 389 | assert strip_whitespace(extern_call_text) in f_str |
| 390 | assert_fields( |
| 391 | "Call", |
| 392 | { |
| 393 | "op": 'ExternFunc(global_symbol="contrib.tensor_array_stack")', |
| 394 | "args": '[Var(name_hint="x"), Var(name_hint="y")]', |
| 395 | "sinfo_args": "[ObjectStructInfo()]", |
| 396 | "attrs": '{"test_attr": True}', |
| 397 | }, |
| 398 | extern_call_text, |
| 399 | ) |
| 400 | |
| 401 | # check that the op call is there too |
| 402 | op_call = f.body.blocks[0].bindings[0].value |
| 403 | op_call_text = dump_ast( |
| 404 | op_call, |
| 405 | include_struct_info_annotations=False, |
| 406 | include_call_attrs=True, |
nothing calls this directly
no test coverage detected
searching dependent graphs…