()
| 394 | |
| 395 | |
| 396 | def test_function_with_value_protocol() -> None: |
| 397 | class ValueProtocol: |
| 398 | def __init__(self, value: Any) -> None: |
| 399 | self.value = value |
| 400 | |
| 401 | def __tvm_ffi_value__(self) -> Any: |
| 402 | return self.value |
| 403 | |
| 404 | fecho = tvm_ffi.get_global_func("testing.echo") |
| 405 | assert fecho(ValueProtocol(10)) == 10 |
| 406 | assert tuple(fecho(ValueProtocol([1, 2, 3]))) == (1, 2, 3) |
| 407 | assert tuple(fecho(ValueProtocol([1, 2, ValueProtocol(3)]))) == (1, 2, 3) |
| 408 | nested_value_protocol = ValueProtocol(ValueProtocol(ValueProtocol(10))) |
| 409 | assert fecho(nested_value_protocol) == 10 |
| 410 | |
| 411 | nested_value_protocol = ValueProtocol([ValueProtocol(1), ValueProtocol(2), ValueProtocol(3)]) |
| 412 | assert tuple(fecho(nested_value_protocol)) == (1, 2, 3) |
| 413 | |
| 414 | |
| 415 | def test_convert_func_tensor_cls_missing_attribute() -> None: |
nothing calls this directly
no test coverage detected