yeezhu / SPN.pytorch

PyTorch implementation of "Soft Proposal Networks for Weakly Supervised Object Localization", ICCV 2017.
http://yzhu.work/spn.html
MIT License
211 stars 37 forks source link

Cuda kernel issues and some build file fixes #8

Closed vadimkantorov closed 6 years ago

vadimkantorov commented 6 years ago

I'd like to share some issues (with fixes) that I discovered while trying to use your package:

  1. A bug in spnlib/spn/src/generic/SoftProposalGenerator.cu, SP_InitDistanceMetric(...): const uint16 count = N * N;

    should be

    const uint32 count = (uint32)N * (uint32)N;

    Otherwise there's an integer overflow for tensors that have H*W > 1024 (this is pretty restrictive, even 32x32 overflows)

  2. (these of course aren't affecting the normal float code path, but still potentially a bug) Double implementations are currently useless, since the GEMV function consumes only float pointers:

    .../SPN.pytorch/spnlib/spn/src/generic/SoftProposalGenerator.cu: In function ‘cuspn_Double_SP_Generate’:
    .../SPN.pytorch/spnlib/spn/src/generic/SoftProposalGenerator.cu:107:17: warning: passing argument 6 of ‘THCudaBlas_Sgemv’ from incompatible pointer
    type [-Wincompatible-pointer-types]
                 transferMatrix_data,
                 ^
  3. (I am building by directly calling python build.py in make.sh instead of python setup.py install). Without these build.py fixes I had various compiler / build_extension "File not found" errors:

    ...
    extra_objects += [os.path.abspath('spn/src/libspn_kernel.cu.o')]
    ...
    #    package=True,
    ...
    include_dirs=[os.path.abspath('spn/src')],
    ...
yeezhu commented 6 years ago

I fixed the bug about integer overflow in the latest version. Thank you very much!