pytorch/caffe2
Jerry Zhang 9f4bcdf075 caffe2::DeviceType -> at::DeviceType (#11254)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/11254
Previously we use DeviceType in caffe2.proto directly, but it's an `enum` and have implicit conversion to int, which does not have type safety, e.g. we have to explicitly check for a device type is valid in event.h:
```
template <int d>
struct EventCreateFunctionRegisterer {
  explicit EventCreateFunctionRegisterer(EventCreateFunction f) {
    static_assert(d < MaxDeviceTypes, "");
    Event::event_creator_[d] = f;
  }
};
```
at::DeviceType is an `enum class`, and it does not have implicit conversion to int, and provides better type safety guarantees. In this diff we have done the following refactor(taking CPU as an example):

    1. caffe2::DeviceType → caffe2::DeviceTypeProto
    2. caffe2::CPU → caffe2::PROTO_CPU
    3. caffe2::DeviceType = at::DeviceType
    4. caffe2::CPU = at::DeviceType::CPU

codemod -d caffe2/caffe2 --extensions h,cc,cpp 'device_type\(\), ' 'device_type(), PROTO_'
+ some manual changes

In short, after this diff, in c++, caffe2::CPU refers to the at::DeviceType::CPU and the old proto caffe2::CPU will be caffe2::PROTO_CPU.
In python side, we have a temporary workaround that alias `caffe2_pb2.CPU = caffe2_pb2.PROOT_CPU` to make the change easier to review and this will be removed later.

Reviewed By: ezyang

Differential Revision: D9545704

fbshipit-source-id: 461a28a4ca74e616d3ee183a607078a717fd38a7
2018-09-05 16:28:09 -07:00
..
contrib caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
core caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
cuda_rtc
db Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
distributed Additional changes to make GPU builds work (#10507) 2018-08-16 13:25:27 -07:00
experiments Move filler interface to operator schema (#10522) 2018-08-15 12:40:18 -07:00
ideep caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
image
mkl caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
mobile caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
mpi Export MPI functions (#11037) 2018-08-30 10:42:02 -07:00
observers update documentation for observers 2018-08-30 18:11:48 -07:00
onnx fix the slice onnx exporting 2018-08-31 17:40:03 -07:00
operators caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
opt caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
perfkernels Faster random number generation in fused_rowwise_random_quantization_ops (#10634) 2018-08-22 13:15:46 -07:00
predictor Back out "[caffe2] Update blackbox predictor with new constructor" (#11105) 2018-08-31 00:55:36 -07:00
proto caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
python caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
queue build changes to make cpu unified build working. (#10504) 2018-08-15 17:22:36 -07:00
sgd Revert D9554375: Support lr adaption for SparseAdam and RowWiseSparseAdam 2018-08-31 07:54:31 -07:00
share Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
test
transforms caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
utils caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
video
.clang-format
__init__.py
CMakeLists.txt Remove BUILD_CAFFE2 and build everything (#8338) 2018-08-31 13:10:24 -07:00
README.md Fix issues link in Caffe2 readme (#10711) 2018-08-20 16:55:11 -07:00
release-notes.md
requirements.txt
VERSION_NUMBER

Caffe2

Jenkins Build Status

Caffe2 is a lightweight, modular, and scalable deep learning framework. Building on the original Caffe, Caffe2 is designed with expression, speed, and modularity in mind.

Questions and Feedback

Please use Github issues (https://github.com/pytorch/pytorch/issues) to ask questions, report bugs, and request new features.

Further Resources on Caffe2.ai