Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoTVM] Added @functools.wraps to function decorators #8237

Merged
merged 1 commit into from
Jun 10, 2021
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/autotvm/task/code_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
code hashing is used to check the consistence of schedule code and the parameters loaded from log
"""
import functools
import inspect
import zlib

Expand All @@ -35,6 +36,7 @@ def attach_code_hash(s):
"""

def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
func(*args, **kwargs)
raw_hash = zlib.crc32("".join(inspect.getsourcelines(func)[0]).encode())
Expand All @@ -56,6 +58,7 @@ def attach_code_hash_to_arg(arg_idx=1):
"""

def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
func(*args, **kwargs)
assert isinstance(args[arg_idx], schedule.Schedule)
Expand Down
3 changes: 3 additions & 0 deletions python/tvm/autotvm/task/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
func is a state-less function, or a string that
registers the standard task.
"""
import functools

import numpy as np

from tvm import runtime
Expand Down Expand Up @@ -411,6 +413,7 @@ def matmul(N, L, M, dtype):
"""

def _decorate(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
assert not kwargs, "Do not support kwargs in template function call"
workload = args_to_workload(args, task_name)
Expand Down
4 changes: 4 additions & 0 deletions python/tvm/autotvm/task/topi_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

See tvm/topi/python/topi/arm_cpu/depthwise_conv2d.py for example usage.
"""
import functools

import tvm.te._ffi_api
from tvm.target import Target
from tvm.te import tensor
Expand Down Expand Up @@ -149,6 +151,7 @@ def register_topi_compute(task_name, func=None):
"""

def _decorate(topi_compute):
@functools.wraps(topi_compute)
@_register_task_compute(task_name)
def wrapper(*args, **kwargs):
"""wrapper function for topi compute"""
Expand Down Expand Up @@ -224,6 +227,7 @@ def register_topi_schedule(task_name, func=None):
"""

def _decorate(topi_schedule):
@functools.wraps(topi_schedule)
@_register_task_schedule(task_name)
def wrapper(outs, *args, **kwargs):
"""wrapper function for topi schedule"""
Expand Down