Skip to content

Conversation

@LeiWang1999
Copy link
Contributor

@LeiWang1999 LeiWang1999 commented Jan 19, 2024

Refer to this issue
#16433 , the relax Pass FuseTIR creates intermediate name by

n->name = param->name_hint + "_intermediate";

which may lead to some bugs when we encounter two fused blocks with the same param name, for example what I encountered in resnet-18, the conv+add+multiply+add, the fused two add operators' block may point to the same block.

So we should provide a method to get an unique name for each in duplicate buffers.

auto unify_name_hints = [this, &buffer, &param]() {
        String base_name = buffer->name;
        String unique_name = base_name + "_intermediate";
        size_t unique_id = 0;
        std::unordered_set<std::string> names;

        for (auto& _buffer : func_info_.alloc_buffers) {
          names.insert(_buffer->name);
        }

        while (names.find(unique_name) != names.end()) {
          unique_name = unique_name + "_" + std::to_string(++unique_id);
        }
 return unique_name;
 };

@LeiWang1999
Copy link
Contributor Author

Please CC @Hzfengsy

Copy link
Member

@junrushao junrushao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants