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

[BugFix] LocalBuilder API #531

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
20 changes: 13 additions & 7 deletions python/tvm/meta_schedule/builder/local_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
import logging
import os
import tempfile
from typing import Callable, List, Optional, Union, Dict
from numpy import byte
from tvm.runtime import NDArray
from typing import Callable, Dict, List, Optional, Union

from tvm._ffi import register_func
from tvm.ir import IRModule
from tvm.runtime import Module, save_param_dict, load_param_dict
from tvm.runtime import NDArray
from tvm.runtime import Module, load_param_dict, save_param_dict
from tvm.target import Target

from ...contrib.popen_pool import MapResult, PopenPoolExecutor, StatusKind
Expand Down Expand Up @@ -69,7 +68,11 @@ class LocalBuilder(PyBuilder):

.. code-block:: python

def default_build(mod: IRModule, target: Target) -> Module:
def default_build(
mod: IRModule,
target: Target,
params: Optional[Dict[str, NDArray]]
) -> Module:
...

T_EXPORT : typing._GenericAlias
Expand All @@ -88,7 +91,7 @@ def default_export(mod: Module) -> str:
please send the registration logic via initializer.
"""

T_BUILD = Callable[[IRModule, Target], Module]
T_BUILD = Callable[[IRModule, Target, Optional[Dict[str, NDArray]]], Module]
T_EXPORT = Callable[[Module], str]

pool: PopenPoolExecutor
Expand Down Expand Up @@ -210,7 +213,7 @@ def _worker_func(


@register_func("meta_schedule.builder.default_build")
def default_build(mod: IRModule, target: Target) -> Module:
def default_build(mod: IRModule, target: Target, params: Optional[Dict[str, NDArray]]) -> Module:
"""Default build function.

Parameters
Expand All @@ -219,6 +222,8 @@ def default_build(mod: IRModule, target: Target) -> Module:
The IRModule to be built.
target : Target
The target to be built.
params : Optional[Dict[str, NDArray]]
The parameters to be used for the build. Must be None.

Returns
-------
Expand All @@ -231,6 +236,7 @@ def default_build(mod: IRModule, target: Target) -> Module:

# pylint: enable=import-outside-toplevel

assert params is None
if target.kind.name == "cuda":
set_cuda_target_arch(target.attrs["arch"])

Expand Down
8 changes: 4 additions & 4 deletions tests/python/unittest/test_meta_schedule_tune_tir.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

@T.prim_func
def matmul(a: T.handle, b: T.handle, c: T.handle) -> None:
A = T.match_buffer(a, [1024, 1024])
B = T.match_buffer(b, [1024, 1024])
C = T.match_buffer(c, [1024, 1024])
for i, j, k in T.grid(1024, 1024, 1024):
A = T.match_buffer(a, [128, 128])
B = T.match_buffer(b, [128, 128])
C = T.match_buffer(c, [128, 128])
for i, j, k in T.grid(128, 128, 128):
with T.block("update"):
vi, vj, vk = T.axis.remap("SSR", [i, j, k])
with T.init():
Expand Down