# RuntimeError: “add\_cpu/sub\_cpu” not implemented for ‘Half’ when using Float16/Half

**URL:** <https://discuss.pytorch.org/t/runtimeerror-add-cpu-sub-cpu-not-implemented-for-half-when-using-float16-half/66229>\
**Category:** jit\
**Created:** [January 9, 2020, 9:41pm UTC](https://discuss.pytorch.org/t/runtimeerror-add-cpu-sub-cpu-not-implemented-for-half-when-using-float16-half/66229 "2020-01-09T21:41:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![flynntax](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/f/3ec8ea/32.png) [@flynntax](https://discuss.pytorch.org/u/flynntax)\
**Post date:** [January 9, 2020, 9:41pm UTC](https://discuss.pytorch.org/t/runtimeerror-add-cpu-sub-cpu-not-implemented-for-half-when-using-float16-half/66229/1 "2020-01-09T21:41:59Z")

</div>

Hello, I am testing out different types in PyTorch and noticed when calling torch.jit.trace where the input is float16/half, I am getting a runtime error (RuntimeError: “add\_cpu/sub\_cpu” not implemented for ‘Half’). Does tracing not work for float16? I believe I also tested with int32 inputs which work.

---

<div class="post-metadata">

**Author:** ![tom](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tom/32/3162_2.png) [@tom](https://discuss.pytorch.org/u/tom)\
**Post date:** [January 9, 2020, 10:30pm UTC](https://discuss.pytorch.org/t/runtimeerror-add-cpu-sub-cpu-not-implemented-for-half-when-using-float16-half/66229/2 "2020-01-09T22:30:53Z")

</div>

I think this might be more about operations that PyTorch supports on GPU than the types.  
Does the same code run in plain PyTorch?

Best regards

Thomas

---

<div class="post-metadata">

**Author:** ![flynntax](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/f/3ec8ea/32.png) [@flynntax](https://discuss.pytorch.org/u/flynntax)\
**Post date:** [January 9, 2020, 10:57pm UTC](https://discuss.pytorch.org/t/runtimeerror-add-cpu-sub-cpu-not-implemented-for-half-when-using-float16-half/66229/3 "2020-01-09T22:57:01Z")

</div>

You are right in that this doesn’t seem to work for eager mode (guessing this is plain PyTorch) as just calling model(input) causes the same runtime error. But I am not running on a GPU right now (just a macbook). I guess I can probably change the category and rename the question. I guess Half is just not supported for CPU?

---

<div class="post-metadata">

**Author:** ![tom](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tom/32/3162_2.png) [@tom](https://discuss.pytorch.org/u/tom)\
**Post date:** [January 12, 2020, 9:09am UTC](https://discuss.pytorch.org/t/runtimeerror-add-cpu-sub-cpu-not-implemented-for-half-when-using-float16-half/66229/4 "2020-01-12T09:09:30Z")

</div>

Indeed. (That’d be a fun weekend project for you! 😛 )
