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

NaN (divide by zero) fix for issue #561 and #790 #891

Closed
wants to merge 1 commit into from
Closed
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: 2 additions & 2 deletions pytorch3d/csrc/utils/geometry_utils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ __device__ inline float3 BarycentricPerspectiveCorrectionForward(
const float w0_top = bary.x * z1 * z2;
const float w1_top = z0 * bary.y * z2;
const float w2_top = z0 * z1 * bary.z;
const float denom = w0_top + w1_top + w2_top;
const float denom = fmaxf(w0_top + w1_top + w2_top, kEpsilon);
const float w0 = w0_top / denom;
const float w1 = w1_top / denom;
const float w2 = w2_top / denom;
Expand Down Expand Up @@ -208,7 +208,7 @@ BarycentricPerspectiveCorrectionBackward(
const float w0_top = bary.x * z1 * z2;
const float w1_top = z0 * bary.y * z2;
const float w2_top = z0 * z1 * bary.z;
const float denom = w0_top + w1_top + w2_top;
const float denom = fmaxf(w0_top + w1_top + w2_top, kEpsilon);

// Now do backward pass
const float grad_denom_top =
Expand Down