mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
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 |
||
|---|---|---|
| .. | ||
| bench_gen | ||
| benchmark_helper.cc | ||
| benchmark_helper.h | ||
| caffe2_benchmark.cc | ||
| CMakeLists.txt | ||
| convert_caffe_image_db.cc | ||
| convert_db.cc | ||
| convert_encoded_to_raw_leveldb.cc | ||
| core_overhead_benchmark_gpu.cc | ||
| db_throughput.cc | ||
| inspect_gpu.cc | ||
| make_cifar_db.cc | ||
| make_image_db.cc | ||
| make_mnist_db.cc | ||
| predictor_verifier.cc | ||
| print_core_object_sizes_gpu.cc | ||
| print_registered_core_operators.cc | ||
| run_plan.cc | ||
| run_plan_mpi.cc | ||
| speed_benchmark.cc | ||
| split_db.cc | ||
| tsv_2_proto.cc | ||
| tutorial_blob.cc | ||
| zmq_feeder.cc | ||