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

Fix linear bug #5945

Merged
merged 7 commits into from
Aug 18, 2021
4 changes: 2 additions & 2 deletions oneflow/core/autograd/gradient_funcs/matmul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ Maybe<void> BroadcastMatmul::Apply(const MatmulInterpState* ctx, const TensorTup
JUST(attrs_b.SetAttr<double>("alpha", ctx->alpha));

in_grads->resize(2);
if (ctx->requires_grad_b) {
if (ctx->requires_grad_a) {
const auto& input_b = ctx->SavedTensors().at(ctx->b_index);
in_grads->at(0) =
JUST(OpInterpUtil::Dispatch<Tensor>(*grad_a_op_, {out_grads.at(0), input_b}, attrs_a));
}

if (ctx->requires_grad_a) {
if (ctx->requires_grad_b) {
const auto& input_a = ctx->SavedTensors().at(ctx->a_index);
if (!ctx->transpose_b) {
in_grads->at(1) =
Expand Down