mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-27 09:04:53 +08:00
[ONNX] Add eliminate_unused_items pass (#38812)
Summary: This PR: - Adds eliminate_unused_items pass that removes unused inputs and initializers. - Fixes run_embed_params function so it doesn't export unnecessary parameters. - Removes test_modifying_params in test_verify since it's no longer needed. Pull Request resolved: https://github.com/pytorch/pytorch/pull/38812 Reviewed By: ezyang Differential Revision: D22236416 Pulled By: houseroad fbshipit-source-id: 30e1a6e8823a7e36b51ae1823cc90476a53cd5bb
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5466231187
commit
547ea787ff
@ -31,6 +31,7 @@
|
||||
#include <torch/csrc/jit/passes/onnx.h>
|
||||
#include <torch/csrc/jit/passes/onnx/cast_all_constant_to_floating.h>
|
||||
#include <torch/csrc/jit/passes/onnx/constant_fold.h>
|
||||
#include <torch/csrc/jit/passes/onnx/eliminate_unused_items.h>
|
||||
#include <torch/csrc/jit/passes/onnx/fixup_onnx_conditionals.h>
|
||||
#include <torch/csrc/jit/passes/onnx/fixup_onnx_loop.h>
|
||||
#include <torch/csrc/jit/passes/onnx/function_substitution.h>
|
||||
@ -156,6 +157,16 @@ void initJITBindings(PyObject* module) {
|
||||
return paramsDict;
|
||||
},
|
||||
pybind11::return_value_policy::move)
|
||||
.def(
|
||||
"_jit_pass_onnx_eliminate_unused_items",
|
||||
[](std::shared_ptr<Graph>& graph,
|
||||
std::map<std::string, IValue>& paramsDict) {
|
||||
EliminateUnusedItemsONNX(
|
||||
graph->block(),
|
||||
paramsDict); // overload resolution
|
||||
return paramsDict;
|
||||
},
|
||||
pybind11::return_value_policy::move)
|
||||
.def("_jit_pass_onnx_scalar_type_analysis", ScalarTypeAnalysisForONNX)
|
||||
.def(
|
||||
"_jit_pass_onnx_prepare_inplace_ops_for_onnx",
|
||||
|
||||
Reference in New Issue
Block a user