Skip to content

Commit

Permalink
[TUZ-150] Post merge cleanup (apache#47)
Browse files Browse the repository at this point in the history
Post TUZ-150 cleanup
  • Loading branch information
Josh Fromm committed Mar 8, 2023
1 parent baa2516 commit 6ff2171
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 37 deletions.
9 changes: 3 additions & 6 deletions python/tvm/octo/octo_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@


class OctoModel(object):
"""A compiled model wrapper that provides helpful utilities.
"""A compiled model wrapper that provides helpful utilities for execution and serialization.
Parameters
----------
exe : Optional[relax.Executable]
A compiled executable that can be loaded and run by a relax VM.
input_info : Optional[Dict[str, Tuple[List, str]]]
Information about the input names, shapes, and types for the VM.
Will be loaded from memory if possible.
model_path : Optional[Union[str, Path]]
The path to a saved OctoModel, one of exe and model_path must
be specified.
Expand Down Expand Up @@ -67,9 +66,7 @@ def __init__(
# Create a vm from exe.
self.vm = relax.VirtualMachine(self.exe, self.dev, profile=True)

def save(
self, model_path: Union[str, Path]
) -> Tuple[relax.Executable, Dict[str, relax.StructInfo]]:
def save(self, model_path: Union[str, Path]):
"""Save the OctoModel to disk.
The current format used is a simple tar of the exported model library (exe.so),
Expand Down Expand Up @@ -139,7 +136,7 @@ def load(self, model_path: Union[str, Path]) -> Tuple[relax.Executable, Dict[Lis
return exe, input_info

def generate_inputs(self) -> Dict[str, np.array]:
"""Generate random inputs for inference or benchmarking
"""Generate random inputs based on 'self.input_info' for inference or benchmarking
Returns
-------
Expand Down
49 changes: 24 additions & 25 deletions python/tvm/octo/utils/target_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,30 @@ def get_llvm_target() -> tvm.target.Target:
# Next extract attribute string.
platform = sys.platform
# Linux
if platform in ["linux", "linux2"]:
output = subprocess.check_output("lscpu", shell=True).decode()
# The output of lscpu produces a bunch of lines with the format
# "Title: Value". This pattern matches both the title and value
# parts of each line so that we can construct a dictionary.
pattern = r"^([^:]+):\s+(.*)$"
cpu_info = {}

for line in output.splitlines():
match = re.match(pattern, line)
if match:
key = match.group(1)
value = match.group(2)
cpu_info[key] = value.lower().strip()

features = cpu_info["Flags"].split(" ")
march = cpu_info["Architecture"]
cores = cpu_info["Core(s) per socket"]
sockets = cpu_info["Socket(s)"]
total_cores = str(int(cores) * int(sockets))
# Special case for x86_64 mismatch between underscore and hyphen
if march == "x86_64":
march = "x86-64"
else:
if platform not in ["linux", "linux2"]:
raise ValueError("Platform %s is not supported." % platform)
output = subprocess.check_output("lscpu", shell=True).decode()
# The output of lscpu produces a bunch of lines with the format
# "Title: Value". This pattern matches both the title and value
# parts of each line so that we can construct a dictionary.
pattern = r"^([^:]+):\s+(.*)$"
cpu_info = {}

for line in output.splitlines():
match = re.match(pattern, line)
if match:
key = match.group(1)
value = match.group(2)
cpu_info[key] = value.lower().strip()

features = cpu_info["Flags"].split(" ")
march = cpu_info["Architecture"]
cores = cpu_info["Core(s) per socket"]
sockets = cpu_info["Socket(s)"]
total_cores = str(int(cores) * int(sockets))
# Special case for x86_64 mismatch between underscore and hyphen
if march == "x86_64":
march = "x86-64"

# Now we'll extract the architecture of the target.
output = subprocess.check_output("llc --version", shell=True).decode()
Expand All @@ -86,7 +85,7 @@ def get_llvm_target() -> tvm.target.Target:
host_target = (
subprocess.check_output("llvm-config --host-target", shell=True).decode().strip("\n")
)
target = "llvm -mcpu=%s -mtriple=%s -num-cores=%s" % (cpu, host_target, total_cores)
target = f"llvm -mcpu={cpu} -mtriple={host_target} -num-cores={total_cores}"

# If possible, add more attribute information.
if not valid_march:
Expand Down
6 changes: 0 additions & 6 deletions src/meta_schedule/space_generator/post_order_apply.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,5 @@ TVM_REGISTER_NODE_TYPE(PostOrderApplyNode);
TVM_REGISTER_GLOBAL("meta_schedule.SpaceGeneratorPostOrderApply")
.set_body_typed(SpaceGenerator::PostOrderApply);

TVM_REGISTER_GLOBAL("tvm.meta_schedule.collect_blocks")
.set_body_typed([](const tir::Schedule& sch,
const runtime::PackedFunc f_block_filter = nullptr) {
return BlockCollector::Collect(sch, f_block_filter);
});

} // namespace meta_schedule
} // namespace tvm

0 comments on commit 6ff2171

Please sign in to comment.