Skip to content

[IR2Vec] Add embeddings mode to llvm-ir2vec tool #147844

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

Open
wants to merge 1 commit into
base: users/svkeerthy/07-09-ir2vec_tool
Choose a base branch
from

Conversation

svkeerthy
Copy link
Contributor

@svkeerthy svkeerthy commented Jul 9, 2025

Add embedding generation functionality to the llvm-ir2vec tool, complementing the existing triplet generation mode.

This change completes the IR2Vec tool by adding the embedding generation functionality, which was previously mentioned as a TODO item. The tool now supports both triplet generation for vocabulary training and embedding generation using a trained vocabulary.

@svkeerthy svkeerthy changed the title IR2Vec Tool Enhancements [IR2Vec] Add embeddings mode to llvm-ir2vec tool Jul 9, 2025
@svkeerthy svkeerthy marked this pull request as ready for review July 9, 2025 22:55
Copy link
Contributor

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

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

Premerge failures here also look relevant.

@@ -0,0 +1,73 @@
; RUN: llvm-ir2vec --mode=embeddings --ir2vec-vocab-path=%S/../../Analysis/IR2Vec/Inputs/dummy_3D_nonzero_opc_vocab.json %s | FileCheck %s -check-prefix=CHECK-DEFAULT
Copy link
Contributor

Choose a reason for hiding this comment

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

Given you access %S../../Analysis/IR2Vec/Inputs so often, I'm wondering if it makes sense to add a lit substitution. Maybe something like %ir2vec_test_vocab or something.

namespace {

/// Helper class for collecting IR information and generating triplets
/// Helper class for collecting IR information and generating embeddings
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment seems incorrect given this can do embeddings and triplets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the catch. Will fix it.

}
}

// OS << "\n";
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove?

"--level=func (functions)\n");

// Validate command line options
if (Mode == TripletMode && Level != FunctionLevel) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a bit confusing if the user explicitly requests function level triplet mode. I think there's a way to see if the user has actually passed a flag with cl::opt, but I'm not sure.

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