|
|
|
@@ -17,6 +17,7 @@ |
|
|
|
|
|
|
|
#include "pass_level0/constant_unpooling.h" |
|
|
|
#include "pass_level0/inline_block.h" |
|
|
|
#include "pass_level0/reset_device.h" |
|
|
|
#include "pass_level0/shape_inference.h" |
|
|
|
|
|
|
|
namespace pnnx { |
|
|
|
@@ -77,7 +78,7 @@ static bool value_link_output(const torch::jit::Value* v, const std::vector<torc |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
void shape_inference(const torch::jit::Module& mod, std::shared_ptr<torch::jit::Graph>& graph, const std::vector<at::Tensor>& input_tensors, const std::vector<at::Tensor>& input_tensors2, const std::vector<std::string>& module_operators, const std::string& ptpath, std::map<std::string, Attribute>& foldable_constants) |
|
|
|
void shape_inference(const torch::jit::Module& mod, std::shared_ptr<torch::jit::Graph>& graph, const std::vector<at::Tensor>& input_tensors, const std::vector<at::Tensor>& input_tensors2, const std::vector<std::string>& module_operators, const std::string& ptpath, const std::string& device, std::map<std::string, Attribute>& foldable_constants) |
|
|
|
{ |
|
|
|
// collect all intermediate output tensors |
|
|
|
std::vector<std::unordered_set<std::string> > more_value_names; |
|
|
|
@@ -150,13 +151,15 @@ void shape_inference(const torch::jit::Module& mod, std::shared_ptr<torch::jit:: |
|
|
|
|
|
|
|
// auto mod2 = mod.deepcopy(); |
|
|
|
|
|
|
|
torch::jit::Module mod2 = torch::jit::load(ptpath); |
|
|
|
torch::jit::Module mod2 = torch::jit::load(ptpath, (device == "gpu") ? c10::kCUDA : c10::kCPU); |
|
|
|
mod2.eval(); |
|
|
|
|
|
|
|
auto graph2 = mod2.get_method("forward").graph(); |
|
|
|
|
|
|
|
inline_block(graph2, module_operators); |
|
|
|
|
|
|
|
reset_device(graph2, device); |
|
|
|
|
|
|
|
constant_unpooling(graph2); |
|
|
|
|
|
|
|
std::vector<torch::jit::Value*> values2; |
|
|
|
|