mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-21 14:50:36 +08:00
a formula for bin size for images over 64x64 (#90)
Summary: Signed-off-by: Michele Sanna <sanna@arrival.com> fixes the bin_size calculation with a formula for any image_size > 64. Matches the values chosen so far. simple test: ``` import numpy as np import matplotlib.pyplot as plt image_size = np.arange(64, 2048) bin_size = np.where(image_size <= 64, 8, (2 ** np.maximum(np.ceil(np.log2(image_size)) - 4, 4)).astype(int)) print(image_size) print(bin_size) for ims, bins in zip(image_size, bin_size): if ims <= 64: assert bins == 8 elif ims <= 256: assert bins == 16 elif ims <= 512: assert bins == 32 elif ims <= 1024: assert bins == 64 elif ims <= 2048: assert bins == 128 assert (ims + bins - 1) // bins < 22 plt.plot(image_size, bin_size) plt.grid() plt.show() ```  Pull Request resolved: https://github.com/facebookresearch/pytorch3d/pull/90 Reviewed By: jcjohnson Differential Revision: D21160372 Pulled By: nikhilaravi fbshipit-source-id: 660cf5832f4ca5be243c435a6bed969596fc0188
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c3d636dc8c
commit
f8acecb6b3
@@ -696,7 +696,7 @@ at::Tensor RasterizeMeshesCoarseCuda(
|
||||
const int num_bins = 1 + (image_size - 1) / bin_size; // Divide round up.
|
||||
const int M = max_faces_per_bin;
|
||||
|
||||
if (num_bins >= 22) {
|
||||
if (num_bins >= kMaxFacesPerBin) {
|
||||
std::stringstream ss;
|
||||
ss << "Got " << num_bins << "; that's too many!";
|
||||
AT_ERROR(ss.str());
|
||||
|
||||
@@ -17,6 +17,8 @@ __device__ inline float PixToNdc(int i, int S) {
|
||||
// TODO: is 8 enough? Would increasing have performance considerations?
|
||||
const int32_t kMaxPointsPerPixel = 150;
|
||||
|
||||
const int32_t kMaxFacesPerBin = 22;
|
||||
|
||||
template <typename T>
|
||||
__device__ inline void BubbleSort(T* arr, int n) {
|
||||
// Bubble sort. We only use it for tiny thread-local arrays (n < 8); in this
|
||||
|
||||
Reference in New Issue
Block a user