Simplify removes no-ops from the tape (#1759)

* simplify removes no-ops from the tape

* comment
This commit is contained in:
Awni Hannun
2025-01-09 11:23:19 -08:00
committed by GitHub
parent 1ccaf80575
commit da8c885784
4 changed files with 41 additions and 11 deletions

View File

@@ -157,6 +157,17 @@ TEST_CASE("test simplify") {
set_compile_mode(CompileMode::enabled);
}
TEST_CASE("test simplify noops") {
set_compile_mode(CompileMode::no_fuse);
auto a = array({1.0f, 2.0f});
auto fun = [](const std::vector<array>& inputs) -> std::vector<array> {
return {copy(stop_gradient(exp(stop_gradient(inputs[0]))))};
};
auto b = compile(fun)({a})[0];
CHECK(b.inputs()[0].id() == a.id());
set_compile_mode(CompileMode::enabled);
}
auto add_diff(const std::vector<array>& inputs) {
auto a = inputs[0];
return std::vector<array>{cos(a) + sin(a)};