- refactoring serialization of ONNX initializers to be name-based (#17420)
authorSpandan Tiwari <sptiwari@microsoft.com>
Thu, 7 Mar 2019 18:06:17 +0000 (10:06 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 7 Mar 2019 18:25:00 +0000 (10:25 -0800)
commite4c9d75008f5a8d5cd44c6b4e24d1e90bb81c598
tree392e8b307100d3970f05aadf389cbc9656438c83
parent3f94fc4862d080fd1d765b948b6da93209cab990
- refactoring serialization of ONNX initializers to be name-based (#17420)

Summary:
Currently, serialization of model parameters in ONNX export depends on the order in which they are stored in a container (`list` on Python side and `std::vector` on C++ side). This has worked fine till now, but if we need to do any pass on that graph that mutates the parameter list, then strictly order-based serialization may not work.

This PR is the first in a set to bring in more passes (such as constant folding) related to ONNX export. This PR lays the groundwork by moving the serialization in ONNX export from order-based to name based approach, which is more amenable to some of the passes.

houseroad - As discussed this change uses a map for export, and removes the code from `export.cpp` that relies on the order to compute initializer names.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17420

Differential Revision: D14361993

Pulled By: houseroad

fbshipit-source-id: da93e945d55755c126de06641f35df87d1648cc4
torch/csrc/jit/export.cpp
torch/csrc/jit/export.h
torch/csrc/jit/python_ir.cpp
torch/onnx/utils.py