MinkowskiEngine icon indicating copy to clipboard operation
MinkowskiEngine copied to clipboard

Problem of define custom kernel shape

Open rencosmo opened this issue 3 years ago • 6 comments

Describe the bug

We tried to define the kernel shape by using "KernelGenerator". The argument "region_offsets" is set as NxD torch.IntTensor. But line 300 of "MinkowskiKernelGenerator.py" self.region_offsets = region_offsets if region_offsets else torch.IntTensor() gives the error RuntimeError: Boolean value of Tensor with more than one value is ambiguous


To Reproduce Steps to reproduce the behavior. If the code is not attached and cannot be reproduced easily, the bug report will be closed without any comments.

class matr_blk(nn.Module):
    def __init__(self,
                 inplanes):
        super(matr_blk, self).__init__()
        kernel_size4 = [7, 7, 7]
        stride = (1, 1, 1)
        dilation = False
        dimension = 3

        kernel_occupied_coords4 = []
        for x in range(-kernel_size4[0] // 2 + 1, kernel_size4[0] // 2 + 1):
            for y in range(-kernel_size4[1] // 2 + 1, kernel_size4[1] // 2 + 1):
                for z in range(-kernel_size4[2] // 2 + 1, kernel_size4[2] // 2 + 1):
                    if abs(x) > 2 and abs(y) > 2:
                        kernel_occupied_coords4.append([x, y, z])
        Custom_kernel_coords4 = torch.IntTensor(kernel_occupied_coords4)
        kernel_generator4 = ME.KernelGenerator(
            kernel_size4,
            stride,
            dilation,
            region_type=ME.RegionType.CUSTOM,
            region_offsets=Custom_kernel_coords4,
            dimension=dimension)
        self.avg_pooling4 = ME.MinkowskiAvgPooling(kernel_size=kernel_size2, stride=(1, 1, 1), dimension=3)

    def forward(self, x):
        adj1 = self.avg_pooling4(x)
        return adj1

The "region_offsets" is a Nx3 torch.IntTensor. But line 300 of "MinkowskiKernelGenerator.py" self.region_offsets = region_offsets if region_offsets else torch.IntTensor() gives the error RuntimeError: Boolean value of Tensor with more than one value is ambiguous

We also tried to set "region_offsets" as list of numpy array, none of them works.


Expected behavior

No RuntimeError.


Desktop (please complete the following information):

  • OS: [Ubuntu 18.04]
  • Python version: [3.6.9]
  • Pytorch version: [1.8.1]
  • CUDA version: [10.2]
  • NVIDIA Driver version: [440.33.01]
  • Minkowski Engine version [0.5.3]
  • Output of the following command. (If you installed the latest MinkowskiEngine, paste the output of python -c "import MinkowskiEngine as ME; ME.print_diagnostics()". Otherwise, paste the output of the following command.)
wget -q https://raw.githubusercontent.com/NVIDIA/MinkowskiEngine/master/MinkowskiEngine/diagnostics.py ; python diagnostics.py

==========System========== Linux-4.15.0-91-generic-x86_64-with-Ubuntu-18.04-bionic DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.04 DISTRIB_CODENAME=bionic DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS" 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0] ==========Pytorch========== 1.8.1+cu102 torch.cuda.is_available(): True ==========NVIDIA-SMI========== /usr/bin/nvidia-smi Driver Version 440.33.01 CUDA Version 10.2 VBIOS Version 88.00.43.00.03 Image Version G503.0203.00.04 ==========NVCC========== /usr/local/cuda/bin/nvcc nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2019 NVIDIA Corporation Built on Wed_Oct_23_19:24:38_PDT_2019 Cuda compilation tools, release 10.2, V10.2.89 ==========CC========== /usr/bin/c++ c++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

==========MinkowskiEngine========== 0.5.3 MinkowskiEngine compiled with CUDA Support: True NVCC version MinkowskiEngine is compiled: 10020 CUDART version MinkowskiEngine is compiled: 10020

rencosmo avatar May 19 '21 20:05 rencosmo

The custom region has not been ported to v0.5 yet. Sorry for the delay. I'll try to finish it in a few weeks.

chrischoy avatar May 27 '21 20:05 chrischoy

+1. Same issue while trying to use CUSTOM Region. Will track this issue to know status of the fix.

sandeepnmenon avatar Jun 23 '21 09:06 sandeepnmenon

Hey @chrischoy,

First of all thank you for this work and all the effort. As a kind reminder do you have an estimate if the CUSTOM kernels will be implemented?

Cheers, David

RozDavid avatar Sep 16 '21 10:09 RozDavid

I had similar issues. Finally figured out that the CUSTOM Region has just not been implemented in v0.5 yet.

aniqueakhtar avatar Sep 21 '21 00:09 aniqueakhtar

The custom region has not been ported to v0.5 yet. Sorry for the delay. I'll try to finish it in a few weeks.

Hi @chrischoy,

Can you give an estimate on when the custom region will be available in v0.5? Currently, it is not possible to use the hybrid kernel from the paper in v0.5, and downgrading to v0.4.3 leads to other problems since it is no longer supported.

benemer avatar Dec 20 '21 13:12 benemer

Same issue here with v0.5.4 (Nov 2, 2022)

xuanlinli17 avatar Nov 02 '22 21:11 xuanlinli17