summac icon indicating copy to clipboard operation
summac copied to clipboard

Convert histograms to nparray to avoid warning

Open tomhosking opened this issue 1 year ago • 0 comments

torch throws a warning about creating a tensor from a list of arrays:

summac/model_summac.py:301: UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor. (Triggered internally at ../torch/csrc/utils/tensor_new.cpp:261.)
  histograms = torch.FloatTensor(histograms).to(self.device)

This PR converts the list to a single nparray first to avoid this message. I've not noticed a significant change in performance as a result.

tomhosking avatar Dec 21 '23 12:12 tomhosking