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

Misc improvement over the error message #545

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
15 changes: 11 additions & 4 deletions python/tvm/meta_schedule/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@
# specific language governing permissions and limitations
# under the License.
"""Utilities for meta schedule"""
from typing import Any, Callable, List, Optional, Union

import ctypes
import json
import os
import shutil
import psutil # type: ignore
from typing import Any, Callable, List, Optional, Union

import psutil
import tvm
from tvm._ffi import get_global_func, register_func
from tvm.error import TVMError
from tvm.ir import Array, Map, IRModule
from tvm.ir import Array, IRModule, Map
from tvm.rpc import RPCSession
from tvm.runtime import PackedFunc, String
from tvm.tir import FloatImm, IntImm
Expand Down Expand Up @@ -61,6 +60,14 @@ def _cpu_count_impl(logical: bool = True) -> int:
return psutil.cpu_count(logical=logical) or 1


@register_func("meta_schedule._process_error_message")
def _process_error_message(error_msg: str) -> str:
error_msg_lines = str(error_msg).splitlines()
if len(error_msg_lines) >= 50:
return "\n".join(error_msg_lines[:25] + ["..."] + error_msg_lines[-25:])
return error_msg


def cpu_count(logical: bool = True) -> int:
"""Return the number of logical or physical CPUs in the system

Expand Down
15 changes: 10 additions & 5 deletions src/meta_schedule/measure_callback/echo_statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,21 @@ struct TaskInfo {
best_round = trials;
best_gflops = flop / run_ms / 1e6;
}
LOG(INFO) << "[" << name //
<< "] Trial #" << trials //
LOG(INFO) << "[" << name << "] Trial #" << trials //
<< std::fixed << std::setprecision(4) //
<< ": GFLOPs: " << (flop / run_ms / 1e6) //
<< ". Time: " << run_ms << " ms" //
<< ". Best GFLOPs: " << best_gflops;
}

void UpdateError(const String& err, const MeasureCandidate& candidate) {
void UpdateError(std::string err, const MeasureCandidate& candidate) {
static const auto* f_proc = runtime::Registry::Get("meta_schedule._process_error_message");
ICHECK(f_proc != nullptr);
err = (*f_proc)(err).operator std::string();
++error_count;
LOG(INFO) << "[" << name //
<< "] Trial #" << trials //
++trials;
LOG(INFO) << "[" << name << "] Trial #" << trials //
<< std::fixed << std::setprecision(4) //
<< ": Error in building: " << err << "\n"
<< tir::AsTVMScript(candidate->sch->mod()) << "\n"
<< Concat(candidate->sch->trace().value()->AsPython(false), "\n");
Expand Down
2 changes: 1 addition & 1 deletion src/meta_schedule/search_strategy/evolutionary_search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ inline std::vector<CachedTrace> EvolutionarySearchNode::State::SampleInitPopulat

inline std::vector<CachedTrace> EvolutionarySearchNode::State::MergeSamples(
const std::vector<CachedTrace>& measured, const std::vector<CachedTrace>& unmeasured) {
ICHECK(measured.size() + unmeasured.size() == self->population)
ICHECK_EQ(measured.size() + unmeasured.size(), self->population)
<< "Num of total init samples does not equal to population size!";
std::vector<CachedTrace> inits;
inits.reserve(self->population);
Expand Down