pytorch/caffe2/core
Sean Lynch 64689c2474 Remove unecessary copy within blob serialization (#40096)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/40096

Declaring `tensor_proto` to be of type `auto` means that it will copy the entire `TensorProto` instead of just keeping a reference. This changes it to just use a const reference instead.

Test Plan:
Using the model loader benchmark to measure model loading performance:

### `tensor_proto` is of type `const auto&`
```
============================================================================
caffe2/caffe2/fb/predictor/ModelLoaderBenchmark.cpprelative  time/iter  iters/s
============================================================================
BlobProtoInt32DeserializationFloat16                        11.08ms    90.27
BlobProtoByteDeserializationFloat16             1509.73%   733.73us    1.36K
----------------------------------------------------------------------------
BlobProtoInt32DeserializationUInt8                          10.48ms    95.45
BlobProtoByteDeserializationUInt8               2974.57%   352.22us    2.84K
============================================================================
```

### `tensor_proto` is of type `auto`
```
============================================================================
caffe2/caffe2/fb/predictor/ModelLoaderBenchmark.cpprelative  time/iter  iters/s
============================================================================
BlobProtoInt32DeserializationFloat16                        13.84ms    72.26
BlobProtoByteDeserializationFloat16              658.85%     2.10ms   476.08
----------------------------------------------------------------------------
BlobProtoInt32DeserializationUInt8                          17.09ms    58.51
BlobProtoByteDeserializationUInt8               3365.98%   507.80us    1.97K
============================================================================
```

Reviewed By: marksantaniello

Differential Revision: D21959644

fbshipit-source-id: 6bc2dfbde306f88bf7cd4f9b14b95ac69c2e1b4d
2020-06-16 14:45:59 -07:00
..
hip
nomnigraph [nomni] fix outputs check to replaceSubgraph (#38005) 2020-05-07 19:58:15 -07:00
__init__.py
allocator.cc
allocator.h
asan.h
blob.h
blob_gpu_test.cc
blob_serialization.cc Remove unecessary copy within blob serialization (#40096) 2020-06-16 14:45:59 -07:00
blob_serialization.h Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
blob_serialization_gpu.cc
blob_serializer_base.h
blob_stats.cc
blob_stats.h
blob_test.cc [caffe2] Enable copying for caffe2::Tensor (#36468) 2020-04-13 21:41:52 -07:00
CMakeLists.txt Formatting cmake (to lowercase without space for if/elseif/else/endif) (#35521) 2020-03-27 14:25:17 -07:00
common.cc
common.h fix windows clang attributes (#33959) 2020-03-02 13:20:51 -08:00
common_cudnn.cc
common_cudnn.h Fix signed-unsigned warnings (#34791) 2020-03-19 00:29:56 -07:00
common_gpu.cc RIP CUDA <9.2: circleci, aten, and caffe2 (#36846) 2020-05-18 13:41:05 -07:00
common_gpu.h fix asserts in cuda code (#39047) 2020-05-28 15:51:38 -07:00
common_omp.h
common_test.cc
context.cc
context.h Call RandomNumberSeed() on-demand (#33539) 2020-02-22 01:22:18 -08:00
context_base.cc
context_base.h Fix is_fundamental template for MSVC (#30959) 2019-12-19 12:10:22 -08:00
context_gpu.cu [caffe2] Fix of initializing ATen's CUDA before using caching allocator (#39759) 2020-06-09 17:25:42 -07:00
context_gpu.h Do not throw from CUDAContext destructor (#34756) 2020-03-18 00:13:18 -07:00
context_gpu_test.cc
context_test.cc
cudnn_wrappers.h
db.cc
db.h
event.cc caffe2/event: allow multiple errors such as when cancelled (#31335) 2019-12-18 13:10:57 -08:00
event.h Back out "Revert D20449887: [dt][caffe2] enable using smart exceptions in async nets" (#36172) 2020-04-13 11:31:52 -07:00
event_cpu.h
event_gpu.cc
event_gpu_test.cc
event_test.cc caffe2/event: allow multiple errors such as when cancelled (#31335) 2019-12-18 13:10:57 -08:00
export_c10_op_to_caffe2.cc
export_c10_op_to_caffe2.h Remove callBoxedWorkaround (#36850) 2020-04-24 23:13:31 -07:00
export_caffe2_op_to_c10.h [c10] Fix the hanlding for Caffe2 ops which return tensor list (#36841) 2020-04-18 13:30:43 -07:00
flags.h
graph.cc
graph.h
graph_test.cc
init.cc
init.h
init_denormals.cc
init_intrinsics_check.cc
init_omp.cc
init_test.cc
int8_serialization.cc
logging.h
macros.h
macros.h.in Remove duplicated Numa detection code. (#30628) 2020-01-03 08:48:46 -08:00
memonger.cc Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
memonger.h
module.cc Allow checking for cached module before asserting (#33954) 2020-03-02 15:43:50 -08:00
module.h
module_test.cc
net.cc
net.h caffe2/core/plan_executor: add cancellation of async nets on error + propagate exceptions via std::exception_ptr for stack traces (#31966) 2020-04-09 14:38:18 -07:00
net_async_base.cc Back out "Revert D20449887: [dt][caffe2] enable using smart exceptions in async nets" (#36172) 2020-04-13 11:31:52 -07:00
net_async_base.h Back out "Revert D20449887: [dt][caffe2] enable using smart exceptions in async nets" (#36172) 2020-04-13 11:31:52 -07:00
net_async_scheduling.cc Back out "Revert D20449887: [dt][caffe2] enable using smart exceptions in async nets" (#36172) 2020-04-13 11:31:52 -07:00
net_async_scheduling.h caffe2/core/plan_executor: add cancellation of async nets on error + propagate exceptions via std::exception_ptr for stack traces (#31966) 2020-04-09 14:38:18 -07:00
net_async_task.cc Fix signed-unsigned warnings (#34791) 2020-03-19 00:29:56 -07:00
net_async_task.h
net_async_task_future.cc Replace c10::guts::stuff with std::stuff (#30915) 2019-12-16 13:57:19 -08:00
net_async_task_future.h
net_async_task_graph.cc Replace c10::guts::stuff with std::stuff (#30915) 2019-12-16 13:57:19 -08:00
net_async_task_graph.h
net_async_tracing.cc Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
net_async_tracing.h
net_async_tracing_test.cc
net_dag_utils.cc
net_dag_utils.h
net_dag_utils_test.cc
net_gpu_test.cc
net_parallel.cc Fix signed-unsigned warnings (#34791) 2020-03-19 00:29:56 -07:00
net_parallel.h
net_simple.cc Wait for all op types in SimpleNet (#39493) 2020-06-11 13:00:34 -07:00
net_simple.h
net_simple_refcount.cc Fix signed-unsigned warnings (#34791) 2020-03-19 00:29:56 -07:00
net_simple_refcount.h
net_simple_refcount_test.cc
net_test.cc Back out "Revert D20449887: [dt][caffe2] enable using smart exceptions in async nets" (#36172) 2020-04-13 11:31:52 -07:00
numa.cc
numa.h
observer.h
observer_test.cc Replace c10::guts::stuff with std::stuff (#30915) 2019-12-16 13:57:19 -08:00
operator.cc Make msg() and msg_with_backtrace() private (#37094) 2020-05-04 11:54:34 -07:00
operator.h Refactor error msg stack handling, add TORCH_RETHROW (#37101) 2020-05-04 11:56:45 -07:00
operator_gpu_test.cc
operator_gradient.h
operator_schema.cc Replace c10::guts::stuff with std::stuff (#30915) 2019-12-16 13:57:19 -08:00
operator_schema.h Revert D20735881: [pytorch][PR] [WIP] [reland][pytorch][PR] Fix some incorrect annotation… 2020-03-30 12:28:27 -07:00
operator_schema_test.cc
operator_test.cc Make msg() and msg_with_backtrace() private (#37094) 2020-05-04 11:54:34 -07:00
parallel_net_test.cc [Caffe2] Increase timing threshold to 50 ms on Windows (#37892) 2020-05-05 19:45:36 -07:00
plan_executor.cc caffe2/core/plan_executor: add cancellation of async nets on error + propagate exceptions via std::exception_ptr for stack traces (#31966) 2020-04-09 14:38:18 -07:00
plan_executor.h
plan_executor_test.cc caffe2/core/plan_executor: add cancellation of async nets on error + propagate exceptions via std::exception_ptr for stack traces (#31966) 2020-04-09 14:38:18 -07:00
prof_dag_counters.cc Fix signed-unsigned warnings (#34791) 2020-03-19 00:29:56 -07:00
prof_dag_counters.h Fix signed-unsigned warnings (#34791) 2020-03-19 00:29:56 -07:00
qtensor.cc
qtensor.h
qtensor_serialization.cc
qtensor_serialization.h
scope_guard.h Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
static_tracepoint.h
static_tracepoint_elfx86.h Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
stats.cc
stats.h
stats_test.cc
storage.h
tensor.cc Remove datatype from Storage and StorageImpl (#38870) 2020-05-21 15:26:08 -07:00
tensor.h Remove datatype from Storage and StorageImpl (#38870) 2020-05-21 15:26:08 -07:00
tensor_impl.h
tensor_int8.cc
tensor_int8.h
test_utils.cc C++ C2/Glow operator unittest 2020-01-17 12:13:34 -08:00
test_utils.h C++ C2/Glow operator unittest 2020-01-17 12:13:34 -08:00
timer.h
timer_test.cc Increase TimerTest tolerance to 20% on Windows (#35818) 2020-04-01 14:29:05 -07:00
transform.cc
transform.h
transform_test.cc fixup unit tests (#34105) 2020-03-03 10:33:21 -08:00
types.cc
types.h
workspace.cc Wait for all op types in SimpleNet (#39493) 2020-06-11 13:00:34 -07:00
workspace.h Fix typos, via a Levenshtein-type corrector (#31523) 2020-01-17 16:03:19 -08:00
workspace_test.cc