Skip to content

Commit

Permalink
Require an autoschedule for build_gradient_module()/GRADIENT_DESCENT
Browse files Browse the repository at this point in the history
Currently we just emit a warning... which may be hidden by CMake/Bazel. This really needs to be an error, though, because an unscheduled gradient-descent module can be immense and take ~forever to compile.
  • Loading branch information
steven-johnson committed Dec 19, 2024
1 parent d3f19bd commit 6bb73fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion doc/HalideCMakePackage.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,9 @@ verbatim.
If `GRADIENT_DESCENT` is set, then the module will be built suitably for
gradient descent calculation in TensorFlow or PyTorch. See
`Generator::build_gradient_module()` for more documentation. This corresponds to
passing `-d 1` at the generator command line.
passing `-d 1` at the generator command line. Note that you *must* also specify
an autoscheduler (via the `AUTOSCHEDULER` argument) when specifying this
argument.

If the `C_BACKEND` option is set, this command will invoke the configured C++
compiler on a generated source. Note that a `<target>.runtime` target is _not_
Expand Down
3 changes: 1 addition & 2 deletions src/AbstractGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ Module AbstractGenerator::build_gradient_module(const std::string &function_name
if (!asp.name.empty()) {
auto_schedule_results = grad_pipeline.apply_autoscheduler(context.target(), asp);
} else {
user_warning << "Autoscheduling is not enabled in build_gradient_module(), so the resulting "
"gradient module will be unscheduled; this is very unlikely to be what you want.\n";
user_error << "An autoscheduler must be specified when producing a gradient-descent module().\n";
}

Module result = grad_pipeline.compile_to_module(gradient_inputs, function_name, context.target(), linkage_type);
Expand Down

0 comments on commit 6bb73fa

Please sign in to comment.