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

[MetaSchedule] Fix Cyclic Dependency in PyClass Family #10368

Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix mypy.
  • Loading branch information
zxybazh committed Mar 2, 2022
commit 298e6d60fb571141f5ec6b3352362adea4c58311
10 changes: 5 additions & 5 deletions python/tvm/meta_schedule/cost_model/random_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class RandomModel(PyCostModel):
https://numpy.org/doc/stable/reference/random/generated/numpy.random.get_state.html
"""

import numpy as np # pylint: disable=import-outside-toplevel
import numpy as np # type: ignore # pylint: disable=import-outside-toplevel

random_state: Union[Tuple[str, np.ndarray, int, int, float], dict]
path: Optional[str]
Expand All @@ -57,7 +57,7 @@ def __init__(
path: Optional[str] = None,
max_range: Optional[int] = 100,
):
import numpy as np # pylint: disable=import-outside-toplevel
import numpy as np # type: ignore # pylint: disable=import-outside-toplevel

super().__init__()
if path is not None:
Expand All @@ -75,7 +75,7 @@ def load(self, path: str) -> None:
path : str
The file path.
"""
import numpy as np # pylint: disable=import-outside-toplevel
import numpy as np # type: ignore # pylint: disable=import-outside-toplevel

self.random_state = tuple(np.load(path, allow_pickle=True)) # type: ignore

Expand All @@ -87,7 +87,7 @@ def save(self, path: str) -> None:
path : str
The file path.
"""
import numpy as np # pylint: disable=import-outside-toplevel
import numpy as np # type: ignore # pylint: disable=import-outside-toplevel

np.save(path, np.array(self.random_state, dtype=object), allow_pickle=True)

Expand Down Expand Up @@ -126,7 +126,7 @@ def predict(
result : np.ndarray
The predicted running results.
"""
import numpy as np # pylint: disable=import-outside-toplevel
import numpy as np # type: ignore # pylint: disable=import-outside-toplevel

np.random.set_state(self.random_state)
# TODO(@zxybazh): Use numpy's RandState object:
Expand Down