mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-21 14:50:36 +08:00
Bug fix for case where aspect ratio is a float
Summary: - Fix the calculation of the non square NDC range when the H and W are not integer multiples. - Add test for this case Reviewed By: gkioxari Differential Revision: D26613213 fbshipit-source-id: df6763cac602e9f1d516b41b432c4d2cfbaa356d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0345f860d4
commit
13429640d3
@@ -10,7 +10,9 @@
|
||||
__device__ inline float NonSquareNdcRange(int S1, int S2) {
|
||||
float range = 2.0f;
|
||||
if (S1 > S2) {
|
||||
range = ((S1 / S2) * range);
|
||||
// First multiply S1 by float range so that division results
|
||||
// in a float value.
|
||||
range = (S1 * range) / S2;
|
||||
}
|
||||
return range;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
inline float NonSquareNdcRange(int S1, int S2) {
|
||||
float range = 2.0f;
|
||||
if (S1 > S2) {
|
||||
range = ((S1 / S2) * range);
|
||||
range = (S1 * range) / S2;
|
||||
}
|
||||
return range;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from typing import List, Optional, Tuple, Union
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
|
||||
# pyre-fixme[21]: Could not find name `_C` in `pytorch3d`.
|
||||
@@ -120,15 +121,7 @@ def rasterize_points(
|
||||
# Binned CPU rasterization not fully implemented
|
||||
bin_size = 0
|
||||
else:
|
||||
# TODO: These heuristics are not well-thought out!
|
||||
if max_image_size <= 64:
|
||||
bin_size = 8
|
||||
elif max_image_size <= 256:
|
||||
bin_size = 16
|
||||
elif max_image_size <= 512:
|
||||
bin_size = 32
|
||||
elif max_image_size <= 1024:
|
||||
bin_size = 64
|
||||
bin_size = int(2 ** max(np.ceil(np.log2(max_image_size)) - 4, 4))
|
||||
|
||||
if bin_size != 0:
|
||||
# There is a limit on the number of points per bin in the cuda kernel.
|
||||
|
||||
Reference in New Issue
Block a user