<h2 dir="auto">🐛 Bug</h2>

<h2 dir="auto">Description</h2>
<ul dir="auto">
<li>Image Type:</li>
</ul>
<p dir="auto">I use the torch.utils.data.Dataloader to wrap my dataset class , but  the Error message shows that the  image tensor was Torch.HalfTensor, but it was float64, Wha should I do to fix it?</p>
<p dir="auto">(0, (3, 1280, 704), (1280, 704, 3), &lt;class 'torch.Tensor'&gt;, tensor(-0.4490, dtype=torch.float64))<br>
(1, (3, 1280, 704), (1280, 704, 3), &lt;class 'torch.Tensor'&gt;, tensor(-0.4490, dtype=torch.float64))</p>
<p dir="auto">dataloader_train = DataLoader(train_dataset, batch_size=1,<br>
shuffle=True, pin_memory=True, num_workers=4)<br>
dataloader_valid = DataLoader(test_dataset, batch_size=1,<br>
shuffle=True, pin_memory=True, num_workers=4)</p>
<ul dir="auto">
<li>PyTorch Version (0.4.0):</li>
<li>OS (Linux):</li>
<li>How you installed PyTorch (<code class="notranslate">conda</code>):</li>
</ul>
<h2 dir="auto">Additional context</h2>
<h2 dir="auto">Issue Description</h2>
<p dir="auto">It seems that stacking is currently (PyTorch 0.4) is not supported for tensors of type <code class="notranslate">HalfTensor</code>; see code example.</p>
<p dir="auto">I don't know if this is intentional for some reason (hence I didn't label this issue as a bug), but I couldn't find any issue or documentation pointing to that. Since some methods, like <code class="notranslate">torch.utils.data.DataLoader</code>, depend on <code class="notranslate">torch.stack()</code> (in this case implicitly through the <code class="notranslate">default_collate()</code> method), it would be great if either stacking for HalfTensors could get implemented, or the documentation could be updated to contain some kind of hint.</p>
<h2 dir="auto">Code Example</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Python 3.6.5 (default, Mar 30 2018, 06:41:49)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.3.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import torch

In [2]: torch.__version__
Out[2]: '0.4.0'

In [3]: tensor_1_float = torch.tensor([1, 2, 3], dtype=torch.float)

In [4]: tensor_2_float = torch.tensor([4, 5, 6], dtype=torch.float)

In [5]: torch.stack([tensor_1_float, tensor_2_float])
Out[5]:
tensor([[ 1.,  2.,  3.],
        [ 4.,  5.,  6.]])

In [6]: tensor_1_half = torch.tensor([1, 2, 3], dtype=torch.half)

In [7]: tensor_2_half = torch.tensor([4, 5, 6], dtype=torch.half)

In [8]: torch.stack([tensor_1_half, tensor_2_half])
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
&lt;ipython-input-8-10f49aa85ea5&gt; in &lt;module&gt;()
----&gt; 1 torch.stack([tensor_1_half, tensor_2_half])

RuntimeError: _cat is not implemented for type torch.HalfTensor"><pre class="notranslate"><code class="notranslate">Python 3.6.5 (default, Mar 30 2018, 06:41:49)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.3.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import torch

In [2]: torch.__version__
Out[2]: '0.4.0'

In [3]: tensor_1_float = torch.tensor([1, 2, 3], dtype=torch.float)

In [4]: tensor_2_float = torch.tensor([4, 5, 6], dtype=torch.float)

In [5]: torch.stack([tensor_1_float, tensor_2_float])
Out[5]:
tensor([[ 1.,  2.,  3.],
        [ 4.,  5.,  6.]])

In [6]: tensor_1_half = torch.tensor([1, 2, 3], dtype=torch.half)

In [7]: tensor_2_half = torch.tensor([4, 5, 6], dtype=torch.half)

In [8]: torch.stack([tensor_1_half, tensor_2_half])
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
&lt;ipython-input-8-10f49aa85ea5&gt; in &lt;module&gt;()
----&gt; 1 torch.stack([tensor_1_half, tensor_2_half])

RuntimeError: _cat is not implemented for type torch.HalfTensor
</code></pre></div>
<p dir="auto">On PyTorch 0.3.1, one gets basically the same error when one tries to do the same thing:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TypeError: Type torch.HalfTensor doesn't implement stateless method cat"><pre class="notranslate"><code class="notranslate">TypeError: Type torch.HalfTensor doesn't implement stateless method cat
</code></pre></div>