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

Remove dead code. NFC #1204

Merged
merged 1 commit into from
Dec 30, 2024
Merged
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
20 changes: 5 additions & 15 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
}

DerivativeAndOverload ReverseModeVisitor::Derive() {
const FunctionDecl* FD = m_DiffReq.Function;
if (m_ExternalSource)
m_ExternalSource->ActOnStartOfDerive();
if (m_DiffReq.Mode == DiffMode::error_estimation)
Expand All @@ -204,13 +203,8 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
assert(m_DiffReq.Function && "Must not be null.");

DiffParams args{};
if (m_DiffReq.Args)
for (const auto& dParam : m_DiffReq.DVI)
args.push_back(dParam.param);
else
std::copy(FD->param_begin(), FD->param_end(), std::back_inserter(args));
if (args.empty())
return {};
for (const auto& dParam : m_DiffReq.DVI)
args.push_back(dParam.param);

if (m_ExternalSource)
m_ExternalSource->ActAfterParsingDiffArgs(m_DiffReq, args);
Expand Down Expand Up @@ -350,7 +344,6 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
}

DerivativeAndOverload ReverseModeVisitor::DerivePullback() {
const clang::FunctionDecl* FD = m_DiffReq.Function;
// FIXME: Duplication of external source here is a workaround
// for the two 'Derive's being different functions.
if (m_ExternalSource)
Expand All @@ -359,13 +352,10 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
assert(m_DiffReq.Function && "Must not be null.");

DiffParams args{};
if (!m_DiffReq.DVI.empty())
for (const auto& dParam : m_DiffReq.DVI)
args.push_back(dParam.param);
else
std::copy(FD->param_begin(), FD->param_end(), std::back_inserter(args));
for (const auto& dParam : m_DiffReq.DVI)
args.push_back(dParam.param);
#ifndef NDEBUG
bool isStaticMethod = utils::IsStaticMethod(FD);
bool isStaticMethod = utils::IsStaticMethod(m_DiffReq.Function);
assert((!args.empty() || !isStaticMethod) &&
"Cannot generate pullback function of a function "
"with no differentiable arguments");
Expand Down
Loading