tingofurro / summac

Codebase, data and models for the SummaC paper in TACL
https://arxiv.org/abs/2111.09525
Apache License 2.0
81 stars 20 forks source link

Convert histograms to nparray to avoid warning #18

Open tomhosking opened 9 months ago

tomhosking commented 9 months ago

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.