Skip to content

[Bug] TVMError: Do not have a default for tir.Evaluate #17973

@Cookiee235

Description

@Cookiee235

Actual behavior

Traceback (most recent call last):
  File "/data/qshenaf/remote_pc/TirFuzz/bugs/topi.topk_0.py", line 10, in <module>
    database = ms.tir_integration.tune_tir(mod=sch.mod, target='llvm --num-cores=16', work_dir='./tune_tmp', max_trials_global=1, num_trials_per_iter=1)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/qshenaf/envs/tvm/python/tvm/meta_schedule/tir_integration.py", line 146, in tune_tir
    return tune_tasks(
           ^^^^^^^^^^^
  File "/data/qshenaf/envs/tvm/python/tvm/meta_schedule/tune.py", line 122, in tune_tasks
    task_scheduler.tune(
  File "/data/qshenaf/envs/tvm/python/tvm/meta_schedule/task_scheduler/task_scheduler.py", line 132, in tune
    _ffi_api.TaskSchedulerTune(  # type: ignore # pylint: disable=no-member
  File "tvm/_ffi/_cython/./packed_func.pxi", line 339, in tvm._ffi._cy3.core.PackedFuncBase.__call__
  File "tvm/_ffi/_cython/./packed_func.pxi", line 284, in tvm._ffi._cy3.core.FuncCall
  File "tvm/_ffi/_cython/./base.pxi", line 185, in tvm._ffi._cy3.core.CHECK_CALL
  File "/data/qshenaf/envs/tvm/python/tvm/_ffi/base.py", line 468, in raise_last_ffi_error
    raise py_err
  File "/data/qshenaf/envs/tvm/src/meta_schedule/task_scheduler/gradient_based.cc", line 54, in tvm::meta_schedule::GradientBasedNode::Tune(tvm::runtime::Array<tvm::meta_schedule::TuneContext, void>, tvm::runtime::Array<tvm::FloatImm, void>, int, int, int, tvm::meta_schedule::Builder, tvm::meta_schedule::Runner, tvm::runtime::Array<tvm::meta_schedule::MeasureCallback, void>, tvm::runtime::Optional<tvm::meta_schedule::Database>, tvm::runtime::Optional<tvm::meta_schedule::CostModel>)
    TaskSchedulerNode::Tune(tasks, task_weights, max_trials_global, max_trials_per_task,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/qshenaf/envs/tvm/src/meta_schedule/task_scheduler/task_scheduler.cc", line 161, in tvm::meta_schedule::TaskSchedulerNode::Tune(tvm::runtime::Array<tvm::meta_schedule::TuneContext, void>, tvm::runtime::Array<tvm::FloatImm, void>, int, int, int, tvm::meta_schedule::Builder, tvm::meta_schedule::Runner, tvm::runtime::Array<tvm::meta_schedule::MeasureCallback, void>, tvm::runtime::Optional<tvm::meta_schedule::Database>, tvm::runtime::Optional<tvm::meta_schedule::CostModel>)
    this->tasks_.push_back(TaskRecord(ctx, weight));
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/qshenaf/envs/tvm/src/meta_schedule/task_scheduler/task_scheduler.cc", line 37, in tvm::meta_schedule::TaskRecord::TaskRecord(tvm::meta_schedule::TuneContext, double)
    n->flop = std::max(1.0, tir::EstimateTIRFlops(ctx->mod.value()));
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc", line 231, in tvm::tir::EstimateTIRFlops(tvm::IRModule const&)
    VisitPrimFuncs(mod, [&result, &counter, &cached_result](const PrimFuncNode* f) {
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/qshenaf/envs/tvm/include/tvm/tir/analysis.h", line 77, in VisitPrimFuncs<tvm::tir::EstimateTIRFlops(const tvm::IRModule&)::<lambda(const tvm::tir::PrimFuncNode*)> >
    fvisit(prim_func);
                ^^^^^^^
  File "/data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc", line 235, in operator()
    result += counter.VisitStmt(f->body);  //
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc", line 93, in tvm::tir::FlopEstimator::VisitStmt(tvm::tir::Stmt const&)
    TResult VisitStmt(const Stmt& stmt) override { return StmtFunctor::VisitStmt(stmt); }
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
tvm._ffi.base.TVMError: Traceback (most recent call last):
  7: tvm::meta_schedule::GradientBasedNode::Tune(tvm::runtime::Array<tvm::meta_schedule::TuneContext, void>, tvm::runtime::Array<tvm::FloatImm, void>, int, int, int, tvm::meta_schedule::Builder, tvm::meta_schedule::Runner, tvm::runtime::Array<tvm::meta_schedule::MeasureCallback, void>, tvm::runtime::Optional<tvm::meta_schedule::Database>, tvm::runtime::Optional<tvm::meta_schedule::CostModel>)
        at /data/qshenaf/envs/tvm/src/meta_schedule/task_scheduler/gradient_based.cc:54
  6: tvm::meta_schedule::TaskSchedulerNode::Tune(tvm::runtime::Array<tvm::meta_schedule::TuneContext, void>, tvm::runtime::Array<tvm::FloatImm, void>, int, int, int, tvm::meta_schedule::Builder, tvm::meta_schedule::Runner, tvm::runtime::Array<tvm::meta_schedule::MeasureCallback, void>, tvm::runtime::Optional<tvm::meta_schedule::Database>, tvm::runtime::Optional<tvm::meta_schedule::CostModel>)
        at /data/qshenaf/envs/tvm/src/meta_schedule/task_scheduler/task_scheduler.cc:161
  5: tvm::meta_schedule::TaskRecord::TaskRecord(tvm::meta_schedule::TuneContext, double)
        at /data/qshenaf/envs/tvm/src/meta_schedule/task_scheduler/task_scheduler.cc:37
  4: tvm::tir::EstimateTIRFlops(tvm::IRModule const&)
        at /data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc:231
  3: VisitPrimFuncs<tvm::tir::EstimateTIRFlops(const tvm::IRModule&)::<lambda(const tvm::tir::PrimFuncNode*)> >
        at /data/qshenaf/envs/tvm/include/tvm/tir/analysis.h:77
  2: operator()
        at /data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc:235
  1: tvm::tir::FlopEstimator::VisitStmt(tvm::tir::Stmt const&)
        at /data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc:93
  0: non-virtual thunk to tvm::tir::FlopEstimator::VisitStmt_(tvm::tir::BlockRealizeNode const*)
  File "/data/qshenaf/envs/tvm/include/tvm/tir/stmt_functor.h", line 104
TVMError: Do not have a default for tir.Evaluate

Environment

tvm-0.21.dev0

Steps to reproduce

import tvm
from tvm import te, topi, tir
from tvm import meta_schedule as ms


data = te.placeholder((128, 64), dtype='float32', name='data')
op_output = topi.topk(data, k=10, axis=1, ret_type='both')
sch = tir.Schedule(te.create_prim_func([data] + op_output))
print(sch.mod)
database = ms.tir_integration.tune_tir(mod=sch.mod, target='llvm --num-cores=16', work_dir='./tune_tmp', max_trials_global=1, num_trials_per_iter=1)

Triage

  • needs-triage
  • tune:meta_schedule

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triagePRs or issues that need to be investigated by maintainers to find the right assignees to address ittype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions