RuntimeError: “add_cpu/sub_cpu” not implemented for ‘Half’ when using Float16/Half

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.

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


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?

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