diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ddf57ce7f5d..a6e84b86a429 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,7 +185,7 @@ assign_source_group("Include" ${GROUP_INCLUDE}) # Source file lists file(GLOB_RECURSE COMPILER_SRCS - src/auto_schedule/*.cc + src/auto_scheduler/*.cc src/node/*.cc src/ir/*.cc src/arith/*.cc diff --git a/python/tvm/auto_schedule/__init__.py b/python/tvm/auto_scheduler/__init__.py similarity index 100% rename from python/tvm/auto_schedule/__init__.py rename to python/tvm/auto_scheduler/__init__.py diff --git a/python/tvm/auto_schedule/_ffi_api.py b/python/tvm/auto_scheduler/_ffi_api.py similarity index 93% rename from python/tvm/auto_schedule/_ffi_api.py rename to python/tvm/auto_scheduler/_ffi_api.py index 9d2b9865ae95..d7b874f71e0f 100644 --- a/python/tvm/auto_schedule/_ffi_api.py +++ b/python/tvm/auto_scheduler/_ffi_api.py @@ -15,8 +15,8 @@ # specific language governing permissions and limitations # under the License. -""" Register FFI APIs from C++ for the namespace tvm.auto_schedule. """ +""" Register FFI APIs from C++ for the namespace tvm.auto_scheduler. """ import tvm._ffi -tvm._ffi._init_api("auto_schedule", __name__) +tvm._ffi._init_api("auto_scheduler", __name__) diff --git a/python/tvm/auto_schedule/auto_schedule.py b/python/tvm/auto_scheduler/auto_schedule.py similarity index 90% rename from python/tvm/auto_schedule/auto_schedule.py rename to python/tvm/auto_scheduler/auto_schedule.py index ffbfc3c914ff..d45dbf8d0aaa 100644 --- a/python/tvm/auto_schedule/auto_schedule.py +++ b/python/tvm/auto_scheduler/auto_schedule.py @@ -34,7 +34,7 @@ from . import _ffi_api -@tvm._ffi.register_object("auto_schedule.HardwareParams") +@tvm._ffi.register_object("auto_scheduler.HardwareParams") class HardwareParams(Object): """ The parameters of target hardware used to guide the search policy @@ -55,7 +55,7 @@ def __init__(self, num_cores, vector_unit_bytes, cache_line_bytes): vector_unit_bytes, cache_line_bytes) -@tvm._ffi.register_object("auto_schedule.SearchTask") +@tvm._ffi.register_object("auto_scheduler.SearchTask") class SearchTask(Object): """ The computation information and hardware parameters for a specific schedule search task. @@ -79,12 +79,12 @@ def __init__(self, dag, workload_key, target, target_host=None, hardware_params) -@tvm._ffi.register_object("auto_schedule.SearchPolicy") +@tvm._ffi.register_object("auto_scheduler.SearchPolicy") class SearchPolicy(Object): """ The base class of search policies. """ -@tvm._ffi.register_object("auto_schedule.EmptyPolicy") +@tvm._ffi.register_object("auto_scheduler.EmptyPolicy") class EmptyPolicy(SearchPolicy): """ This is an example empty search policy which will always generate the init state of ComputeDAG. @@ -93,7 +93,7 @@ def __init__(self): self.__init_handle_by_constructor__(_ffi_api.EmptyPolicy) -@tvm._ffi.register_object("auto_schedule.TuningOptions") +@tvm._ffi.register_object("auto_scheduler.TuningOptions") class TuningOptions(Object): """ This controls the options of performance tuning. @@ -120,12 +120,12 @@ class TuningOptions(Object): measure_callbacks: Optional[List[MeasureCallback]] Callback functions called after each measurement. Candidates: - - auto_schedule.RecordToFile + - auto_scheduler.RecordToFile pre_search_callbacks: Optional[List[SearchCallback]] Callback functions called before the search process. Candidates: - - auto_schedule.PreloadMeasuredStates - - auto_schedule.PreloadCustomSketchRule + - auto_scheduler.PreloadMeasuredStates + - auto_scheduler.PreloadCustomSketchRule TODO(jcf94): Add these implementation in later PRs. """ def __init__(self, num_measure_trials=0, early_stopping=None, num_measures_per_round=64, @@ -136,7 +136,7 @@ def __init__(self, num_measure_trials=0, early_stopping=None, num_measures_per_r builder = LocalBuilder() else: raise ValueError("Invalid builder: " + builder) - elif not isinstance(builder, tvm.auto_schedule.measure.ProgramBuilder): + elif not isinstance(builder, tvm.auto_scheduler.measure.ProgramBuilder): raise ValueError("Invalid builder: " + builder + " . TuningOptions expects a ProgramBuilder or string.") @@ -145,7 +145,7 @@ def __init__(self, num_measure_trials=0, early_stopping=None, num_measures_per_r runner = LocalRunner() else: raise ValueError("Invalid runner: " + runner) - elif not isinstance(runner, tvm.auto_schedule.measure.ProgramRunner): + elif not isinstance(runner, tvm.auto_scheduler.measure.ProgramRunner): raise ValueError("Invalid runner: " + runner + " . TuningOptions expects a ProgramRunner or string.") @@ -176,7 +176,7 @@ def auto_schedule(task, search_policy='default', tuning_options=None): """ if not isinstance(task, SearchTask): raise ValueError("Invalid task: " + task + - " . `auto_schedule.auto_schedule` expects a SearchTask.") + " . `auto_scheduler.auto_schedule` expects a SearchTask.") if isinstance(search_policy, str): if search_policy == 'default': @@ -187,7 +187,7 @@ def auto_schedule(task, search_policy='default', tuning_options=None): raise ValueError("Invalid search policy: " + search_policy) elif not isinstance(search_policy, SearchPolicy): raise ValueError("Invalid search policy: " + search_policy + - " . `auto_schedule.auto_schedule` expects a SearchPolicy or a string.") + " . `auto_scheduler.auto_schedule` expects a SearchPolicy or a string.") sch, tensors = _ffi_api.AutoSchedule(task, search_policy, tuning_options if tuning_options else TuningOptions()) diff --git a/python/tvm/auto_schedule/compute_dag.py b/python/tvm/auto_scheduler/compute_dag.py similarity index 99% rename from python/tvm/auto_schedule/compute_dag.py rename to python/tvm/auto_scheduler/compute_dag.py index a4738a933b3e..115d28b4d478 100644 --- a/python/tvm/auto_schedule/compute_dag.py +++ b/python/tvm/auto_scheduler/compute_dag.py @@ -30,7 +30,7 @@ from . import _ffi_api -@tvm._ffi.register_object("auto_schedule.ComputeDAG") +@tvm._ffi.register_object("auto_scheduler.ComputeDAG") class ComputeDAG(Object): """ The TVM Auto-scheduler computational graph and related program analyses. diff --git a/python/tvm/auto_schedule/loop_state.py b/python/tvm/auto_scheduler/loop_state.py similarity index 97% rename from python/tvm/auto_schedule/loop_state.py rename to python/tvm/auto_scheduler/loop_state.py index 7b8804c8be60..693a668a158e 100644 --- a/python/tvm/auto_schedule/loop_state.py +++ b/python/tvm/auto_scheduler/loop_state.py @@ -48,17 +48,17 @@ from . import _ffi_api -@tvm._ffi.register_object("auto_schedule.Iterator") +@tvm._ffi.register_object("auto_scheduler.Iterator") class Iterator(Object): """ A loop iterator structure. """ -@tvm._ffi.register_object("auto_schedule.Stage") +@tvm._ffi.register_object("auto_scheduler.Stage") class Stage(Object): """ A stage in the compute declaration. Similar to tvm.te.schedule.Stage. """ -@tvm._ffi.register_object("auto_schedule.State") +@tvm._ffi.register_object("auto_scheduler.State") class StateObject(Object): """ The internal State object """ def __eq__(self, other): diff --git a/python/tvm/auto_schedule/measure.py b/python/tvm/auto_scheduler/measure.py similarity index 96% rename from python/tvm/auto_schedule/measure.py rename to python/tvm/auto_scheduler/measure.py index 24e2af1d8f49..e99c47e6262c 100644 --- a/python/tvm/auto_schedule/measure.py +++ b/python/tvm/auto_scheduler/measure.py @@ -54,12 +54,12 @@ # This can avoid expensive serialization of TVM IR when using multiprocessing.Pool GLOBAL_BUILD_ARGUMENTS = None -@tvm._ffi.register_object("auto_schedule.MeasureCallback") +@tvm._ffi.register_object("auto_scheduler.MeasureCallback") class MeasureCallback(Object): """ The base class of measurement callback functions. """ -@tvm._ffi.register_object("auto_schedule.MeasureInput") +@tvm._ffi.register_object("auto_scheduler.MeasureInput") class MeasureInput(Object): """ Store the input of a measurement. @@ -74,7 +74,7 @@ def __init__(self, task, state): self.__init_handle_by_constructor__(_ffi_api.MeasureInput, task, state.state_object) -@tvm._ffi.register_object("auto_schedule.BuildResult") +@tvm._ffi.register_object("auto_scheduler.BuildResult") class BuildResult(Object): """ Store the result of a build. @@ -99,7 +99,7 @@ def __init__(self, filename, args, error_no, error_msg, time_cost): _ffi_api.BuildResult, filename, args, error_no, error_msg, time_cost) -@tvm._ffi.register_object("auto_schedule.MeasureResult") +@tvm._ffi.register_object("auto_scheduler.MeasureResult") class MeasureResult(Object): """ Store the results of a measurement. @@ -124,7 +124,7 @@ def __init__(self, costs, error_no, error_msg, all_cost, timestamp): error_msg, all_cost, timestamp) -@tvm._ffi.register_object("auto_schedule.ProgramBuilder") +@tvm._ffi.register_object("auto_scheduler.ProgramBuilder") class ProgramBuilder(Object): """ The base class of ProgramBuilders. """ @@ -145,7 +145,7 @@ def build(self, measure_inputs, verbose=1): return _ffi_api.ProgramBuilderBuild(self, measure_inputs, verbose) -@tvm._ffi.register_object("auto_schedule.ProgramRunner") +@tvm._ffi.register_object("auto_scheduler.ProgramRunner") class ProgramRunner(Object): """ The base class of ProgramRunners. """ @@ -168,7 +168,7 @@ def run(self, measure_inputs, build_results, verbose=1): return _ffi_api.ProgramRunnerRun(self, measure_inputs, build_results, verbose) -@tvm._ffi.register_object("auto_schedule.LocalBuilder") +@tvm._ffi.register_object("auto_scheduler.LocalBuilder") class LocalBuilder(ProgramBuilder): """ LocalBuilder use local CPU cores to build programs in parallel. @@ -191,7 +191,7 @@ def __init__(self, _ffi_api.LocalBuilder, timeout, n_parallel, build_func) -@tvm._ffi.register_object("auto_schedule.LocalRunner") +@tvm._ffi.register_object("auto_scheduler.LocalRunner") class LocalRunner(ProgramRunner): """ LocalRunner that uses local CPU/GPU to measures the time cost of programs. @@ -334,7 +334,7 @@ def timed_func(): return res -@tvm._ffi.register_func("auto_schedule.local_builder.build") +@tvm._ffi.register_func("auto_scheduler.local_builder.build") def local_builder_build(inputs, timeout, n_parallel, build_func='default', verbose=1): """ Build function of LocalBuilder to build the MeasureInputs to runnable modules. @@ -376,7 +376,7 @@ def local_builder_build(inputs, timeout, n_parallel, build_func='default', verbo return results -@tvm._ffi.register_func("auto_schedule.local_runner.run") +@tvm._ffi.register_func("auto_scheduler.local_runner.run") def local_run(inputs, build_results, timeout, number, repeat, min_repeat_ms, cooldown_interval, verbose=1): """ diff --git a/python/tvm/auto_schedule/measure_record.py b/python/tvm/auto_scheduler/measure_record.py similarity index 94% rename from python/tvm/auto_schedule/measure_record.py rename to python/tvm/auto_scheduler/measure_record.py index 25a998566280..2a4cd2957a0a 100644 --- a/python/tvm/auto_schedule/measure_record.py +++ b/python/tvm/auto_scheduler/measure_record.py @@ -25,7 +25,7 @@ from . import _ffi_api -@tvm._ffi.register_object("auto_schedule.RecordToFile") +@tvm._ffi.register_object("auto_scheduler.RecordToFile") class RecordToFile(MeasureCallback): """ A measurement callback that writes measurement records into a file. @@ -35,21 +35,21 @@ class RecordToFile(MeasureCallback): filename : str File name for this callback to write log to. """ - def __init__(self, filename="auto_schedule_tuning.json"): + def __init__(self, filename="auto_scheduler_tuning.json"): self.__init_handle_by_constructor__(_ffi_api.RecordToFile, filename) -@tvm._ffi.register_object("auto_schedule.RecordReader") +@tvm._ffi.register_object("auto_scheduler.RecordReader") class RecordReader(Object): """ Reader of the json log file. Parameters ---------- - filename : str = "auto_schedule_tuning.json" + filename : str = "auto_scheduler_tuning.json" File name for this reader to load log from. """ - def __init__(self, filename="auto_schedule_tuning.json"): + def __init__(self, filename="auto_scheduler_tuning.json"): self.__init_handle_by_constructor__(_ffi_api.RecordReader, filename) def read_lines(self, max_lines=None, skip_lines=0): diff --git a/python/tvm/auto_schedule/utils.py b/python/tvm/auto_scheduler/utils.py similarity index 99% rename from python/tvm/auto_schedule/utils.py rename to python/tvm/auto_scheduler/utils.py index c29675074e22..f7b12028fc36 100644 --- a/python/tvm/auto_schedule/utils.py +++ b/python/tvm/auto_scheduler/utils.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -""" Common utilities for auto_schedule. """ +""" Common utilities for auto_scheduler. """ from typing import Hashable import multiprocessing diff --git a/python/tvm/auto_schedule/workload_registry.py b/python/tvm/auto_scheduler/workload_registry.py similarity index 97% rename from python/tvm/auto_schedule/workload_registry.py rename to python/tvm/auto_scheduler/workload_registry.py index b50727ec955e..36c203781073 100644 --- a/python/tvm/auto_schedule/workload_registry.py +++ b/python/tvm/auto_scheduler/workload_registry.py @@ -55,7 +55,7 @@ def register_workload(func_name, f=None, override=False): Examples -------- - @auto_schedule.register_workload + @auto_scheduler.register_workload def matmul(N, M, K): A = te.placeholder((N, K), name='A') B = te.placeholder((K, M), name='B') @@ -110,7 +110,7 @@ def make_workload_key(func, args): if not func_name in WORKLOAD_FUNC_REGISTRY: raise ValueError("%s is not registered. " % func, - "Please register it with @auto_schedule.register_workload") + "Please register it with @auto_scheduler.register_workload") args = serialize_args(args) @@ -137,11 +137,11 @@ def decode_workload_key_to_func_args(workload_key): workload = json.loads(workload_key) if not workload[0] in WORKLOAD_FUNC_REGISTRY: raise ValueError("%s is not registered. " % workload[0] + - "Please register it with @auto_schedule.register_workload") + "Please register it with @auto_scheduler.register_workload") return workload[0], deserialize_args(workload[1:]) -@tvm._ffi.register_func("auto_schedule.workload_key_to_tensors") +@tvm._ffi.register_func("auto_scheduler.workload_key_to_tensors") def workload_key_to_tensors(workload_key): """ Get the input/output tensors from the workload key. diff --git a/src/auto_schedule/auto_schedule.cc b/src/auto_scheduler/auto_schedule.cc similarity index 88% rename from src/auto_schedule/auto_schedule.cc rename to src/auto_scheduler/auto_schedule.cc index aaf472b1f26a..b515b3accf7a 100644 --- a/src/auto_schedule/auto_schedule.cc +++ b/src/auto_scheduler/auto_schedule.cc @@ -18,8 +18,10 @@ */ /*! - * \file auto_schedule/auto_schedule.cc - * \brief The user interface of the TVM Auto-scheduler. + * \file auto_scheduler/auto_schedule.cc + * \brief The user interface of the TVM Auto-scheduler. This is the entry structure to get + * schedule search requirements from upper level (Python API), and returns a high performance + * schedule after search process. */ #include "auto_schedule.h" @@ -27,7 +29,7 @@ #include namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { TVM_REGISTER_NODE_TYPE(TuningOptionsNode); @@ -61,7 +63,7 @@ std::pair> AutoSchedule(SearchTask task, SearchP return task->compute_dag.ApplySteps(state->transform_steps); } -TVM_REGISTER_GLOBAL("auto_schedule.TuningOptions") +TVM_REGISTER_GLOBAL("auto_scheduler.TuningOptions") .set_body_typed([](int num_measure_trials, int early_stopping, int num_measures_per_round, int verbose, ProgramBuilder builder, ProgramRunner runner, Optional> measure_callbacks, @@ -70,12 +72,12 @@ TVM_REGISTER_GLOBAL("auto_schedule.TuningOptions") builder, runner, measure_callbacks, pre_search_callbacks); }); -TVM_REGISTER_GLOBAL("auto_schedule.AutoSchedule") +TVM_REGISTER_GLOBAL("auto_scheduler.AutoSchedule") .set_body_typed([](SearchTask task, SearchPolicy search_policy, TuningOptions tuning_options) { te::Schedule sch; Array return_tensors; std::tie(sch, return_tensors) = AutoSchedule(task, search_policy, tuning_options); return Array{sch, return_tensors}; }); -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm diff --git a/src/auto_schedule/auto_schedule.h b/src/auto_scheduler/auto_schedule.h similarity index 93% rename from src/auto_schedule/auto_schedule.h rename to src/auto_scheduler/auto_schedule.h index d2e49bbe7e4f..55c6992dfd4e 100644 --- a/src/auto_schedule/auto_schedule.h +++ b/src/auto_scheduler/auto_schedule.h @@ -18,14 +18,14 @@ */ /*! - * \file auto_schedule/auto_schedule.h + * \file auto_scheduler/auto_schedule.h * \brief The user interface of the TVM Auto-scheduler. This is the entry structure to get * schedule search requirements from upper level (Python API), and returns a high performance * schedule after search process. */ -#ifndef TVM_AUTO_SCHEDULE_AUTO_SCHEDULE_H_ -#define TVM_AUTO_SCHEDULE_AUTO_SCHEDULE_H_ +#ifndef TVM_AUTO_SCHEDULER_AUTO_SCHEDULE_H_ +#define TVM_AUTO_SCHEDULER_AUTO_SCHEDULE_H_ #include @@ -33,7 +33,7 @@ #include "search_policy/search_policy.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { /*! \brief Tuning and measurement options. */ class TuningOptionsNode : public Object { @@ -69,7 +69,7 @@ class TuningOptionsNode : public Object { v->Visit("pre_search_callbacks", &pre_search_callbacks); } - static constexpr const char* _type_key = "auto_schedule.TuningOptions"; + static constexpr const char* _type_key = "auto_scheduler.TuningOptions"; TVM_DECLARE_FINAL_OBJECT_INFO(TuningOptionsNode, Object); }; @@ -110,7 +110,7 @@ class TuningOptions : public ObjectRef { TVM_DLL std::pair> AutoSchedule(SearchTask task, SearchPolicy search_policy, TuningOptions tuning_options); -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm -#endif // TVM_AUTO_SCHEDULE_AUTO_SCHEDULE_H_ +#endif // TVM_AUTO_SCHEDULER_AUTO_SCHEDULE_H_ diff --git a/src/auto_schedule/compute_dag.cc b/src/auto_scheduler/compute_dag.cc similarity index 97% rename from src/auto_schedule/compute_dag.cc rename to src/auto_scheduler/compute_dag.cc index 312a25ad62dd..a7abcb8a7ebf 100644 --- a/src/auto_schedule/compute_dag.cc +++ b/src/auto_scheduler/compute_dag.cc @@ -18,7 +18,7 @@ */ /*! - * \file auto_schedule/compute_dag.cc + * \file auto_scheduler/compute_dag.cc * \brief Compute declaration graph and its related analysis tools. */ @@ -40,7 +40,7 @@ #include "utils.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { using namespace tvm::tir; @@ -450,11 +450,11 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) p->stream << ss.str(); }); -TVM_REGISTER_GLOBAL("auto_schedule.ComputeDAG").set_body_typed([](Array tensors) { +TVM_REGISTER_GLOBAL("auto_scheduler.ComputeDAG").set_body_typed([](Array tensors) { return ComputeDAG(tensors); }); -TVM_REGISTER_GLOBAL("auto_schedule.ComputeDAGApplyStepsFromState") +TVM_REGISTER_GLOBAL("auto_scheduler.ComputeDAGApplyStepsFromState") .set_body_typed([](const ComputeDAG& dag, const State& state) { te::Schedule sch; Array return_tensors; @@ -462,15 +462,15 @@ TVM_REGISTER_GLOBAL("auto_schedule.ComputeDAGApplyStepsFromState") return Array{sch, return_tensors}; }); -TVM_REGISTER_GLOBAL("auto_schedule.ComputeDAGPrintPythonCodeFromState") +TVM_REGISTER_GLOBAL("auto_scheduler.ComputeDAGPrintPythonCodeFromState") .set_body_typed([](const ComputeDAG& dag, const State& state) { return dag.PrintStepsAsPython(state->transform_steps); }); -TVM_REGISTER_GLOBAL("auto_schedule.ComputeDAGInferBoundFromState") +TVM_REGISTER_GLOBAL("auto_scheduler.ComputeDAGInferBoundFromState") .set_body_typed([](const ComputeDAG& dag, const State& state) { return dag.InferBound(state); }); -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm diff --git a/src/auto_schedule/compute_dag.h b/src/auto_scheduler/compute_dag.h similarity index 93% rename from src/auto_schedule/compute_dag.h rename to src/auto_scheduler/compute_dag.h index bb582d32ee7e..2417d72983b0 100644 --- a/src/auto_schedule/compute_dag.h +++ b/src/auto_scheduler/compute_dag.h @@ -18,7 +18,7 @@ */ /*! - * \file auto_schedule/compute_dag.h + * \file auto_scheduler/compute_dag.h * \brief The TVM Auto-scheduler computational graph and related program analyses. * * We convert a compute declaration described by `tvm.compute` (could be a single operator or a @@ -32,8 +32,8 @@ * `LoopState` with extra information got from TVM schedule ...). */ -#ifndef TVM_AUTO_SCHEDULE_COMPUTE_DAG_H_ -#define TVM_AUTO_SCHEDULE_COMPUTE_DAG_H_ +#ifndef TVM_AUTO_SCHEDULER_COMPUTE_DAG_H_ +#define TVM_AUTO_SCHEDULER_COMPUTE_DAG_H_ #include @@ -42,7 +42,7 @@ #include "loop_state.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { /*! \brief The TVM Auto-scheduler computational graph and related program analyses. */ class ComputeDAGNode : public Object { @@ -67,7 +67,7 @@ class ComputeDAGNode : public Object { v->Visit("init_state", &init_state); } - static constexpr const char* _type_key = "auto_schedule.ComputeDAG"; + static constexpr const char* _type_key = "auto_scheduler.ComputeDAG"; TVM_DECLARE_FINAL_OBJECT_INFO(ComputeDAGNode, Object); }; @@ -118,7 +118,7 @@ class ComputeDAG : public ObjectRef { TVM_DEFINE_OBJECT_REF_COW_METHOD(ComputeDAGNode); }; -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm -#endif // TVM_AUTO_SCHEDULE_COMPUTE_DAG_H_ +#endif // TVM_AUTO_SCHEDULER_COMPUTE_DAG_H_ diff --git a/src/auto_schedule/loop_state.cc b/src/auto_scheduler/loop_state.cc similarity index 97% rename from src/auto_schedule/loop_state.cc rename to src/auto_scheduler/loop_state.cc index 666efcebce04..1bfcb9ebc58a 100644 --- a/src/auto_schedule/loop_state.cc +++ b/src/auto_scheduler/loop_state.cc @@ -18,9 +18,9 @@ */ /*! - * \file auto_schedule/loop_state.cc + * \file auto_scheduler/loop_state.cc * \brief An lightweight IR (intermediate representation) for loop structures. - * see auto_schedule/loop_state.h for more explanation. + * see auto_scheduler/loop_state.h for more explanation. */ #include "loop_state.h" @@ -34,7 +34,7 @@ #include "utils.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { TVM_REGISTER_OBJECT_TYPE(StepNode); TVM_REGISTER_NODE_TYPE(StageNode); @@ -386,28 +386,28 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) }); /********** State interface API for ffi **********/ -TVM_REGISTER_GLOBAL("auto_schedule.StateReorder") +TVM_REGISTER_GLOBAL("auto_scheduler.StateReorder") .set_body_typed([](State state, int stage_id, const Array& order) { state.reorder(stage_id, order); return state; }); -TVM_REGISTER_GLOBAL("auto_schedule.StateSplit") +TVM_REGISTER_GLOBAL("auto_scheduler.StateSplit") .set_body_typed([](State state, int stage_id, const Iterator& it, const Array>& lengths, bool inner_to_outer) { const auto& res = state.split(stage_id, it, lengths, inner_to_outer); return Array{state, res}; }); -TVM_REGISTER_GLOBAL("auto_schedule.StateFuse") +TVM_REGISTER_GLOBAL("auto_scheduler.StateFuse") .set_body_typed([](State state, int stage_id, const Array& iters) { const auto& res = state.fuse(stage_id, iters); return Array{state, res}; }); -TVM_REGISTER_GLOBAL("auto_schedule.StateEqual").set_body_typed([](State state1, State state2) { +TVM_REGISTER_GLOBAL("auto_scheduler.StateEqual").set_body_typed([](State state1, State state2) { return std::equal_to()(state1, state2); }); -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm diff --git a/src/auto_schedule/loop_state.h b/src/auto_scheduler/loop_state.h similarity index 93% rename from src/auto_schedule/loop_state.h rename to src/auto_scheduler/loop_state.h index 5ba47b7263a1..04e5304b6943 100644 --- a/src/auto_schedule/loop_state.h +++ b/src/auto_scheduler/loop_state.h @@ -18,7 +18,7 @@ */ /*! - * \file auto_schedule/loop_state.h + * \file auto_scheduler/loop_state.h * \brief The definition of the "state" in search. * * Each LoopState corresponds to a schedule for its ComputeDAG. @@ -45,8 +45,8 @@ * copy on write style. All objects are immutable, which is similar to TVM IR. */ -#ifndef TVM_AUTO_SCHEDULE_LOOP_STATE_H_ -#define TVM_AUTO_SCHEDULE_LOOP_STATE_H_ +#ifndef TVM_AUTO_SCHEDULER_LOOP_STATE_H_ +#define TVM_AUTO_SCHEDULER_LOOP_STATE_H_ #include @@ -55,7 +55,7 @@ #include "transform_step.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { using namespace tvm::tir; @@ -135,7 +135,7 @@ class IteratorNode : public Object { v->Visit("range", &range); } - static constexpr const char* _type_key = "auto_schedule.Iterator"; + static constexpr const char* _type_key = "auto_scheduler.Iterator"; TVM_DECLARE_FINAL_OBJECT_INFO(IteratorNode, Object); }; @@ -187,7 +187,7 @@ class StageNode : public Object { v->Visit("iters", &iters); } - static constexpr const char* _type_key = "auto_schedule.Stage"; + static constexpr const char* _type_key = "auto_scheduler.Stage"; TVM_DECLARE_FINAL_OBJECT_INFO(StageNode, Object); }; @@ -241,7 +241,7 @@ class StateNode : public Object { v->Visit("concrete", &concrete); } - static constexpr const char* _type_key = "auto_schedule.State"; + static constexpr const char* _type_key = "auto_scheduler.State"; TVM_DECLARE_FINAL_OBJECT_INFO(StateNode, Object); private: @@ -347,22 +347,22 @@ class State : public ObjectRef { const Array>& lengths, bool inner_to_outer); }; -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm // Hash and equal function for State namespace std { -/*! \brief The hash function for auto_schedule::State. */ +/*! \brief The hash function for auto_scheduler::State. */ template <> -struct hash<::tvm::auto_schedule::State> { - std::size_t operator()(const ::tvm::auto_schedule::State& state) const { +struct hash<::tvm::auto_scheduler::State> { + std::size_t operator()(const ::tvm::auto_scheduler::State& state) const { return tvm::runtime::ObjectHash()(state.ToStr()); } }; /*! - * \brief The equal_to function for auto_schedule::State. + * \brief The equal_to function for auto_scheduler::State. * We use the schedule result(its string format) of a state to check if two states are `euqal`. * Equal States: 1. the transform steps are totally the same; 2. even with different steps, two * states may still result in a same schedule. e.g. To split a axis with extent 512 to 3 parts @@ -370,13 +370,13 @@ struct hash<::tvm::auto_schedule::State> { * to split from outter to inner by factors [8, 16]) */ template <> -struct equal_to<::tvm::auto_schedule::State> { - bool operator()(const ::tvm::auto_schedule::State& lhs, - const ::tvm::auto_schedule::State& rhs) const { +struct equal_to<::tvm::auto_scheduler::State> { + bool operator()(const ::tvm::auto_scheduler::State& lhs, + const ::tvm::auto_scheduler::State& rhs) const { return lhs.ToStr() == rhs.ToStr(); } }; } // namespace std -#endif // TVM_AUTO_SCHEDULE_LOOP_STATE_H_ +#endif // TVM_AUTO_SCHEDULER_LOOP_STATE_H_ diff --git a/src/auto_schedule/measure.cc b/src/auto_scheduler/measure.cc similarity index 93% rename from src/auto_schedule/measure.cc rename to src/auto_scheduler/measure.cc index b710745b02f9..3c545525f4e6 100644 --- a/src/auto_schedule/measure.cc +++ b/src/auto_scheduler/measure.cc @@ -18,7 +18,7 @@ */ /*! - * \file auto_schedule/measure.cc + * \file auto_scheduler/measure.cc * \brief Distributed measurement infrastructure to measure the runtime costs of tensor programs. */ @@ -31,7 +31,7 @@ #include "utils.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { TVM_REGISTER_NODE_TYPE(MeasureInputNode); TVM_REGISTER_NODE_TYPE(BuildResultNode); @@ -111,11 +111,11 @@ LocalBuilder::LocalBuilder(int timeout, int n_parallel, const String& build_func } Array LocalBuilderNode::Build(const Array& inputs, int verbose) { - if (const auto* f = runtime::Registry::Get("auto_schedule.local_builder.build")) { + if (const auto* f = runtime::Registry::Get("auto_scheduler.local_builder.build")) { Array results = (*f)(inputs, timeout, n_parallel, build_func, verbose); return results; } - LOG(FATAL) << "auto_schedule.local_builder.build is not registered. " + LOG(FATAL) << "auto_scheduler.local_builder.build is not registered. " << "This is a function registered in Python, " << "make sure the TVM Python runtime has been loaded successfully."; throw; @@ -135,12 +135,12 @@ LocalRunner::LocalRunner(int timeout, int number, int repeat, int min_repeat_ms, Array LocalRunnerNode::Run(const Array& inputs, const Array& build_results, int verbose) { - if (const auto* f = runtime::Registry::Get("auto_schedule.local_runner.run")) { + if (const auto* f = runtime::Registry::Get("auto_scheduler.local_runner.run")) { Array results = (*f)(inputs, build_results, timeout, number, repeat, min_repeat_ms, cooldown_interval, verbose); return results; } - LOG(FATAL) << "auto_schedule.local_runner.run is not registered. " + LOG(FATAL) << "auto_scheduler.local_runner.run is not registered. " << "This is a function registered in Python, " << "make sure the TVM Python runtime has been loaded successfully."; throw; @@ -291,41 +291,41 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) }); /********** Measure interface API for ffi **********/ -TVM_REGISTER_GLOBAL("auto_schedule.MeasureInput").set_body_typed([](SearchTask task, State state) { +TVM_REGISTER_GLOBAL("auto_scheduler.MeasureInput").set_body_typed([](SearchTask task, State state) { return MeasureInput(task, state); }); -TVM_REGISTER_GLOBAL("auto_schedule.BuildResult") +TVM_REGISTER_GLOBAL("auto_scheduler.BuildResult") .set_body_typed([](String filename, Array args, int error_no, String error_msg, double time_cost) { return BuildResult(filename, args, error_no, error_msg, time_cost); }); -TVM_REGISTER_GLOBAL("auto_schedule.MeasureResult") +TVM_REGISTER_GLOBAL("auto_scheduler.MeasureResult") .set_body_typed([](Array costs, int error_no, String error_msg, double all_cost, double timestamp) { return MeasureResult(costs, error_no, error_msg, all_cost, timestamp); }); -TVM_REGISTER_GLOBAL("auto_schedule.ProgramBuilderBuild") +TVM_REGISTER_GLOBAL("auto_scheduler.ProgramBuilderBuild") .set_body_typed([](const ProgramBuilder& builder, const Array& inputs, int verbose) { return builder->Build(inputs, verbose); }); -TVM_REGISTER_GLOBAL("auto_schedule.ProgramRunnerRun") +TVM_REGISTER_GLOBAL("auto_scheduler.ProgramRunnerRun") .set_body_typed([](const ProgramRunner& runner, const Array& inputs, const Array& build_results, int verbose) { return runner->Run(inputs, build_results, verbose); }); -TVM_REGISTER_GLOBAL("auto_schedule.LocalBuilder") +TVM_REGISTER_GLOBAL("auto_scheduler.LocalBuilder") .set_body_typed([](int timeout, int n_parallel, const String& build_func) { return LocalBuilder(timeout, n_parallel, build_func); }); -TVM_REGISTER_GLOBAL("auto_schedule.LocalRunner") +TVM_REGISTER_GLOBAL("auto_scheduler.LocalRunner") .set_body_typed([](int timeout, int number, int repeat, int min_repeat_ms, double cooldown_interval) { return LocalRunner(timeout, number, repeat, min_repeat_ms, cooldown_interval); }); -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm diff --git a/src/auto_schedule/measure.h b/src/auto_scheduler/measure.h similarity index 94% rename from src/auto_schedule/measure.h rename to src/auto_scheduler/measure.h index a7890eaffd0d..50b6fcfd6520 100644 --- a/src/auto_schedule/measure.h +++ b/src/auto_scheduler/measure.h @@ -18,7 +18,7 @@ */ /*! - * \file auto_schedule/measure.h + * \file auto_scheduler/measure.h * \brief Distributed measurement infrastructure to measure the runtime costs of tensor programs. * These functions are responsible for building the tvm module, uploading it to remote devices, * recording the running time costs, and checking the correctness of the output. @@ -33,8 +33,8 @@ * We implement these in python to utilize python's multiprocessing and error handling. */ -#ifndef TVM_AUTO_SCHEDULE_MEASURE_H_ -#define TVM_AUTO_SCHEDULE_MEASURE_H_ +#ifndef TVM_AUTO_SCHEDULER_MEASURE_H_ +#define TVM_AUTO_SCHEDULER_MEASURE_H_ #include #include @@ -44,7 +44,7 @@ #include "search_task.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { class SearchPolicy; class MeasureInput; @@ -90,7 +90,7 @@ class MeasureInputNode : public Object { /*! \brief Do shallow copy. */ MeasureInput copy() const; - static constexpr const char* _type_key = "auto_schedule.MeasureInput"; + static constexpr const char* _type_key = "auto_scheduler.MeasureInput"; TVM_DECLARE_FINAL_OBJECT_INFO(MeasureInputNode, Object); }; @@ -132,7 +132,7 @@ class BuildResultNode : public Object { v->Visit("time_cost", &time_cost); } - static constexpr const char* _type_key = "auto_schedule.BuildResult"; + static constexpr const char* _type_key = "auto_scheduler.BuildResult"; TVM_DECLARE_FINAL_OBJECT_INFO(BuildResultNode, Object); }; @@ -180,7 +180,7 @@ class MeasureResultNode : public Object { /*! \brief Do shallow copy. */ MeasureResult copy() const; - static constexpr const char* _type_key = "auto_schedule.MeasureResult"; + static constexpr const char* _type_key = "auto_scheduler.MeasureResult"; TVM_DECLARE_FINAL_OBJECT_INFO(MeasureResultNode, Object); }; @@ -216,7 +216,7 @@ class MeasureCallbackNode : public Object { */ virtual void Callback(const SearchPolicy& policy, const Array& inputs, const Array& results) = 0; - static constexpr const char* _type_key = "auto_schedule.MeasureCallback"; + static constexpr const char* _type_key = "auto_scheduler.MeasureCallback"; TVM_DECLARE_BASE_OBJECT_INFO(MeasureCallbackNode, Object); }; @@ -248,7 +248,7 @@ class ProgramBuilderNode : public Object { */ virtual Array Build(const Array& inputs, int verbose) = 0; - static constexpr const char* _type_key = "auto_schedule.ProgramBuilder"; + static constexpr const char* _type_key = "auto_scheduler.ProgramBuilder"; TVM_DECLARE_BASE_OBJECT_INFO(ProgramBuilderNode, Object); }; @@ -278,7 +278,7 @@ class ProgramRunnerNode : public Object { virtual Array Run(const Array& inputs, const Array& build_results, int verbose) = 0; - static constexpr const char* _type_key = "auto_schedule.ProgramRunner"; + static constexpr const char* _type_key = "auto_scheduler.ProgramRunner"; TVM_DECLARE_BASE_OBJECT_INFO(ProgramRunnerNode, Object); }; @@ -301,7 +301,7 @@ class LocalBuilderNode : public ProgramBuilderNode { Array Build(const Array& inputs, int verbose) final; - static constexpr const char* _type_key = "auto_schedule.LocalBuilder"; + static constexpr const char* _type_key = "auto_scheduler.LocalBuilder"; TVM_DECLARE_FINAL_OBJECT_INFO(LocalBuilderNode, ProgramBuilderNode); }; @@ -338,7 +338,7 @@ class LocalRunnerNode : public ProgramRunnerNode { Array Run(const Array& inputs, const Array& build_results, int verbose) final; - static constexpr const char* _type_key = "auto_schedule.LocalRunner"; + static constexpr const char* _type_key = "auto_scheduler.LocalRunner"; TVM_DECLARE_FINAL_OBJECT_INFO(LocalRunnerNode, ProgramRunnerNode); }; @@ -349,7 +349,7 @@ class LocalRunnerNode : public ProgramRunnerNode { class LocalRunner : public ProgramRunner { public: /*! - * \brief The constructor. See the corresponding class in python/tvm/auto_schedule/measure.py + * \brief The constructor. See the corresponding class in python/tvm/auto_scheduler/measure.py * for more detailed parameter explaination. * \param timeout The timeout limit (in second) for each run. * This is used in a wrapper of the multiprocessing.Process.join(). @@ -416,7 +416,7 @@ class ProgramMeasurerNode : public Object { /*! \brief The default max continuous error setting. */ static const int DEFAULT_MAX_CONTINOUS_ERROR = 150; - static constexpr const char* _type_key = "auto_schedule.ProgramMeasurer"; + static constexpr const char* _type_key = "auto_scheduler.ProgramMeasurer"; TVM_DECLARE_FINAL_OBJECT_INFO(ProgramMeasurerNode, Object); }; @@ -442,7 +442,7 @@ class ProgramMeasurer : public ObjectRef { TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(ProgramMeasurer, ObjectRef, ProgramMeasurerNode); }; -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm -#endif // TVM_AUTO_SCHEDULE_MEASURE_H_ +#endif // TVM_AUTO_SCHEDULER_MEASURE_H_ diff --git a/src/auto_schedule/measure_record.cc b/src/auto_scheduler/measure_record.cc similarity index 82% rename from src/auto_schedule/measure_record.cc rename to src/auto_scheduler/measure_record.cc index 99bd5917f7c8..f6f882edb5a2 100644 --- a/src/auto_schedule/measure_record.cc +++ b/src/auto_scheduler/measure_record.cc @@ -18,7 +18,7 @@ */ /*! - * \file auto_schedule/measure_record.cc + * \file auto_scheduler/measure_record.cc * \brief Json serialization format for dumping and loading tuning records. */ @@ -62,14 +62,14 @@ inline std::vector IntArrayToVector( } template <> -struct Handler<::tvm::Array<::tvm::auto_schedule::Stage>> { +struct Handler<::tvm::Array<::tvm::auto_scheduler::Stage>> { inline static void Write(dmlc::JSONWriter* writer, - const ::tvm::Array<::tvm::auto_schedule::Stage>& data) { + const ::tvm::Array<::tvm::auto_scheduler::Stage>& data) { writer->BeginArray(false); writer->EndArray(); } inline static void Read(dmlc::JSONReader* reader, - ::tvm::Array<::tvm::auto_schedule::Stage>* data) { + ::tvm::Array<::tvm::auto_scheduler::Stage>* data) { bool s; reader->BeginArray(); s = reader->NextArrayItem(); @@ -78,26 +78,26 @@ struct Handler<::tvm::Array<::tvm::auto_schedule::Stage>> { }; template <> -struct Handler<::tvm::Array<::tvm::auto_schedule::Step>> { +struct Handler<::tvm::Array<::tvm::auto_scheduler::Step>> { inline static void Write(dmlc::JSONWriter* writer, - const ::tvm::Array<::tvm::auto_schedule::Step>& data) { + const ::tvm::Array<::tvm::auto_scheduler::Step>& data) { writer->BeginArray(false); for (size_t i = 0; i < data.size(); ++i) { writer->WriteArraySeperator(); writer->BeginArray(false); - if (auto ps = data[i].as<::tvm::auto_schedule::ReorderStepNode>()) { + if (auto ps = data[i].as<::tvm::auto_scheduler::ReorderStepNode>()) { writer->WriteArrayItem(std::string("RE")); writer->WriteArrayItem(ps->stage_id); writer->WriteArrayItem(IntArrayToVector(ps->after_ids)); - } else if (auto ps = data[i].as<::tvm::auto_schedule::SplitStepNode>()) { + } else if (auto ps = data[i].as<::tvm::auto_scheduler::SplitStepNode>()) { writer->WriteArrayItem(std::string("SP")); writer->WriteArrayItem(ps->stage_id); writer->WriteArrayItem(ps->iter_id); - writer->WriteArrayItem(ps->extent ? ::tvm::auto_schedule::GetIntImm(ps->extent.value()) + writer->WriteArrayItem(ps->extent ? ::tvm::auto_scheduler::GetIntImm(ps->extent.value()) : 0); writer->WriteArrayItem(IntArrayToVector(ps->lengths)); writer->WriteArrayItem(static_cast(ps->inner_to_outer)); - } else if (auto ps = data[i].as<::tvm::auto_schedule::FuseStepNode>()) { + } else if (auto ps = data[i].as<::tvm::auto_scheduler::FuseStepNode>()) { writer->WriteArrayItem(std::string("FU")); writer->WriteArrayItem(ps->stage_id); writer->WriteArrayItem(IntArrayToVector(ps->fused_ids)); @@ -110,7 +110,7 @@ struct Handler<::tvm::Array<::tvm::auto_schedule::Step>> { } inline static void Read(dmlc::JSONReader* reader, - ::tvm::Array<::tvm::auto_schedule::Step>* data) { + ::tvm::Array<::tvm::auto_scheduler::Step>* data) { std::vector int_list; bool s, inner_to_outer; std::string name, scope_name, pragma_type, ti_func_name; @@ -134,7 +134,7 @@ struct Handler<::tvm::Array<::tvm::auto_schedule::Step>> { for (const auto& i : int_list) { after_ids.push_back(i); } - data->push_back(::tvm::auto_schedule::ReorderStep(stage_id, after_ids)); + data->push_back(::tvm::auto_scheduler::ReorderStep(stage_id, after_ids)); } else if (name == "SP") { s = reader->NextArrayItem(); CHECK(s); @@ -155,7 +155,7 @@ struct Handler<::tvm::Array<::tvm::auto_schedule::Step>> { for (const auto& i : int_list) { lengths.push_back(::tvm::Integer(i)); } - data->push_back(::tvm::auto_schedule::SplitStep( + data->push_back(::tvm::auto_scheduler::SplitStep( stage_id, iter_id, extent == 0 ? ::tvm::PrimExpr() : extent, lengths, inner_to_outer)); } else if (name == "FU") { s = reader->NextArrayItem(); @@ -168,7 +168,7 @@ struct Handler<::tvm::Array<::tvm::auto_schedule::Step>> { for (const auto& i : int_list) { fused_ids.push_back(i); } - data->push_back(::tvm::auto_schedule::FuseStep(stage_id, fused_ids)); + data->push_back(::tvm::auto_scheduler::FuseStep(stage_id, fused_ids)); } else { LOG(FATAL) << "Invalid step format"; } @@ -179,14 +179,14 @@ struct Handler<::tvm::Array<::tvm::auto_schedule::Step>> { }; template <> -struct Handler<::tvm::auto_schedule::StateNode> { - inline static void Write(dmlc::JSONWriter* writer, const ::tvm::auto_schedule::StateNode& data) { +struct Handler<::tvm::auto_scheduler::StateNode> { + inline static void Write(dmlc::JSONWriter* writer, const ::tvm::auto_scheduler::StateNode& data) { writer->BeginArray(false); writer->WriteArrayItem(data.stages); writer->WriteArrayItem(data.transform_steps); writer->EndArray(); } - inline static void Read(dmlc::JSONReader* reader, ::tvm::auto_schedule::StateNode* data) { + inline static void Read(dmlc::JSONReader* reader, ::tvm::auto_scheduler::StateNode* data) { reader->BeginArray(); bool s; s = reader->NextArrayItem(); @@ -201,15 +201,15 @@ struct Handler<::tvm::auto_schedule::StateNode> { }; template <> -struct Handler<::tvm::auto_schedule::SearchTaskNode> { +struct Handler<::tvm::auto_scheduler::SearchTaskNode> { inline static void Write(dmlc::JSONWriter* writer, - const ::tvm::auto_schedule::SearchTaskNode& data) { + const ::tvm::auto_scheduler::SearchTaskNode& data) { writer->BeginArray(false); writer->WriteArrayItem(std::string(data.workload_key)); writer->WriteArrayItem(data.target->str()); writer->EndArray(); } - inline static void Read(dmlc::JSONReader* reader, ::tvm::auto_schedule::SearchTaskNode* data) { + inline static void Read(dmlc::JSONReader* reader, ::tvm::auto_scheduler::SearchTaskNode* data) { std::string target_str; bool s; @@ -228,18 +228,18 @@ struct Handler<::tvm::auto_schedule::SearchTaskNode> { }; template <> -struct Handler<::tvm::auto_schedule::MeasureInputNode> { +struct Handler<::tvm::auto_scheduler::MeasureInputNode> { inline static void Write(dmlc::JSONWriter* writer, - const ::tvm::auto_schedule::MeasureInputNode& data) { + const ::tvm::auto_scheduler::MeasureInputNode& data) { writer->BeginArray(false); writer->WriteArrayItem(*data.task.operator->()); writer->WriteArrayItem(*data.state.operator->()); writer->EndArray(); } - inline static void Read(dmlc::JSONReader* reader, ::tvm::auto_schedule::MeasureInputNode* data) { + inline static void Read(dmlc::JSONReader* reader, ::tvm::auto_scheduler::MeasureInputNode* data) { bool s; - auto task_node = ::tvm::make_object<::tvm::auto_schedule::SearchTaskNode>(); - auto state_node = ::tvm::make_object<::tvm::auto_schedule::StateNode>(); + auto task_node = ::tvm::make_object<::tvm::auto_scheduler::SearchTaskNode>(); + auto state_node = ::tvm::make_object<::tvm::auto_scheduler::StateNode>(); state_node->concrete = true; reader->BeginArray(); @@ -252,15 +252,15 @@ struct Handler<::tvm::auto_schedule::MeasureInputNode> { s = reader->NextArrayItem(); CHECK(!s); - data->task = ::tvm::auto_schedule::SearchTask(task_node); - data->state = ::tvm::auto_schedule::State(state_node); + data->task = ::tvm::auto_scheduler::SearchTask(task_node); + data->state = ::tvm::auto_scheduler::State(state_node); } }; template <> -struct Handler<::tvm::auto_schedule::MeasureResultNode> { +struct Handler<::tvm::auto_scheduler::MeasureResultNode> { inline static void Write(dmlc::JSONWriter* writer, - const ::tvm::auto_schedule::MeasureResultNode& data) { + const ::tvm::auto_scheduler::MeasureResultNode& data) { writer->BeginArray(false); writer->WriteArraySeperator(); writer->BeginArray(false); @@ -275,7 +275,8 @@ struct Handler<::tvm::auto_schedule::MeasureResultNode> { writer->WriteArrayItem(static_cast((data.timestamp))); writer->EndArray(); } - inline static void Read(dmlc::JSONReader* reader, ::tvm::auto_schedule::MeasureResultNode* data) { + inline static void Read(dmlc::JSONReader* reader, + ::tvm::auto_scheduler::MeasureResultNode* data) { bool s; std::vector tmp; @@ -305,12 +306,12 @@ struct Handler<::tvm::auto_schedule::MeasureResultNode> { } // namespace dmlc namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { TVM_REGISTER_OBJECT_TYPE(RecordToFileNode); TVM_REGISTER_OBJECT_TYPE(RecordReaderNode); -const std::string AUTO_SCHEDULE_LOG_VERSION = "v0.2"; // NOLINT(*) +const std::string AUTO_SCHEDULER_LOG_VERSION = "v0.2"; // NOLINT(*) RecordToFile::RecordToFile(String filename) { auto node = make_object(); @@ -325,7 +326,7 @@ void WriteMeasureRecords(std::ostream* os, const Array& inputs, writer.BeginObject(false); writer.WriteObjectKeyValue("i", *inputs[i].operator->()); writer.WriteObjectKeyValue("r", *results[i].operator->()); - writer.WriteObjectKeyValue("v", AUTO_SCHEDULE_LOG_VERSION); + writer.WriteObjectKeyValue("v", AUTO_SCHEDULER_LOG_VERSION); writer.EndObject(); *os << "\n"; } @@ -405,21 +406,21 @@ std::pair, Array> RecordReaderNode::ReadLines return std::make_pair(inputs, results); } -TVM_REGISTER_GLOBAL("auto_schedule.RecordToFile").set_body_typed([](const String& filename) { +TVM_REGISTER_GLOBAL("auto_scheduler.RecordToFile").set_body_typed([](const String& filename) { return RecordToFile(filename); }); -TVM_REGISTER_GLOBAL("auto_schedule.RecordReader").set_body_typed([](const String& filename) { +TVM_REGISTER_GLOBAL("auto_scheduler.RecordReader").set_body_typed([](const String& filename) { return RecordReader(filename); }); -TVM_REGISTER_GLOBAL("auto_schedule.RecordReaderReadLines") +TVM_REGISTER_GLOBAL("auto_scheduler.RecordReaderReadLines") .set_body_typed([](RecordReader reader, int size, int skip_size) { const auto& res = reader->ReadLines(size, skip_size); return Array{res.first, res.second}; }); -TVM_REGISTER_GLOBAL("auto_schedule.RecordReaderReadNext").set_body_typed([](RecordReader reader) { +TVM_REGISTER_GLOBAL("auto_scheduler.RecordReaderReadNext").set_body_typed([](RecordReader reader) { auto inp = make_object(); auto res = make_object(); if (reader->ReadNext(inp.get(), res.get())) { @@ -429,10 +430,10 @@ TVM_REGISTER_GLOBAL("auto_schedule.RecordReaderReadNext").set_body_typed([](Reco } }); -TVM_REGISTER_GLOBAL("auto_schedule.SaveRecords") +TVM_REGISTER_GLOBAL("auto_scheduler.SaveRecords") .set_body_typed([](String filename, Array in, Array res) { std::ofstream ofs(filename, std::ofstream::app); WriteMeasureRecords(&ofs, in, res); }); -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm diff --git a/src/auto_schedule/measure_record.h b/src/auto_scheduler/measure_record.h similarity index 91% rename from src/auto_schedule/measure_record.h rename to src/auto_scheduler/measure_record.h index f97e30ae9f70..1cfeab07a400 100644 --- a/src/auto_schedule/measure_record.h +++ b/src/auto_scheduler/measure_record.h @@ -18,12 +18,12 @@ */ /*! - * \file auto_schedule/measure_record.h + * \file auto_scheduler/measure_record.h * \brief Json serialization format for dumping and loading tuning records. */ -#ifndef TVM_AUTO_SCHEDULE_MEASURE_RECORD_H_ -#define TVM_AUTO_SCHEDULE_MEASURE_RECORD_H_ +#ifndef TVM_AUTO_SCHEDULER_MEASURE_RECORD_H_ +#define TVM_AUTO_SCHEDULER_MEASURE_RECORD_H_ #include #include @@ -32,7 +32,7 @@ #include "measure.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { /*! \brief Callback for logging the input and results of measurements to file */ class RecordToFileNode : public MeasureCallbackNode { @@ -43,7 +43,7 @@ class RecordToFileNode : public MeasureCallbackNode { void Callback(const SearchPolicy& policy, const Array& inputs, const Array& results) final; - static constexpr const char* _type_key = "auto_schedule.RecordToFile"; + static constexpr const char* _type_key = "auto_scheduler.RecordToFile"; TVM_DECLARE_FINAL_OBJECT_INFO(RecordToFileNode, MeasureCallbackNode); }; @@ -88,7 +88,7 @@ class RecordReaderNode : public Object { std::pair, Array> ReadLines(int max_size = -1, int skip_size = 0); - static constexpr const char* _type_key = "auto_schedule.RecordReader"; + static constexpr const char* _type_key = "auto_scheduler.RecordReader"; TVM_DECLARE_FINAL_OBJECT_INFO(RecordReaderNode, Object); private: @@ -130,7 +130,7 @@ void WriteMeasureRecords(std::ostream* os, const Array& inputs, void ReadMeasureRecord(const std::string& str, MeasureInputNode* inp, MeasureResultNode* res, std::string* log_version); -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm -#endif // TVM_AUTO_SCHEDULE_MEASURE_RECORD_H_ +#endif // TVM_AUTO_SCHEDULER_MEASURE_RECORD_H_ diff --git a/src/auto_schedule/search_policy/empty_policy.cc b/src/auto_scheduler/search_policy/empty_policy.cc similarity index 94% rename from src/auto_schedule/search_policy/empty_policy.cc rename to src/auto_scheduler/search_policy/empty_policy.cc index d91d563252b5..1886203593a9 100644 --- a/src/auto_schedule/search_policy/empty_policy.cc +++ b/src/auto_scheduler/search_policy/empty_policy.cc @@ -18,7 +18,7 @@ */ /*! - * \file auto_schedule/search_policy/empty_policy.cc + * \file auto_scheduler/search_policy/empty_policy.cc * \brief This is an brief example of search policy. */ @@ -29,7 +29,7 @@ #include "../measure.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { TVM_REGISTER_NODE_TYPE(EmptyPolicyNode); @@ -92,9 +92,9 @@ Array EmptyPolicyNode::SearchOneRound() { return res; } -TVM_REGISTER_GLOBAL("auto_schedule.EmptyPolicy").set_body_typed([]() { +TVM_REGISTER_GLOBAL("auto_scheduler.EmptyPolicy").set_body_typed([]() { return EmptyPolicy(make_object()); }); -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm diff --git a/src/auto_schedule/search_policy/empty_policy.h b/src/auto_scheduler/search_policy/empty_policy.h similarity index 85% rename from src/auto_schedule/search_policy/empty_policy.h rename to src/auto_scheduler/search_policy/empty_policy.h index 610a02a3cd12..4ccc9c1042ea 100644 --- a/src/auto_schedule/search_policy/empty_policy.h +++ b/src/auto_scheduler/search_policy/empty_policy.h @@ -18,19 +18,19 @@ */ /*! - * \file auto_schedule/search_policy/empty_policy.h + * \file auto_scheduler/search_policy/empty_policy.h * \brief A brief example of the search policy which always returns the initial naive schedule * (state). */ -#ifndef TVM_AUTO_SCHEDULE_SEARCH_POLICY_EMPTY_POLICY_H_ -#define TVM_AUTO_SCHEDULE_SEARCH_POLICY_EMPTY_POLICY_H_ +#ifndef TVM_AUTO_SCHEDULER_SEARCH_POLICY_EMPTY_POLICY_H_ +#define TVM_AUTO_SCHEDULER_SEARCH_POLICY_EMPTY_POLICY_H_ #include "../loop_state.h" #include "search_policy.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { /*! * \brief A brief example of the search policy which always returns the initial naive schedule @@ -44,7 +44,7 @@ class EmptyPolicyNode : public SearchPolicyNode { int num_measures_per_round, int verbose, ProgramMeasurer measurer, Optional> pre_search_callbacks) final; - static constexpr const char* _type_key = "auto_schedule.EmptyPolicy"; + static constexpr const char* _type_key = "auto_scheduler.EmptyPolicy"; TVM_DECLARE_FINAL_OBJECT_INFO(EmptyPolicyNode, SearchPolicyNode); private: @@ -64,7 +64,7 @@ class EmptyPolicy : public SearchPolicy { TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(EmptyPolicy, SearchPolicy, EmptyPolicyNode); }; -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm -#endif // TVM_AUTO_SCHEDULE_SEARCH_POLICY_EMPTY_POLICY_H_ +#endif // TVM_AUTO_SCHEDULER_SEARCH_POLICY_EMPTY_POLICY_H_ diff --git a/src/auto_schedule/search_policy/search_policy.cc b/src/auto_scheduler/search_policy/search_policy.cc similarity index 84% rename from src/auto_schedule/search_policy/search_policy.cc rename to src/auto_scheduler/search_policy/search_policy.cc index f8ac7ca39495..fba5155edaea 100644 --- a/src/auto_schedule/search_policy/search_policy.cc +++ b/src/auto_scheduler/search_policy/search_policy.cc @@ -18,7 +18,7 @@ */ /*! - * \file auto_schedule/search_policy/search_policy.cc + * \file auto_scheduler/search_policy/search_policy.cc * \brief The base class of search policies. */ @@ -27,7 +27,7 @@ #include namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { TVM_REGISTER_OBJECT_TYPE(SearchCallbackNode); TVM_REGISTER_OBJECT_TYPE(SearchPolicyNode); @@ -40,16 +40,16 @@ void SearchPolicyNode::RunCallbacks(const Optional>& callb } } -TVM_REGISTER_GLOBAL("auto_schedule.SearchPolicyRunCallbacks") +TVM_REGISTER_GLOBAL("auto_scheduler.SearchPolicyRunCallbacks") .set_body_typed([](SearchPolicy policy, Optional> callbacks) { policy->RunCallbacks(callbacks); }); -TVM_REGISTER_GLOBAL("auto_schedule.SearchPolicySetTask") +TVM_REGISTER_GLOBAL("auto_scheduler.SearchPolicySetTask") .set_body_typed([](SearchPolicy policy, SearchTask task) { policy->cur_task = task; }); -TVM_REGISTER_GLOBAL("auto_schedule.SearchPolicySetVerbose") +TVM_REGISTER_GLOBAL("auto_scheduler.SearchPolicySetVerbose") .set_body_typed([](SearchPolicy policy, int verbose) { policy->verbose = verbose; }); -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm diff --git a/src/auto_schedule/search_policy/search_policy.h b/src/auto_scheduler/search_policy/search_policy.h similarity index 93% rename from src/auto_schedule/search_policy/search_policy.h rename to src/auto_scheduler/search_policy/search_policy.h index 47cccec93661..70f94ad65b94 100644 --- a/src/auto_schedule/search_policy/search_policy.h +++ b/src/auto_scheduler/search_policy/search_policy.h @@ -18,7 +18,7 @@ */ /*! - * \file auto_schedule/search_policy/search_policy.h + * \file auto_scheduler/search_policy/search_policy.h * \brief The base class of search policies, including the abstract definition of search policy and * other supporting data structures. * @@ -48,8 +48,8 @@ * during the search process. */ -#ifndef TVM_AUTO_SCHEDULE_SEARCH_POLICY_SEARCH_POLICY_H_ -#define TVM_AUTO_SCHEDULE_SEARCH_POLICY_SEARCH_POLICY_H_ +#ifndef TVM_AUTO_SCHEDULER_SEARCH_POLICY_SEARCH_POLICY_H_ +#define TVM_AUTO_SCHEDULER_SEARCH_POLICY_SEARCH_POLICY_H_ #include @@ -59,7 +59,7 @@ #include "../search_task.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { class ProgramMeasurer; class SearchPolicyNode; @@ -77,7 +77,7 @@ class SearchCallbackNode : public Object { */ virtual void Callback(SearchPolicyNode* policy) = 0; - static constexpr const char* _type_key = "auto_schedule.SearchCallback"; + static constexpr const char* _type_key = "auto_scheduler.SearchCallback"; TVM_DECLARE_BASE_OBJECT_INFO(SearchCallbackNode, Object); }; @@ -131,7 +131,7 @@ class SearchPolicyNode : public Object { */ void RunCallbacks(const Optional>& callbacks); - static constexpr const char* _type_key = "auto_schedule.SearchPolicy"; + static constexpr const char* _type_key = "auto_scheduler.SearchPolicy"; TVM_DECLARE_BASE_OBJECT_INFO(SearchPolicyNode, Object); protected: @@ -161,7 +161,7 @@ class SearchPolicy : public ObjectRef { TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(SearchPolicy, ObjectRef, SearchPolicyNode); }; -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm -#endif // TVM_AUTO_SCHEDULE_SEARCH_POLICY_SEARCH_POLICY_H_ +#endif // TVM_AUTO_SCHEDULER_SEARCH_POLICY_SEARCH_POLICY_H_ diff --git a/src/auto_schedule/search_task.cc b/src/auto_scheduler/search_task.cc similarity index 93% rename from src/auto_schedule/search_task.cc rename to src/auto_scheduler/search_task.cc index 1d7a08cc73db..912a31046540 100644 --- a/src/auto_schedule/search_task.cc +++ b/src/auto_scheduler/search_task.cc @@ -18,7 +18,7 @@ */ /*! - * \file auto_schedule/search_task.cc + * \file auto_scheduler/search_task.cc * \brief Meta information and hardware parameters for a search task. */ @@ -30,7 +30,7 @@ #include namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { TVM_REGISTER_NODE_TYPE(HardwareParamsNode); TVM_REGISTER_NODE_TYPE(SearchTaskNode); @@ -69,16 +69,16 @@ SearchTask::SearchTask(ComputeDAG compute_dag, String workload_key, Target targe data_ = std::move(node); } -TVM_REGISTER_GLOBAL("auto_schedule.HardwareParams") +TVM_REGISTER_GLOBAL("auto_scheduler.HardwareParams") .set_body_typed([](int num_cores, int vector_unit_bytes, int cache_line_bytes) { return HardwareParams(num_cores, vector_unit_bytes, cache_line_bytes); }); -TVM_REGISTER_GLOBAL("auto_schedule.SearchTask") +TVM_REGISTER_GLOBAL("auto_scheduler.SearchTask") .set_body_typed([](ComputeDAG compute_dag, String workload_key, Target target, Target target_host, Optional hardware_params) { return SearchTask(compute_dag, workload_key, target, target_host, hardware_params); }); -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm diff --git a/src/auto_schedule/search_task.h b/src/auto_scheduler/search_task.h similarity index 92% rename from src/auto_schedule/search_task.h rename to src/auto_scheduler/search_task.h index c7d2ddc533ed..ca313500cc8f 100644 --- a/src/auto_schedule/search_task.h +++ b/src/auto_scheduler/search_task.h @@ -18,19 +18,19 @@ */ /*! - * \file auto_schedule/search_task.h + * \file auto_scheduler/search_task.h * \brief Meta information and hardware parameters for a search task. */ -#ifndef TVM_AUTO_SCHEDULE_SEARCH_TASK_H_ -#define TVM_AUTO_SCHEDULE_SEARCH_TASK_H_ +#ifndef TVM_AUTO_SCHEDULER_SEARCH_TASK_H_ +#define TVM_AUTO_SCHEDULER_SEARCH_TASK_H_ #include #include "compute_dag.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { class HardwareParams; @@ -76,7 +76,7 @@ class HardwareParamsNode : public Object { */ static HardwareParams GetDefaultHardwareParams(const Target& target, const Target& target_host); - static constexpr const char* _type_key = "auto_schedule.HardwareParams"; + static constexpr const char* _type_key = "auto_scheduler.HardwareParams"; TVM_DECLARE_FINAL_OBJECT_INFO(HardwareParamsNode, Object); }; @@ -122,7 +122,7 @@ class SearchTaskNode : public Object { v->Visit("hardware_params", &hardware_params); } - static constexpr const char* _type_key = "auto_schedule.SearchTask"; + static constexpr const char* _type_key = "auto_scheduler.SearchTask"; TVM_DECLARE_FINAL_OBJECT_INFO(SearchTaskNode, Object); }; @@ -146,7 +146,7 @@ class SearchTask : public ObjectRef { TVM_DEFINE_OBJECT_REF_METHODS(SearchTask, ObjectRef, SearchTaskNode); }; -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm -#endif // TVM_AUTO_SCHEDULE_SEARCH_TASK_H_ +#endif // TVM_AUTO_SCHEDULER_SEARCH_TASK_H_ diff --git a/src/auto_schedule/transform_step.cc b/src/auto_scheduler/transform_step.cc similarity index 98% rename from src/auto_schedule/transform_step.cc rename to src/auto_scheduler/transform_step.cc index bffb2dcfab31..90b4db838fef 100644 --- a/src/auto_schedule/transform_step.cc +++ b/src/auto_scheduler/transform_step.cc @@ -18,7 +18,7 @@ */ /*! - * \file auto_schedule/transform_step.cc + * \file auto_scheduler/transform_step.cc * \brief Transformation steps. For each schedule primitive, there is a corresponding transform * step. */ @@ -34,7 +34,7 @@ #include "utils.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { /********** Reorder **********/ ReorderStep::ReorderStep(int stage_id, const Array& after_ids) { @@ -235,5 +235,5 @@ String FuseStepNode::PrintAsPythonAPI(Array* stages, return ss.str(); } -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm diff --git a/src/auto_schedule/transform_step.h b/src/auto_scheduler/transform_step.h similarity index 92% rename from src/auto_schedule/transform_step.h rename to src/auto_scheduler/transform_step.h index 5e54c9de583f..d840cc009e2d 100644 --- a/src/auto_schedule/transform_step.h +++ b/src/auto_scheduler/transform_step.h @@ -18,7 +18,7 @@ */ /*! - * \file auto_schedule/transform_step.h + * \file auto_scheduler/transform_step.h * \brief Transformation steps. For each schedule primitive, there is a corresponding transform * step. The implementation of each step consists of 2 parts: * - transform_step.cc: How each step interacts with TE and TE's schedule primitives @@ -34,13 +34,13 @@ * - In these two functions you need to incrementally update all data structures in State with * CopyOnWrite style * 4. Add you step to `ComputeDAG::ApplySteps` and make sure it works. - * 5. Add log record serialization support in `struct Handler>` + * 5. Add log record serialization support in `struct Handler>` * in `record.cc`. * 6. Add its corresponding Python API to `loop_state.py` and necessary unit test. */ -#ifndef TVM_AUTO_SCHEDULE_TRANSFORM_STEP_H_ -#define TVM_AUTO_SCHEDULE_TRANSFORM_STEP_H_ +#ifndef TVM_AUTO_SCHEDULER_TRANSFORM_STEP_H_ +#define TVM_AUTO_SCHEDULER_TRANSFORM_STEP_H_ #include #include @@ -49,7 +49,7 @@ #include "utils.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { typedef Map, ObjectHash, ObjectEqual> StageToAxesMap; @@ -62,7 +62,7 @@ class StepNode : public Object { /*! \brief The index of the stage. */ int stage_id; - static constexpr const char* _type_key = "auto_schedule.Step"; + static constexpr const char* _type_key = "auto_scheduler.Step"; TVM_DECLARE_BASE_OBJECT_INFO(StepNode, Object); }; @@ -99,7 +99,7 @@ class ReorderStepNode : public StepNode { */ String PrintAsPythonAPI(Array* stages, StageToAxesMap* stage_to_axes) const; - static constexpr const char* _type_key = "auto_schedule.ReorderStep"; + static constexpr const char* _type_key = "auto_scheduler.ReorderStep"; TVM_DECLARE_FINAL_OBJECT_INFO(ReorderStepNode, Object); }; @@ -154,7 +154,7 @@ class SplitStepNode : public StepNode { */ String PrintAsPythonAPI(Array* stages, StageToAxesMap* stage_to_axes) const; - static constexpr const char* _type_key = "auto_schedule.SplitStep"; + static constexpr const char* _type_key = "auto_scheduler.SplitStep"; TVM_DECLARE_FINAL_OBJECT_INFO(SplitStepNode, Object); }; @@ -200,7 +200,7 @@ class FuseStepNode : public StepNode { */ String PrintAsPythonAPI(Array* stages, StageToAxesMap* stage_to_axes) const; - static constexpr const char* _type_key = "auto_schedule.FuseStep"; + static constexpr const char* _type_key = "auto_scheduler.FuseStep"; TVM_DECLARE_FINAL_OBJECT_INFO(FuseStepNode, Object); }; @@ -220,7 +220,7 @@ class FuseStep : public Step { TVM_DEFINE_OBJECT_REF_METHODS(FuseStep, Step, FuseStepNode); }; -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm -#endif // TVM_AUTO_SCHEDULE_TRANSFORM_STEP_H_ +#endif // TVM_AUTO_SCHEDULER_TRANSFORM_STEP_H_ diff --git a/src/auto_schedule/utils.cc b/src/auto_scheduler/utils.cc similarity index 91% rename from src/auto_schedule/utils.cc rename to src/auto_scheduler/utils.cc index ecb6145268d6..68f503836cfb 100644 --- a/src/auto_schedule/utils.cc +++ b/src/auto_scheduler/utils.cc @@ -18,19 +18,19 @@ */ /*! - * \file auto_schedule/utils.cc + * \file auto_scheduler/utils.cc * \brief Common utilities. */ #include "utils.h" namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { NullStream& NullStream::Global() { static NullStream stream; return stream; } -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm diff --git a/src/auto_schedule/utils.h b/src/auto_scheduler/utils.h similarity index 96% rename from src/auto_schedule/utils.h rename to src/auto_scheduler/utils.h index e91bc106fb51..5637780e3991 100644 --- a/src/auto_schedule/utils.h +++ b/src/auto_scheduler/utils.h @@ -18,12 +18,12 @@ */ /*! - * \file auto_schedule/utils.h + * \file auto_scheduler/utils.h * \brief Common utilities. */ -#ifndef TVM_AUTO_SCHEDULE_UTILS_H_ -#define TVM_AUTO_SCHEDULE_UTILS_H_ +#ifndef TVM_AUTO_SCHEDULER_UTILS_H_ +#define TVM_AUTO_SCHEDULER_UTILS_H_ #include #include @@ -61,7 +61,7 @@ struct hash> { } // namespace std namespace tvm { -namespace auto_schedule { +namespace auto_scheduler { /********** Utilities for Array, std::string **********/ /*! \brief Get the first appearance index of elements in an Array */ @@ -183,7 +183,7 @@ inline void PrintTitle(const std::string& title, int verbose) { << Chars('-', 60) << std::endl; } -} // namespace auto_schedule +} // namespace auto_scheduler } // namespace tvm -#endif // TVM_AUTO_SCHEDULE_UTILS_H_ +#endif // TVM_AUTO_SCHEDULER_UTILS_H_ diff --git a/tests/python/unittest/test_auto_schedule_common.py b/tests/python/unittest/test_auto_scheduler_common.py similarity index 88% rename from tests/python/unittest/test_auto_schedule_common.py rename to tests/python/unittest/test_auto_scheduler_common.py index 691c7e767b6f..078e1ae8e854 100644 --- a/tests/python/unittest/test_auto_schedule_common.py +++ b/tests/python/unittest/test_auto_scheduler_common.py @@ -15,16 +15,16 @@ # specific language governing permissions and limitations # under the License. -"""Common functions for auto_schedule test cases""" +"""Common functions for auto_scheduler test cases""" import threading -from tvm import te, auto_schedule +from tvm import te, auto_scheduler import topi -@auto_schedule.register_workload -def matmul_auto_schedule_test(N, M, K): +@auto_scheduler.register_workload +def matmul_auto_scheduler_test(N, M, K): A = te.placeholder((N, K), name='A') B = te.placeholder((K, M), name='B') k = te.reduce_axis((0, K), name='k') @@ -32,8 +32,8 @@ def matmul_auto_schedule_test(N, M, K): return [A, B, C] -@auto_schedule.register_workload("matmul_auto_schedule_test_rename_1") -def matmul_auto_schedule_test_rename_0(N, M, K): +@auto_scheduler.register_workload("matmul_auto_scheduler_test_rename_1") +def matmul_auto_scheduler_test_rename_0(N, M, K): A = te.placeholder((N, K), name='A') B = te.placeholder((K, M), name='B') k = te.reduce_axis((0, K), name='k') @@ -67,8 +67,8 @@ def conv2d_nchw_bn_relu(N, H, W, CI, CO, kernel_size, strides, padding, dilation def get_tiled_matmul(): - A, B, C = matmul_auto_schedule_test(512, 512, 512) - dag = auto_schedule.ComputeDAG([A, B, C]) + A, B, C = matmul_auto_scheduler_test(512, 512, 512) + dag = auto_scheduler.ComputeDAG([A, B, C]) s0 = dag.get_init_state() its0 = s0.split(C, s0[C].iters[0], [4, 8, 8]) diff --git a/tests/python/unittest/test_auto_schedule_compute_dag.py b/tests/python/unittest/test_auto_scheduler_compute_dag.py similarity index 93% rename from tests/python/unittest/test_auto_schedule_compute_dag.py rename to tests/python/unittest/test_auto_scheduler_compute_dag.py index 8a4f836765eb..49344634a8f0 100644 --- a/tests/python/unittest/test_auto_schedule_compute_dag.py +++ b/tests/python/unittest/test_auto_scheduler_compute_dag.py @@ -18,9 +18,9 @@ """Test ComputeDAG (replay, infer bound)""" import tvm -from tvm import auto_schedule, te +from tvm import auto_scheduler, te -from test_auto_schedule_common import get_tiled_matmul +from test_auto_scheduler_common import get_tiled_matmul def test_apply_steps(): diff --git a/tests/python/unittest/test_auto_schedule_loop_state.py b/tests/python/unittest/test_auto_scheduler_loop_state.py similarity index 89% rename from tests/python/unittest/test_auto_schedule_loop_state.py rename to tests/python/unittest/test_auto_scheduler_loop_state.py index ed54da513d16..0801d9200275 100644 --- a/tests/python/unittest/test_auto_schedule_loop_state.py +++ b/tests/python/unittest/test_auto_scheduler_loop_state.py @@ -20,15 +20,15 @@ import numpy as np import tvm -from tvm import auto_schedule, te +from tvm import auto_scheduler, te import topi -from test_auto_schedule_common import matmul_auto_schedule_test, conv2d_nchw_bn_relu +from test_auto_scheduler_common import matmul_auto_scheduler_test, conv2d_nchw_bn_relu def test_split_fuse_reorder(): - A, B, C = matmul_auto_schedule_test(512, 512, 512) - dag = auto_schedule.ComputeDAG([A, B, C]) + A, B, C = matmul_auto_scheduler_test(512, 512, 512) + dag = auto_scheduler.ComputeDAG([A, B, C]) s0 = dag.get_init_state() i, j, k = s0[C].iters diff --git a/tests/python/unittest/test_auto_schedule_measure.py b/tests/python/unittest/test_auto_scheduler_measure.py similarity index 74% rename from tests/python/unittest/test_auto_schedule_measure.py rename to tests/python/unittest/test_auto_scheduler_measure.py index 52d016de0756..1bcd0540ecb4 100644 --- a/tests/python/unittest/test_auto_schedule_measure.py +++ b/tests/python/unittest/test_auto_scheduler_measure.py @@ -18,10 +18,10 @@ """ Test measurement and log serialization. """ import tvm -from tvm import auto_schedule +from tvm import auto_scheduler import tempfile -from test_auto_schedule_common import get_tiled_matmul +from test_auto_scheduler_common import get_tiled_matmul def test_record(): @@ -30,15 +30,15 @@ def test_record(): if not tvm.runtime.enabled("llvm"): return target = tvm.target.create("llvm") - task = auto_schedule.SearchTask(dag, "test", target) + task = auto_scheduler.SearchTask(dag, "test", target) - inp = auto_schedule.measure.MeasureInput(task, s) - res = auto_schedule.measure.MeasureResult([0.1], 0, "", 0.2, 1) + inp = auto_scheduler.measure.MeasureInput(task, s) + res = auto_scheduler.measure.MeasureResult([0.1], 0, "", 0.2, 1) with tempfile.NamedTemporaryFile() as fp: - auto_schedule.save_records(fp.name, [inp], [res]) + auto_scheduler.save_records(fp.name, [inp], [res]) - log_reader = auto_schedule.RecordReader(fp.name) + log_reader = auto_scheduler.RecordReader(fp.name) inputs, results = log_reader.read_lines() assert len(inputs) == 1 @@ -55,11 +55,11 @@ def test_measure_local_builder_runner(): if not tvm.runtime.enabled("llvm"): return tgt = tvm.target.create("llvm") - task = auto_schedule.SearchTask(dag, "test", tgt) + task = auto_scheduler.SearchTask(dag, "test", tgt) - minp = auto_schedule.MeasureInput(task, s0) - local_builder = auto_schedule.LocalBuilder() - local_runner = auto_schedule.LocalRunner() + minp = auto_scheduler.MeasureInput(task, s0) + local_builder = auto_scheduler.LocalBuilder() + local_runner = auto_scheduler.LocalRunner() bress = local_builder.build([minp]) assert bress[0].error_no == 0 diff --git a/tests/python/unittest/test_auto_schedule_search_policy.py b/tests/python/unittest/test_auto_scheduler_search_policy.py similarity index 78% rename from tests/python/unittest/test_auto_schedule_search_policy.py rename to tests/python/unittest/test_auto_scheduler_search_policy.py index 9e08218dcbce..8dfc07865ea8 100644 --- a/tests/python/unittest/test_auto_schedule_search_policy.py +++ b/tests/python/unittest/test_auto_scheduler_search_policy.py @@ -22,31 +22,32 @@ import tempfile import tvm -from tvm import auto_schedule +from tvm import auto_scheduler -from test_auto_schedule_common import matmul_auto_schedule_test, PropagatingThread +from test_auto_scheduler_common import matmul_auto_scheduler_test, PropagatingThread -def search_common(workload=matmul_auto_schedule_test, target="llvm", search_policy = auto_schedule.EmptyPolicy(), +def search_common(workload=matmul_auto_scheduler_test, target="llvm", + search_policy=auto_scheduler.EmptyPolicy(), seed=random.randint(1, 1 << 30), runner='local', cost_model=None, num_measure_trials=2, params=None, pre_search_callbacks=None): print("Test %s schedule search with the default search policy" % (target)) random.seed(seed) N = 128 - workload_key = auto_schedule.make_workload_key(workload, (N, N, N)) - dag = auto_schedule.ComputeDAG(workload_key) + workload_key = auto_scheduler.make_workload_key(workload, (N, N, N)) + dag = auto_scheduler.ComputeDAG(workload_key) target = tvm.target.create(target) - task = auto_schedule.SearchTask(dag, workload_key, target) + task = auto_scheduler.SearchTask(dag, workload_key, target) with tempfile.NamedTemporaryFile() as fp: log_file = fp.name - tuning_options = auto_schedule.TuningOptions(num_measure_trials=num_measure_trials, runner=runner, + tuning_options = auto_scheduler.TuningOptions(num_measure_trials=num_measure_trials, runner=runner, verbose=0, - measure_callbacks=[auto_schedule.RecordToFile(log_file)], + measure_callbacks=[auto_scheduler.RecordToFile(log_file)], pre_search_callbacks=pre_search_callbacks) - sch, args = auto_schedule.auto_schedule(task, search_policy, tuning_options) - inp, res = auto_schedule.load_best(log_file, workload_key, target) + sch, args = auto_scheduler.auto_schedule(task, search_policy, tuning_options) + inp, res = auto_scheduler.load_best(log_file, workload_key, target) print("==== Python Code ====") print(dag.print_python_code_from_state(inp.state)) @@ -79,11 +80,11 @@ def test_workload_registry_search_basic(): t.start() t.join() t = PropagatingThread(target=search_common, - kwargs={'seed': 944563397, 'workload': "matmul_auto_schedule_test"}) + kwargs={'seed': 944563397, 'workload': "matmul_auto_scheduler_test"}) t.start() t.join() t = PropagatingThread(target=search_common, - kwargs={'seed': 944563397, 'workload': "matmul_auto_schedule_test_rename_1"}) + kwargs={'seed': 944563397, 'workload': "matmul_auto_scheduler_test_rename_1"}) t.start() t.join()