Skip to content

[Bug][MetaSchedule] TVMError: Do not have a default for tir.While #17960

@Cookiee235

Description

@Cookiee235

Actual behavior

Traceback (most recent call last):
  File "/data/qshenaf/remote_pc/TirFuzz/bugs/topi.searchsorted_0.py", line 11, 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); }
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc", line 161, in tvm::tir::FlopEstimator::VisitStmt_(tvm::tir::ForNode const*)
    TResult result = VisitStmt(loop->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); }
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc", line 200, in tvm::tir::FlopEstimator::VisitStmt_(tvm::tir::SeqStmtNode const*)
    result += VisitStmt(stmt);
                ^^^^^^^^^^^^^^^
  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):
  15: 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
  14: 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
  13: tvm::meta_schedule::TaskRecord::TaskRecord(tvm::meta_schedule::TuneContext, double)
        at /data/qshenaf/envs/tvm/src/meta_schedule/task_scheduler/task_scheduler.cc:37
  12: tvm::tir::EstimateTIRFlops(tvm::IRModule const&)
        at /data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc:231
  11: VisitPrimFuncs<tvm::tir::EstimateTIRFlops(const tvm::IRModule&)::<lambda(const tvm::tir::PrimFuncNode*)> >
        at /data/qshenaf/envs/tvm/include/tvm/tir/analysis.h:77
  10: operator()
        at /data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc:235
  9: tvm::tir::FlopEstimator::VisitStmt(tvm::tir::Stmt const&)
        at /data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc:93
  8: non-virtual thunk to tvm::tir::FlopEstimator::VisitStmt_(tvm::tir::BlockRealizeNode const*)
  7: _ZThn8_N3tvm3tir13FlopEstimat
  6: tvm::tir::FlopEstimator::VisitStmt_(tvm::tir::ForNode const*)
        at /data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc:161
  5: tvm::tir::FlopEstimator::VisitStmt(tvm::tir::Stmt const&)
        at /data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc:93
  4: non-virtual thunk to tvm::tir::FlopEstimator::VisitStmt_(tvm::tir::AllocateNode const*)
  3: non-virtual thunk to tvm::tir::FlopEstimator::VisitStmt_(tvm::tir::AllocateNode const*)
  2: _ZThn8_N3tvm3tir13FlopEstimat
  1: tvm::tir::FlopEstimator::VisitStmt_(tvm::tir::SeqStmtNode const*)
        at /data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc:200
  0: tvm::tir::FlopEstimator::VisitStmt(tvm::tir::Stmt const&)
        at /data/qshenaf/envs/tvm/src/tir/analysis/estimate_flops.cc:93
  File "/data/qshenaf/envs/tvm/include/tvm/tir/stmt_functor.h", line 104
TVMError: Do not have a default for tir.While

Environment

tvm-0.21.dev0

Steps to reproduce

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


sorted_sequence = te.placeholder((10,), dtype='int32', name='sorted_sequence')
values = te.placeholder((5,), dtype='int32', name='values')
op_output = topi.searchsorted(sorted_sequence,values,right=False)
sch = tir.Schedule(te.create_prim_func([sorted_sequence, values, 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

Please refer to the list of label tags here to find the relevant tags and add them below in a bullet format (example below).

  • needs-triage
  • tune:meta_schedule

cc @ibsidorenko

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