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

Handle variadic pullbacks #1150

Open
kchristin22 opened this issue Nov 22, 2024 · 0 comments
Open

Handle variadic pullbacks #1150

kchristin22 opened this issue Nov 22, 2024 · 0 comments

Comments

@kchristin22
Copy link
Collaborator

kchristin22 commented Nov 22, 2024

When Clad tries to create a pullback function for variadic functions, the variadic arg is not shown as a function parameter, so there's a mismatch in call args for a function and its actual params:

bool isMethodOperatorCall = MD && isa<CXXOperatorCallExpr>(CE);
for (std::size_t i = static_cast<std::size_t>(isMethodOperatorCall),
e = CE->getNumArgs();
i != e; ++i) {
const Expr* arg = CE->getArg(i);
const auto* PVD = FD->getParamDecl(
i - static_cast<unsigned long>(isMethodOperatorCall));
StmtDiff argDiff{};
// We do not need to create result arg for arguments passed by reference
// because the derivatives of arguments passed by reference are directly
// modified by the derived callee function.
if (utils::IsReferenceOrPointerArg(arg) ||
!m_DiffReq.shouldHaveAdjoint(PVD)) {
argDiff = Visit(arg);
CallArgDx.push_back(argDiff.getExpr_dx());

Clad should be able to handle such calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant