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
28 changes: 1 addition & 27 deletions python/tvm/meta_schedule/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
# under the License.
"""Utilities for meta schedule"""
import ctypes
import json
import logging
import os
import shutil
from contextlib import contextmanager
from typing import Any, List, Dict, Callable, Optional, Union
from typing import Any, Callable, Dict, List, Optional, Union

import psutil # type: ignore
from tvm._ffi import get_global_func, register_func
Expand Down Expand Up @@ -296,31 +295,6 @@ def _json_de_tvm(obj: Any) -> Any:
raise TypeError("Not supported type: " + str(type(obj)))


@register_func("meta_schedule.json_obj2str")
def json_obj2str(json_obj: Any) -> str:
json_obj = _json_de_tvm(json_obj)
return json.dumps(json_obj)


@register_func("meta_schedule.batch_json_str2obj")
def batch_json_str2obj(json_strs: List[str]) -> List[Any]:
"""Covert a list of JSON strings to a list of json objects.
Parameters
----------
json_strs : List[str]
The list of JSON strings
Returns
-------
result : List[Any]
The list of json objects
"""
return [
json.loads(json_str)
for json_str in map(str.strip, json_strs)
if json_str and (not json_str.startswith("#")) and (not json_str.startswith("//"))
]


def shash2hex(mod: IRModule) -> str:
"""Get the structural hash of a module.

Expand Down
2 changes: 1 addition & 1 deletion src/meta_schedule/arg_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ TensorInfo TensorInfo::FromJSON(const ObjectRef& json_obj) {
dtype = runtime::String2DLDataType(dtype_str);
}
// Load json[2] => shape
shape = Downcast<Array<Integer>>(json_array->at(2));
shape = AsIntArray(json_array->at(2));
} catch (const std::runtime_error& e) { // includes tvm::Error and dmlc::Error
LOG(FATAL) << "ValueError: Unable to parse the JSON object: " << json_obj
<< "\nThe error is: " << e.what();
Expand Down
2 changes: 1 addition & 1 deletion src/meta_schedule/database/database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ TuningRecord TuningRecord::FromJSON(const ObjectRef& json_obj, const Workload& w
CHECK(json_array && json_array->size() == 4);
// Load json[1] => run_secs
if (json_array->at(1).defined()) {
run_secs = Downcast<Array<FloatImm>>(json_array->at(1));
run_secs = AsFloatArray(json_array->at(1));
}
// Load json[2] => target
if (json_array->at(2).defined()) {
Expand Down
Loading