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

Rename Output to OutputFileType and deprecated Output #6568

Merged
merged 6 commits into from
Jan 25, 2022
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
2 changes: 1 addition & 1 deletion python_bindings/correctness/compile_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def main():
assert os.path.isfile(os.path.join(tmpdir, "f_all.o"))

p = os.path.join(tmpdir, "f.html")
f.compile_to({hl.Output.stmt_html: p}, args, "f")
f.compile_to({hl.OutputFileType.stmt_html: p}, args, "f")
assert os.path.isfile(p)

finally:
Expand Down
34 changes: 17 additions & 17 deletions python_bindings/src/PyEnums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,23 @@ void define_enums(py::module &m) {
.value("Float", Type::Float)
.value("Handle", Type::Handle);

py::enum_<Output>(m, "Output")
.value("assembly", Output::assembly)
.value("bitcode", Output::bitcode)
.value("c_header", Output::c_header)
.value("c_source", Output::c_source)
.value("cpp_stub", Output::cpp_stub)
.value("featurization", Output::featurization)
.value("llvm_assembly", Output::llvm_assembly)
.value("object", Output::object)
.value("python_extension", Output::python_extension)
.value("pytorch_wrapper", Output::pytorch_wrapper)
.value("registration", Output::registration)
.value("schedule", Output::schedule)
.value("static_library", Output::static_library)
.value("stmt", Output::stmt)
.value("stmt_html", Output::stmt_html)
.value("compiler_log", Output::compiler_log);
py::enum_<OutputFileType>(m, "OutputFileType")
.value("assembly", OutputFileType::assembly)
.value("bitcode", OutputFileType::bitcode)
.value("c_header", OutputFileType::c_header)
.value("c_source", OutputFileType::c_source)
.value("cpp_stub", OutputFileType::cpp_stub)
.value("featurization", OutputFileType::featurization)
.value("llvm_assembly", OutputFileType::llvm_assembly)
.value("object", OutputFileType::object)
.value("python_extension", OutputFileType::python_extension)
.value("pytorch_wrapper", OutputFileType::pytorch_wrapper)
.value("registration", OutputFileType::registration)
.value("schedule", OutputFileType::schedule)
.value("static_library", OutputFileType::static_library)
.value("stmt", OutputFileType::stmt)
.value("stmt_html", OutputFileType::stmt_html)
.value("compiler_log", OutputFileType::compiler_log);
}

} // namespace PythonBindings
Expand Down
2 changes: 1 addition & 1 deletion python_bindings/src/PyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void define_module(py::module &m) {

m.def("link_modules", &link_modules, py::arg("name"), py::arg("modules"));
m.def("compile_standalone_runtime", (void (*)(const std::string &, const Target &)) & compile_standalone_runtime, py::arg("filename"), py::arg("target"));
using OutputMap = std::map<Output, std::string>;
using OutputMap = std::map<OutputFileType, std::string>;
m.def("compile_standalone_runtime", (OutputMap(*)(const OutputMap &, const Target &)) & compile_standalone_runtime, py::arg("outputs"), py::arg("target"));

// TODO: compile_multitarget() deliberately skipped for now.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def main():
# arguments to the routine. This routine takes two. Arguments are
# usually Params or ImageParams.
fname = "lesson_10_halide"
brighter.compile_to({hl.Output.object: "lesson_10_halide.o",
hl.Output.python_extension: "lesson_10_halide.py.cpp"},
brighter.compile_to({hl.OutputFileType.object: "lesson_10_halide.o",
hl.OutputFileType.python_extension: "lesson_10_halide.py.cpp"},
[input, offset], "lesson_10_halide")

print("Halide pipeline compiled, but not yet run.")
Expand Down
2 changes: 1 addition & 1 deletion src/Func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3179,7 +3179,7 @@ Module Func::compile_to_module(const vector<Argument> &args, const std::string &
return pipeline().compile_to_module(args, fn_name, target);
}

void Func::compile_to(const map<Output, string> &output_files,
void Func::compile_to(const map<OutputFileType, string> &output_files,
const vector<Argument> &args,
const string &fn_name,
const Target &target) {
Expand Down
8 changes: 4 additions & 4 deletions src/Func.h
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ class Func {
* Deduces target files based on filenames specified in
* output_files map.
*/
void compile_to(const std::map<Output, std::string> &output_files,
void compile_to(const std::map<OutputFileType, std::string> &output_files,
const std::vector<Argument> &args,
const std::string &fn_name,
const Target &target = get_target_from_environment());
Expand Down Expand Up @@ -2301,9 +2301,9 @@ class Func {
Func &async();

/** Bound the extent of a Func's storage, but not extent of its
* compute. This can be useful for forcing a function's allocation
* to be a fixed size, which often means it can go on the stack.
* If bounds inference decides that it requires more storage for
* compute. This can be useful for forcing a function's allocation
* to be a fixed size, which often means it can go on the stack.
* If bounds inference decides that it requires more storage for
* this function than the allocation size you have stated, a runtime
* error will occur when you try to run the pipeline. */
Func &bound_storage(const Var &dim, const Expr &bound);
Expand Down
38 changes: 19 additions & 19 deletions src/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ std::string compute_base_path(const std::string &output_dir,
return base_path;
}

std::map<Output, std::string> compute_output_files(const Target &target,
const std::string &base_path,
const std::set<Output> &outputs) {
std::map<Output, const OutputInfo> output_info = get_output_info(target);
std::map<OutputFileType, std::string> compute_output_files(const Target &target,
const std::string &base_path,
const std::set<OutputFileType> &outputs) {
std::map<OutputFileType, const OutputInfo> output_info = get_output_info(target);

std::map<Output, std::string> output_files;
std::map<OutputFileType, std::string> output_files;
for (auto o : outputs) {
output_files[o] = base_path + output_info.at(o).extension;
}
Expand Down Expand Up @@ -912,23 +912,23 @@ int generate_filter_main_inner(int argc, char **argv, std::ostream &error_output
}

// extensions won't vary across multitarget output
std::map<Output, const OutputInfo> output_info = get_output_info(targets[0]);
std::map<OutputFileType, const OutputInfo> output_info = get_output_info(targets[0]);

std::set<Output> outputs;
std::set<OutputFileType> outputs;
if (emit_flags.empty() || (emit_flags.size() == 1 && emit_flags[0].empty())) {
// If omitted or empty, assume .a and .h and registration.cpp
outputs.insert(Output::c_header);
outputs.insert(Output::registration);
outputs.insert(Output::static_library);
outputs.insert(OutputFileType::c_header);
outputs.insert(OutputFileType::registration);
outputs.insert(OutputFileType::static_library);
} else {
// Build a reverse lookup table. Allow some legacy aliases on the command line,
// to allow legacy build systems to work more easily.
std::map<std::string, Output> output_name_to_enum = {
{"cpp", Output::c_source},
{"h", Output::c_header},
{"html", Output::stmt_html},
{"o", Output::object},
{"py.c", Output::python_extension},
std::map<std::string, OutputFileType> output_name_to_enum = {
{"cpp", OutputFileType::c_source},
{"h", OutputFileType::c_header},
{"html", OutputFileType::stmt_html},
{"o", OutputFileType::object},
{"py.c", OutputFileType::python_extension},
};
for (const auto &it : output_info) {
output_name_to_enum[it.second.name] = it.first;
Expand All @@ -955,7 +955,7 @@ int generate_filter_main_inner(int argc, char **argv, std::ostream &error_output
}

// Allow quick-n-dirty use of compiler logging via HL_DEBUG_COMPILER_LOGGER env var
const bool do_compiler_logging = outputs.count(Output::compiler_log) ||
const bool do_compiler_logging = outputs.count(OutputFileType::compiler_log) ||
(get_env_variable("HL_DEBUG_COMPILER_LOGGER") == "1");

const bool obfuscate_compiler_logging = get_env_variable("HL_OBFUSCATE_COMPILER_LOGGER") == "1";
Expand Down Expand Up @@ -1055,11 +1055,11 @@ int generate_filter_main_inner(int argc, char **argv, std::ostream &error_output
if (!generator_name.empty()) {
std::string base_path = compute_base_path(output_dir, function_name, file_base_name);
debug(1) << "Generator " << generator_name << " has base_path " << base_path << "\n";
if (outputs.count(Output::cpp_stub)) {
if (outputs.count(OutputFileType::cpp_stub)) {
// When generating cpp_stub, we ignore all generator args passed in, and supply a fake Target.
// (CompilerLogger is never enabled for cpp_stub, for now anyway.)
auto gen = GeneratorRegistry::create(generator_name, GeneratorContext(Target()));
auto stub_file_path = base_path + output_info[Output::cpp_stub].extension;
auto stub_file_path = base_path + output_info[OutputFileType::cpp_stub].extension;
gen->emit_cpp_stub(stub_file_path);
}

Expand Down
Loading