MCPcopy Create free account
hub / github.com/apache/tvm-ffi / test_object_protocol

Function test_object_protocol

tests/python/test_object.py:193–206  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

191
192
193def test_object_protocol() -> None:
194 class CompactObject:
195 def __init__(self, backend_obj: Any) -> None:
196 self.backend_obj = backend_obj
197
198 def __tvm_ffi_object__(self) -> Any:
199 return self.backend_obj
200
201 x = tvm_ffi.convert([])
202 assert isinstance(x, tvm_ffi.Object)
203 x_compact = CompactObject(x)
204 test_echo = tvm_ffi.get_global_func("testing.echo")
205 y = test_echo(x_compact)
206 assert y.__chandle__() == x.__chandle__()
207
208
209def test_unregistered_object_fallback() -> None:

Callers

nothing calls this directly

Calls 3

CompactObjectClass · 0.85
test_echoFunction · 0.85
convertMethod · 0.45

Tested by

no test coverage detected