Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support parallel encoding ? #2

Open
qZhang88 opened this issue Dec 9, 2023 · 1 comment
Open

support parallel encoding ? #2

qZhang88 opened this issue Dec 9, 2023 · 1 comment

Comments

@qZhang88
Copy link

qZhang88 commented Dec 9, 2023

Notice that encoding is done one by one. Would it be faster if find all pieces first, then encode parallelly?

        while (re2::RE2::FindAndConsume(&input, *_regex, &piece)) {
            auto iter = _encoder.find(piece);
            if (iter != _encoder.end()) {
                last_piece_token_len = 1;
                ret.push_back(iter->second);
                continue;
            }
            auto tokens = _byte_pair_encode(piece, _encoder);
            last_piece_token_len = tokens.size();
            ret.insert(ret.end(), tokens.begin(), tokens.end());
        }
@sewenew
Copy link
Owner

sewenew commented Dec 11, 2023

Yes, you can have a try. Put all pieces into a vector, and then run OpenMPI or TBB threads to do the encoding stuff in parallel.

Regards

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

No branches or pull requests

2 participants