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
3 changes: 3 additions & 0 deletions python/tvm/meta_schedule/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ def __setattr__(self, name, value):
TVMDerivedObject.__name__ = cls.__name__
TVMDerivedObject.__doc__ = cls.__doc__
TVMDerivedObject.__module__ = cls.__module__
for key, value in cls.__dict__.items():
if isinstance(value, (classmethod, staticmethod)):
setattr(TVMDerivedObject, key, value)
return TVMDerivedObject


Expand Down
21 changes: 21 additions & 0 deletions tests/python/unittest/test_meta_schedule_post_order_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,5 +404,26 @@ def _get_sch(filter_fn):
assert len(schs) == 8


def test_meta_schedule_derived_object():
@derived_object
class RemoveBlock(PyScheduleRule):
@classmethod
def class_construct(cls):
return cls()

@staticmethod
def static_construct():
return RemoveBlock()

inst_by_init = RemoveBlock()
assert isinstance(inst_by_init, RemoveBlock)

inst_by_classmethod = RemoveBlock.class_construct()
assert isinstance(inst_by_classmethod, RemoveBlock)

inst_by_staticmethod = RemoveBlock.static_construct()
assert isinstance(inst_by_staticmethod, RemoveBlock)


if __name__ == "__main__":
tvm.testing.main()