pytorch/binaries
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
..
bench_gen Update from facebook 1ee4edd286a3 (#8040) 2018-06-01 17:41:09 -04:00
benchmark_helper.cc caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
benchmark_helper.h Add benchmarking functionality to the benchmark app (#10976) 2018-08-30 09:54:55 -07:00
caffe2_benchmark.cc Caffe2 flags needs to be used after the GlobalInit function is called 2018-08-30 19:10:39 -07:00
CMakeLists.txt Hipify Caffe2 binaries (#10468) 2018-08-13 20:56:28 -07:00
convert_caffe_image_db.cc Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
convert_db.cc Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
convert_encoded_to_raw_leveldb.cc Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
core_overhead_benchmark_gpu.cc caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
db_throughput.cc
inspect_gpu.cc Hipify Caffe2 binaries (#10468) 2018-08-13 20:56:28 -07:00
make_cifar_db.cc Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
make_image_db.cc Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
make_mnist_db.cc Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
predictor_verifier.cc Update mobile predictor caller's interface 2018-08-24 23:40:05 -07:00
print_core_object_sizes_gpu.cc Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
print_registered_core_operators.cc caffe2::DeviceType -> at::DeviceType (#11254) 2018-09-05 16:28:09 -07:00
run_plan.cc Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
run_plan_mpi.cc Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
speed_benchmark.cc Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
split_db.cc Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
tsv_2_proto.cc Replace direct include of caffe2.pb.h with an intermediary header caffe2_pb.h (#10946) 2018-08-28 11:57:08 -07:00
tutorial_blob.cc
zmq_feeder.cc