summaryrefslogtreecommitdiff
path: root/caffe2/core
diff options
context:
space:
mode:
authorHector Yuen <hyz@fb.com>2019-03-19 10:30:29 -0700
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2019-03-19 10:39:20 -0700
commit7bb36ada1f2711708b504b08981f9f8b93963595 (patch)
tree610a4428faffa780d9af1f87c2a898aaf3f4c1a3 /caffe2/core
parent1c76746f61598cc3c3f05057fd8ebc5e771338fc (diff)
downloadpytorch-7bb36ada1f2711708b504b08981f9f8b93963595.tar.gz
pytorch-7bb36ada1f2711708b504b08981f9f8b93963595.tar.bz2
pytorch-7bb36ada1f2711708b504b08981f9f8b93963595.zip
fix -Wsign-compare warnings for some files inside c2 (#18123)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/18123 the motivation of this fix is to resolve things like: for(auto i = 0; i < N; i++) where N is bigger than int32 These instances of comparison were found by enabling -Wsign-compare There are way too many things to fix, so issuing this as a series of fixes The plan is to fix all these issues and then enable this flag into Caffe2 to catch future instances Reviewed By: ZolotukhinM Differential Revision: D14497094 fbshipit-source-id: bca3927a2188bd33a508fa503ba221c220cdaefe
Diffstat (limited to 'caffe2/core')
-rw-r--r--caffe2/core/blob_serialization.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/caffe2/core/blob_serialization.h b/caffe2/core/blob_serialization.h
index f61331e9dd..a38ee67993 100644
--- a/caffe2/core/blob_serialization.h
+++ b/caffe2/core/blob_serialization.h
@@ -162,7 +162,7 @@ inline void CopyToProtoAsIs(
"The source type and dest type cannot be copied as-is. Did "
"you mean CopyToProtoWithCast?");
field->Reserve(size);
- for (int i = 0; i < size; ++i) {
+ for (size_t i = 0; i < size; ++i) {
field->Add(0);
}
context->template CopyToCPU<SrcType>(
@@ -183,7 +183,7 @@ inline void CopyToProtoWithCast(
context->template CopyToCPU<SrcType>(size, src, buffer.get());
context->FinishDeviceComputation();
field->Reserve(size);
- for (int i = 0; i < size; ++i) {
+ for (size_t i = 0; i < size; ++i) {
field->Add(static_cast<DstType>(buffer[i]));
}
}
@@ -214,7 +214,7 @@ inline void CopyFromProtoWithCast(
// CPUContext. Remove it if it is performance critical.
unique_ptr<DstType[]> buffer(new DstType[size]);
const SrcType* src = field.data();
- for (int i = 0; i < size; ++i) {
+ for (size_t i = 0; i < size; ++i) {
buffer[i] = static_cast<DstType>(src[i]);
}
context->template CopyFromCPU<DstType>(size, buffer.get(), dst);