Skip to content
Closed
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
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ContinuationIndentWidth: 4
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
LambdaBodyIndentation: OuterScope
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PackConstructorInitializers: BinPack
Expand Down
16 changes: 8 additions & 8 deletions apps/hannk/interpreter/allocation_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ void AllocationPlanner::commit() {

std::sort(block_requirements_sorted.begin(), block_requirements_sorted.end(),
[](BlockRequirements *a, BlockRequirements *b) -> bool {
// Sort in decreasing (well, really non-increasing) order by size.
if (a->size_needed != b->size_needed) {
return a->size_needed > b->size_needed;
}

// If sizes are equal, sort by increasing time of first use.
return a->first_use < b->first_use;
});
// Sort in decreasing (well, really non-increasing) order by size.
if (a->size_needed != b->size_needed) {
return a->size_needed > b->size_needed;
}

// If sizes are equal, sort by increasing time of first use.
return a->first_use < b->first_use;
});

// This is a list that we keep sorted (by offset) as we go along.
// It just points to entries in block_requirements_sorted, so it's crucial
Expand Down
114 changes: 57 additions & 57 deletions apps/hannk/util/model_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,75 +519,75 @@ int ModelRunner::parse_flags(int argc, char **argv, std::vector<std::string> &fi

fp.flag_handlers = FlagProcessor::FnMap{
{"benchmark", [this](const std::string &value) {
this->do_benchmark = std::stoi(value) != 0;
return 0;
}},
this->do_benchmark = std::stoi(value) != 0;
return 0;
}},
{"compare", [this](const std::string &value) {
this->do_compare_results = std::stoi(value) != 0;
return 0;
}},
this->do_compare_results = std::stoi(value) != 0;
return 0;
}},
{"csv", [this](const std::string &value) {
this->csv_output = std::stoi(value) != 0;
return 0;
}},
this->csv_output = std::stoi(value) != 0;
return 0;
}},
{"enable", [this](const std::string &value) {
for (int i = 0; i < ModelRunner::kNumRuns; i++) {
this->do_run[i] = false;
}
for (char c : value) {
switch (c) {
case 'h':
this->do_run[ModelRunner::kHannk] = true;
break;
for (int i = 0; i < ModelRunner::kNumRuns; i++) {
this->do_run[i] = false;
}
for (char c : value) {
switch (c) {
case 'h':
this->do_run[ModelRunner::kHannk] = true;
break;
#if HANNK_BUILD_TFLITE
case 't':
this->do_run[ModelRunner::kTfLite] = true;
break;
case 'x':
this->do_run[ModelRunner::kExternalDelegate] = true;
break;
case 'i':
this->do_run[ModelRunner::kInternalDelegate] = true;
break;
case 't':
this->do_run[ModelRunner::kTfLite] = true;
break;
case 'x':
this->do_run[ModelRunner::kExternalDelegate] = true;
break;
case 'i':
this->do_run[ModelRunner::kInternalDelegate] = true;
break;
#else
case 't':
case 'x':
case 'i':
std::cerr << "Unsupported option to --enable (TFLite is not enabled in this build): " << c << "\n";
return -1;
break;
case 't':
case 'x':
case 'i':
std::cerr << "Unsupported option to --enable (TFLite is not enabled in this build): " << c << "\n";
return -1;
break;
#endif
default:
std::cerr << "Unknown option to --enable: " << c << "\n";
return -1;
}
}
return 0;
}},
default:
std::cerr << "Unknown option to --enable: " << c << "\n";
return -1;
}
}
return 0;
}},
{"external_delegate_path", [this](const std::string &value) {
this->external_delegate_path = value;
return 0;
}},
this->external_delegate_path = value;
return 0;
}},
{"keep_going", [this](const std::string &value) {
this->keep_going = std::stoi(value) != 0;
return 0;
}},
this->keep_going = std::stoi(value) != 0;
return 0;
}},
{"seed", [&seed](const std::string &value) {
seed = std::stoi(value);
return 0;
}},
seed = std::stoi(value);
return 0;
}},
{"threads", [this](const std::string &value) {
this->threads = std::stoi(value);
return 0;
}},
this->threads = std::stoi(value);
return 0;
}},
{"tolerance", [this](const std::string &value) {
this->tolerance = std::stof(value);
return 0;
}},
this->tolerance = std::stof(value);
return 0;
}},
{"verbose", [this](const std::string &value) {
this->verbosity = std::stoi(value);
return 0;
}},
this->verbosity = std::stoi(value);
return 0;
}},
};

int r = fp.process(argc, argv);
Expand Down
12 changes: 6 additions & 6 deletions python_bindings/src/halide/halide_/PyArgument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ void define_argument(py::module &m) {
py::class_<Argument>(m, "Argument")
.def(py::init<>())
.def(py::init([](const OutputImageParam &im) -> Argument {
return im;
}),
return im;
}),
py::arg("im"))
.def(py::init([](const ImageParam &im) -> Argument {
return im;
}),
return im;
}),
py::arg("im"))
.def(py::init([](const Param<> &param) -> Argument {
return param;
}),
return param;
}),
py::arg("param"))
.def(py::init<Buffer<>>(), py::arg("buffer"))
.def_readwrite("name", &Argument::name)
Expand Down
75 changes: 37 additions & 38 deletions python_bindings/src/halide/halide_/PyBinaryOperators.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,54 +114,54 @@ void add_binary_operators_with(PythonClass &class_instance) {
using Promote = std::conditional_t<
std::is_same_v<other_t, double>, DoubleToExprCheck, other_t>;

#define BINARY_OP(op, method) \
#define BINARY_OP(op, method) \
do { \
class_instance.def( \
"__" #method "__", \
[](const self_t &self, const other_t &other) { \
auto result = self op Promote(other); \
LOG_PY_BINARY_OP(self, #method, other, result); \
return result; \
}, \
py::is_operator()); \
} while (0)

#define RBINARY_OP(op, method) \
do { \
class_instance.def( \
"__" #method "__", \
"__r" #method "__", \
[](const self_t &self, const other_t &other) { \
auto result = self op Promote(other); \
LOG_PY_BINARY_OP(self, #method, other, result); \
return result; \
}, \
auto result = Promote(other) op self; \
LOG_PY_BINARY_OP(self, "r" #method, other, result); \
return result; \
}, \
py::is_operator()); \
} while (0)

#define RBINARY_OP(op, method) \
do { \
class_instance.def( \
"__r" #method "__", \
[](const self_t &self, const other_t &other) { \
auto result = Promote(other) op self; \
LOG_PY_BINARY_OP(self, "r" #method, other, result); \
return result; \
}, \
py::is_operator()); \
} while (0)

#define BINARY_OPS(op, method) \
do { \
BINARY_OP(op, method); \
RBINARY_OP(op, method); \
} while (0)

if constexpr (std::is_same_v<self_t, FuncRef>) {
#define BINARY_OPS_UNEVAL(op, method, val) \
do { \
class_instance.def( \
"__" #method "__", \
[](const self_t &self, const other_t &other) -> std::variant<UnevaluatedFuncRefExpr, Expr> { \
if (self.function().has_pure_definition() || self.function().has_extern_definition()) { \
auto result = Expr(self) op Promote(other); \
LOG_PY_BINARY_OP(self, #method, other, result); \
return result; \
} else { \
auto result = UnevaluatedFuncRefExpr{self, Promote(other), UnevaluatedFuncRefExpr::Op::val}; \
LOG_PY_BINARY_OP_UNEVAL(self, #method, other, result); \
return result; \
} \
}, \
py::is_operator()); \
RBINARY_OP(op, method); \
#define BINARY_OPS_UNEVAL(op, method, val) \
do { \
class_instance.def( \
"__" #method "__", \
[](const self_t &self, const other_t &other) -> std::variant<UnevaluatedFuncRefExpr, Expr> { \
if (self.function().has_pure_definition() || self.function().has_extern_definition()) { \
auto result = Expr(self) op Promote(other); \
LOG_PY_BINARY_OP(self, #method, other, result); \
return result; \
} else { \
auto result = UnevaluatedFuncRefExpr{self, Promote(other), UnevaluatedFuncRefExpr::Op::val}; \
LOG_PY_BINARY_OP_UNEVAL(self, #method, other, result); \
return result; \
} \
}, \
py::is_operator()); \
RBINARY_OP(op, method); \
} while (0)

BINARY_OPS_UNEVAL(+, add, Add);
Expand Down Expand Up @@ -222,9 +222,8 @@ void add_binary_operators(PythonClass &class_instance) {
class_instance
.def("__pow__", Halide::pow, py::is_operator())
.def("__rpow__", [](const Expr &self, const Expr &other) {
return Halide::pow(other, self); //
},
py::is_operator());
return Halide::pow(other, self); //
}, py::is_operator());

const auto logical_not_wrap = [](const self_t &self) -> decltype(!self) {
return !self;
Expand Down
Loading
Loading