Fix half-float conversion ops to handle tensors larger than 2B of params (#17952)
authorAndrey Malevich <amalevich@fb.com>
Wed, 13 Mar 2019 05:57:44 +0000 (22:57 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 13 Mar 2019 06:03:22 +0000 (23:03 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17952

As desc.

Reviewed By: hyuen

Differential Revision: D14435092

fbshipit-source-id: dc614ba16ad531101d04d01aec8f1fbd534ebec5

caffe2/operators/half_float_ops.cc

index 3745121..b186ec6 100644 (file)
@@ -12,7 +12,7 @@ bool FloatToHalfOp<CPUContext>::RunOnDevice() {
   at::Half* out = output->template mutable_data<at::Half>();
   auto N = input.numel();
 
-  for (auto i = 0; i < N; i++) {
+  for (size_t i = 0; i < N; i++) {
     out[i] = data[i];
   }
 
@@ -28,7 +28,7 @@ bool HalfToFloatOp<CPUContext>::RunOnDevice() {
   float* out = output->template mutable_data<float>();
   auto N = input.numel();
 
-  for (auto i = 0; i < N; i++) {
+  for (size_t i = 0; i < N; i++) {
     out[i] = data[i];
   }
   return true;