aboutsummaryrefslogtreecommitdiff
path: root/llvm/docs/CommandGuide/llvm-ir2vec.rst
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/docs/CommandGuide/llvm-ir2vec.rst')
-rw-r--r--llvm/docs/CommandGuide/llvm-ir2vec.rst120
1 files changed, 62 insertions, 58 deletions
diff --git a/llvm/docs/CommandGuide/llvm-ir2vec.rst b/llvm/docs/CommandGuide/llvm-ir2vec.rst
index 2f00c9f..0c9fb6e 100644
--- a/llvm/docs/CommandGuide/llvm-ir2vec.rst
+++ b/llvm/docs/CommandGuide/llvm-ir2vec.rst
@@ -6,27 +6,27 @@ llvm-ir2vec - IR2Vec Embedding Generation Tool
SYNOPSIS
--------
-:program:`llvm-ir2vec` [*options*] *input-file*
+:program:`llvm-ir2vec` [*subcommand*] [*options*]
DESCRIPTION
-----------
:program:`llvm-ir2vec` is a standalone command-line tool for IR2Vec. It
generates IR2Vec embeddings for LLVM IR and supports triplet generation
-for vocabulary training. It provides three main operation modes:
+for vocabulary training. The tool provides three main subcommands:
-1. **Triplet Mode**: Generates numeric triplets in train2id format for vocabulary
+1. **triplets**: Generates numeric triplets in train2id format for vocabulary
training from LLVM IR.
-2. **Entity Mode**: Generates entity mapping files (entity2id.txt) for vocabulary
+2. **entities**: Generates entity mapping files (entity2id.txt) for vocabulary
training.
-3. **Embedding Mode**: Generates IR2Vec embeddings using a trained vocabulary
+3. **embeddings**: Generates IR2Vec embeddings using a trained vocabulary
at different granularity levels (instruction, basic block, or function).
The tool is designed to facilitate machine learning applications that work with
LLVM IR by converting the IR into numerical representations that can be used by
-ML models. The triplet mode generates numeric IDs directly instead of string
+ML models. The `triplets` subcommand generates numeric IDs directly instead of string
triplets, streamlining the training data preparation workflow.
.. note::
@@ -53,111 +53,115 @@ for details).
See `llvm/utils/mlgo-utils/IR2Vec/generateTriplets.py` for more details on how
these two modes are used to generate the triplets and entity mappings.
-Triplet Generation Mode
-~~~~~~~~~~~~~~~~~~~~~~~
+Triplet Generation
+~~~~~~~~~~~~~~~~~~
-In triplet mode, :program:`llvm-ir2vec` analyzes LLVM IR and extracts numeric
-triplets consisting of opcode IDs, type IDs, and operand IDs. These triplets
-are generated in the standard format used for knowledge graph embedding training.
-The tool outputs numeric IDs directly using the ir2vec::Vocabulary mapping
+With the `triplets` subcommand, :program:`llvm-ir2vec` analyzes LLVM IR and extracts
+numeric triplets consisting of opcode IDs, type IDs, and operand IDs. These triplets
+are generated in the standard format used for knowledge graph embedding training.
+The tool outputs numeric IDs directly using the ir2vec::Vocabulary mapping
infrastructure, eliminating the need for string-to-ID preprocessing.
Usage:
.. code-block:: bash
- llvm-ir2vec --mode=triplets input.bc -o triplets_train2id.txt
+ llvm-ir2vec triplets input.bc -o triplets_train2id.txt
-Entity Mapping Generation Mode
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Entity Mapping Generation
+~~~~~~~~~~~~~~~~~~~~~~~~~
-In entity mode, :program:`llvm-ir2vec` generates the entity mappings supported by
-IR2Vec in the standard format used for knowledge graph embedding training. This
-mode outputs all supported entities (opcodes, types, and operands) with their
-corresponding numeric IDs, and is not specific for an LLVM IR file.
+With the `entities` subcommand, :program:`llvm-ir2vec` generates the entity mappings
+supported by IR2Vec in the standard format used for knowledge graph embedding
+training. This subcommand outputs all supported entities (opcodes, types, and
+operands) with their corresponding numeric IDs, and is not specific for an
+LLVM IR file.
Usage:
.. code-block:: bash
- llvm-ir2vec --mode=entities -o entity2id.txt
+ llvm-ir2vec entities -o entity2id.txt
-Embedding Generation Mode
-~~~~~~~~~~~~~~~~~~~~~~~~~~
+Embedding Generation
+~~~~~~~~~~~~~~~~~~~~
-In embedding mode, :program:`llvm-ir2vec` uses a pre-trained vocabulary to
+With the `embeddings` subcommand, :program:`llvm-ir2vec` uses a pre-trained vocabulary to
generate numerical embeddings for LLVM IR at different levels of granularity.
Example Usage:
.. code-block:: bash
- llvm-ir2vec --mode=embeddings --ir2vec-vocab-path=vocab.json --level=func input.bc -o embeddings.txt
+ llvm-ir2vec embeddings --ir2vec-vocab-path=vocab.json --level=func input.bc -o embeddings.txt
OPTIONS
-------
-.. option:: --mode=<mode>
+Global options:
+
+.. option:: -o <filename>
+
+ Specify the output filename. Use ``-`` to write to standard output (default).
+
+.. option:: --help
+
+ Print a summary of command line options.
- Specify the operation mode. Valid values are:
+Subcommand-specific options:
- * ``triplets`` - Generate triplets for vocabulary training
- * ``entities`` - Generate entity mappings for vocabulary training
- * ``embeddings`` - Generate embeddings using trained vocabulary (default)
+**embeddings** subcommand:
+
+.. option:: <input-file>
+
+ The input LLVM IR or bitcode file to process. This positional argument is
+ required for the `embeddings` subcommand.
.. option:: --level=<level>
- Specify the embedding generation level. Valid values are:
+ Specify the embedding generation level. Valid values are:
- * ``inst`` - Generate instruction-level embeddings
- * ``bb`` - Generate basic block-level embeddings
- * ``func`` - Generate function-level embeddings (default)
+ * ``inst`` - Generate instruction-level embeddings
+ * ``bb`` - Generate basic block-level embeddings
+ * ``func`` - Generate function-level embeddings (default)
.. option:: --function=<name>
- Process only the specified function instead of all functions in the module.
+ Process only the specified function instead of all functions in the module.
.. option:: --ir2vec-vocab-path=<path>
- Specify the path to the vocabulary file (required for embedding mode).
- The vocabulary file should be in JSON format and contain the trained
- vocabulary for embedding generation. See `llvm/lib/Analysis/models`
- for pre-trained vocabulary files.
+ Specify the path to the vocabulary file (required for embedding generation).
+ The vocabulary file should be in JSON format and contain the trained
+ vocabulary for embedding generation. See `llvm/lib/Analysis/models`
+ for pre-trained vocabulary files.
.. option:: --ir2vec-opc-weight=<weight>
- Specify the weight for opcode embeddings (default: 1.0). This controls
- the relative importance of instruction opcodes in the final embedding.
+ Specify the weight for opcode embeddings (default: 1.0). This controls
+ the relative importance of instruction opcodes in the final embedding.
.. option:: --ir2vec-type-weight=<weight>
- Specify the weight for type embeddings (default: 0.5). This controls
- the relative importance of type information in the final embedding.
+ Specify the weight for type embeddings (default: 0.5). This controls
+ the relative importance of type information in the final embedding.
.. option:: --ir2vec-arg-weight=<weight>
- Specify the weight for argument embeddings (default: 0.2). This controls
- the relative importance of operand information in the final embedding.
+ Specify the weight for argument embeddings (default: 0.2). This controls
+ the relative importance of operand information in the final embedding.
-.. option:: -o <filename>
- Specify the output filename. Use ``-`` to write to standard output (default).
+**triplets** subcommand:
-.. option:: --help
-
- Print a summary of command line options.
-
-.. note::
+.. option:: <input-file>
- ``--level``, ``--function``, ``--ir2vec-vocab-path``, ``--ir2vec-opc-weight``,
- ``--ir2vec-type-weight``, and ``--ir2vec-arg-weight`` are only used in embedding
- mode. These options are ignored in triplet and entity modes.
+ The input LLVM IR or bitcode file to process. This positional argument is
+ required for the `triplets` subcommand.
-INPUT FILE FORMAT
------------------
+**entities** subcommand:
-:program:`llvm-ir2vec` accepts LLVM bitcode files (``.bc``) and LLVM IR files
-(``.ll``) as input. The input file should contain valid LLVM IR.
+ No subcommand-specific options.
OUTPUT FORMAT
-------------