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

Add D_folded support for jagged_to_padded_dense_backward meta function #3670

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion fbgemm_gpu/src/jagged_tensor_ops/jagged_tensor_ops_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ Tensor jagged_to_padded_dense_backward_meta(
auto grad_padded_values = grad_output;

at::SymInt D = grad_padded_values.sym_size(-1);
const bool D_folded =
static_cast<size_t>(grad_padded_values.dim()) == offsets.size() + 1;
// Initialize with zeros so output will be zero for the portion truncated
// in forward.
auto grad_values =
at::zeros_symint({total_L, D}, grad_padded_values.options());

TORCH_CHECK(grad_values.is_meta());
return grad_values;
return D_folded ? grad_values.squeeze(-1) : grad_values;
}

Tensor jagged_dense_dense_elementwise_add_jagged_output_forward_meta(
Expand Down
Loading