Skip to content

Commit

Permalink
fix bug of iter
Browse files Browse the repository at this point in the history
  • Loading branch information
sen.li committed Jun 27, 2024
1 parent 2841063 commit 909f165
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions tools/pnnx/src/ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4950,10 +4950,10 @@ Operator* MainGraph::set_sub_graph_new_input(const std::string& sub_graph_name,

void MainGraph::set_op_new_input(std::string& sub_graph_name2, Operator* new_input_op)
{
for (auto& it = op_2_graph.begin(); it != op_2_graph.end(); ++it)
for (auto it = op_2_graph.begin(); it != op_2_graph.end(); ++it)
{
auto& op_2_graph_input_list = it->second;
for (auto& it2 = op_2_graph_input_list.begin(); it2 != op_2_graph_input_list.end(); ++it2)
for (auto it2 = op_2_graph_input_list.begin(); it2 != op_2_graph_input_list.end(); ++it2)
{
if(it2->first == sub_graph_name2)
{
Expand Down
2 changes: 1 addition & 1 deletion tools/pnnx/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ int main(int argc, char** argv)
}

std::set<std::string> foldable_constants;
std::string foldable_constants_zippath = ptbase + ".foldable_constants.zip";
std::string foldable_constants_zippath = save_dir + "/model.foldable_constants.zip";

if(input_shapes2.size() > 0)
{
Expand Down
16 changes: 9 additions & 7 deletions tools/pnnx/src/pass_level1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,19 +474,21 @@ void PassLevel1::Process_Loop(const torch::jit::Module& mod,
int init_input_num = op->inputs.size();
for (const torch::jit::Block* subBlock : n->blocks())
{
std::string loop_block_name = std::string(loop_op_name);
std::shared_ptr<pnnx::MainGraph> sub_pnnx_graph = std::make_shared<pnnx::MainGraph>();
sub_pnnx_graph->create_main_graph(std::string(loop_op_name));
pnnx_graph->insert_sub_graph(std::string(loop_op_name), sub_pnnx_graph, op, init_input_num);
sub_pnnx_graph->create_main_graph(loop_block_name);
pnnx_graph->insert_sub_graph(loop_block_name, sub_pnnx_graph, op, init_input_num);
sub_pnnx_graph->set_base_graph(pnnx_graph);
// ASSERT_INFO(block_num == 0 , "block num > 1 in loop");
std::string loop_block_name = std::string(loop_op_name);

Process_Loop_block(mod, subBlock, sub_pnnx_graph, op, loop_block_name);
pnnx_graph->effective_sub_model_name.push_back(loop_block_name);
block_num++;
block_names.push_back(loop_block_name);

}

block_names.push_back(std::string(loop_op_name));


}


Expand Down Expand Up @@ -764,10 +766,10 @@ void PassLevel1::Process_Input(Operator* op,
// set this op with new input
auto base_graph = tmp_base_graph->get_base_graph();
std::string sub_graph_name = base_graph_names.back();
for (auto& it = base_graph->op_2_graph.begin(); it != base_graph->op_2_graph.end(); ++it)
for (auto it = base_graph->op_2_graph.begin(); it != base_graph->op_2_graph.end(); ++it)
{
auto& op_2_graph_input_list = it->second;
for (auto& it2 = op_2_graph_input_list.begin(); it2 != op_2_graph_input_list.end(); ++it2)
for (auto it2 = op_2_graph_input_list.begin(); it2 != op_2_graph_input_list.end(); ++it2)
{
if(it2->first == sub_graph_name)
{
Expand Down

0 comments on commit 909f165

Please sign in to comment.