[REFACTOR] Streamline Function Attr interface. (#5045)
* [REFACTOR] Streamline Function Attr interface. There has been quite a few recent changes that depends heavily on the function attr interface. This PR streamlines that interface by introducing two APIs that covers most of the usages. - GetAttr which gets a typed object for a given key - HasNonzeroAttr is a quick helper that calls GetAttr to quickly check an attribute - WithAttr that creates a new function object with the given attr - The API comes with copy on write optimization to avoid multiple copies - We deliberately pick the prefix With(instead of Set) to indicate this function does not mutate the original input. On the python side: - We allow read access via func.attrs (which is a DictAttr) - func.with_attrs to create a new instance with updated attrs. We also get rid of the small wrapper functions and make sure the API centered around the GetAttr and HasNonzeroAttr interface. This PR also changes the function construction to follow the new convention. * Address review comments * Address review comments * Fix doxygen path
Showing
include/tvm/ir/function.h
0 → 100644
include/tvm/relay/function.h
0 → 100644
src/ir/function.cc
0 → 100644
src/relay/ir/function.cc
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
tests/python/unittest/test_ir_attrs.py
0 → 100644
Please
register
or
sign in
to comment