Repository: IITH-Compilers/IR2Vec (language: python)

Issue:
With pre-commit-checks



Discussion / hints:

Fix patch:
diff --git a/Manylinux2014_Compliant_Source/pkg/build.sh b/Manylinux2014_Compliant_Source/pkg/build.sh
index a4ed19c4..1766b418 100644
--- a/Manylinux2014_Compliant_Source/pkg/build.sh
+++ b/Manylinux2014_Compliant_Source/pkg/build.sh
@@ -18,8 +18,7 @@ cd ..
 cmake -DCMAKE_BUILD_TYPE=Release .. && make -j"$(nproc)" && make install
 
 cd ..
+cp build/vocabulary.h Manylinux2014_Compliant_Source/pkg/ir2vec/
 cp src/include/utils.h Manylinux2014_Compliant_Source/pkg/ir2vec/
 cp build/src/version.h Manylinux2014_Compliant_Source/pkg/ir2vec/
-cp vocabulary/seedEmbeddingVocab.txt Manylinux2014_Compliant_Source/pkg/ir2vec/
-
 bash Manylinux2014_Compliant_Source/pkg/regen-oracle.sh
diff --git a/Manylinux2014_Compliant_Source/pkg/ir2vec/__init__.py b/Manylinux2014_Compliant_Source/pkg/ir2vec/__init__.py
index 68187309..1916d201 100755
--- a/Manylinux2014_Compliant_Source/pkg/ir2vec/__init__.py
+++ b/Manylinux2014_Compliant_Source/pkg/ir2vec/__init__.py
@@ -14,5 +14,3 @@
 __version__ = getVersion()
 __copyright__ = "Copyright The Contributors of IR2Vec"
 __license__ = "BSD 4-Clause License"
-
-setSeedEmbdPath(preparation.install_loc_pkg)
diff --git a/Manylinux2014_Compliant_Source/pkg/ir2vec/core.cpp b/Manylinux2014_Compliant_Source/pkg/ir2vec/core.cpp
index b5243fa6..43f57a4e 100644
--- a/Manylinux2014_Compliant_Source/pkg/ir2vec/core.cpp
+++ b/Manylinux2014_Compliant_Source/pkg/ir2vec/core.cpp
@@ -9,7 +9,6 @@
 #include "IR2Vec.h"
 #include "utils.h"
 #include "version.h"
-
 #include <Python.h>
 #include <cstring>
 #include <fstream>
@@ -58,14 +57,6 @@ static PyObject *getIR2VecVersion(PyObject *self, PyObject *args) {
       NULL);
 }
 
-PyObject *setSeedEmbeddingPath(PyObject *self, PyObject *args) {
-  const char *vocab_path2 = "";
-  if (PyArg_ParseTuple(args, "s", &vocab_path2)) {
-    seed_emb_path = string(vocab_path2);
-  }
-  return PyUnicode_FromString("Seed Embedding Path is Set");
-}
-
 bool fileNotValid(const char *filename) {
   ifstream temp;
   temp.open(filename, ios_base::in);
@@ -169,7 +160,6 @@ class IR2VecHandler {
     // The scope of this Module object is extremely crucial
     std::unique_ptr<llvm::Module> Module;
     Module = IR2Vec::getLLVMIR();
-    std::string vocab_path = seed_emb_path + "/seedEmbeddingVocab.txt";
 
     IR2Vec::Embeddings *emb = new IR2Vec::Embeddings();
     // if output file is provided
@@ -177,13 +167,11 @@ class IR2VecHandler {
       string outFile = this->outputFile;
       ofstream output;
       output.open(outFile, ios_base::app);
-      emb = std::move(new IR2Vec::Embeddings(*Module, ir2vecMode, vocab_path,
-                                             (this->level)[0], &output,
-                                             funcName));
+      emb = std::move(new IR2Vec::Embeddings(
+          *Module, ir2vecMode, (this->level)[0], &output, funcName));
     } else {
-      emb = std::move(new IR2Vec::Embeddings(*Module, ir2vecMode, vocab_path,
-                                             (this->level)[0], nullptr,
-                                             funcName));
+      emb = std::move(new IR2Vec::Embeddings(
+          *Module, ir2vecMode, (this->level)[0], nullptr, funcName));
     }
 
     if (!emb) {
@@ -381,8 +369,6 @@ PyMethodDef IR2Vec_core_Methods[] = {
      "Get Program Vector"},
     {"getFunctionVectors", (PyCFunction)getFunctionVectors, METH_VARARGS,
      "Get Function Vectors"},
-    {"setSeedEmbdPath", (PyCFunction)setSeedEmbeddingPath, METH_VARARGS,
-     "Set Seed Embedding Path"},
     {"getVersion", getIR2VecVersion, METH_VARARGS, "Get IR2Vec Version"},
     {NULL, NULL, 0, NULL} /* Sentinel */
 };
diff --git a/Manylinux2014_Compliant_Source/pkg/regen-oracle.sh b/Manylinux2014_Compliant_Source/pkg/regen-oracle.sh
index 3f015f9c..b384d27b 100644
--- a/Manylinux2014_Compliant_Source/pkg/regen-oracle.sh
+++ b/Manylinux2014_Compliant_Source/pkg/regen-oracle.sh
@@ -28,13 +28,12 @@ mkdir -p ${DEST_FOLDER_SYM_P}
 mkdir -p ${DEST_FOLDER_FA_P}
 
 IR2VEC_PATH=../../build/bin/ir2vec
-VOCAB_PATH="../../vocabulary/seedEmbeddingVocab.txt"
 
 while IFS= read -r d; do
 	echo "Generating embeddings for ${d}"
-	${IR2VEC_PATH} -sym -vocab=${VOCAB_PATH} -o ${DEST_FOLDER_SYM}/ir2vec.txt -level f ${d} &>/dev/null
-	${IR2VEC_PATH} -fa -vocab=${VOCAB_PATH} -o ${DEST_FOLDER_FA}/ir2vec.txt -level f ${d} &>/dev/null
-	${IR2VEC_PATH} -sym -vocab=${VOCAB_PATH} -o ${DEST_FOLDER_SYM_P}/ir2vec.txt -level p ${d} >/dev/null
-	${IR2VEC_PATH} -fa -vocab=${VOCAB_PATH} -o ${DEST_FOLDER_FA_P}/ir2vec.txt -level p ${d} >/dev/null
+	${IR2VEC_PATH} -sym -o ${DEST_FOLDER_SYM}/ir2vec.txt -level f ${d} &>/dev/null
+	${IR2VEC_PATH} -fa -o ${DEST_FOLDER_FA}/ir2vec.txt -level f ${d} &>/dev/null
+	${IR2VEC_PATH} -sym -o ${DEST_FOLDER_SYM_P}/ir2vec.txt -level p ${d} >/dev/null
+	${IR2VEC_PATH} -fa -o ${DEST_FOLDER_FA_P}/ir2vec.txt -level p ${d} >/dev/null
 done <index-${SEED_VERSION}.files
 wait
diff --git a/Manylinux2014_Compliant_Source/pkg/setup.py b/Manylinux2014_Compliant_Source/pkg/setup.py
index c8f8b7d0..7c348292 100755
--- a/Manylinux2014_Compliant_Source/pkg/setup.py
+++ b/Manylinux2014_Compliant_Source/pkg/setup.py
@@ -81,6 +81,5 @@ def get_llvm_files():
     ],
     ext_modules=[IR2Vec_core],
     packages=["ir2vec"],
-    package_data={"": ["seedEmbeddingVocab.txt"]},
     include_package_data=True,
 )
diff --git a/README.md b/README.md
index d33b6f17..307a3a2b 100644
--- a/README.md
+++ b/README.md
@@ -110,14 +110,13 @@ To ensure the correctness, run `make verify-all`
 instructions.
 
 ### Using Binary
-> ir2vec -\<mode\> -vocab \<seedEmbedding-file-path\> -o \<output-file\> -level \<p|f\> -class \<class-number\> -funcName=\<function-name\> \<input-ll-file\>
+> ir2vec -\<mode\> -o \<output-file\> -level \<p|f\> -class \<class-number\> -funcName=\<function-name\> \<input-ll-file\>
 
 #### Command-Line options
 
 - `mode` - can be one of `sym`/`fa`
     - `sym` denotes Symbolic representation
     - `fa` denotes Flow-Aware representation
-- `vocab`  - the path to the seed embeddings file
 -  `o` - file in which the embeddings are to be appended;     (Note : If  file doesn’t exist, new file would be created, else embeddings would be appended)
 - `level` - can be one of chars `p`/`f`.
     - `p` denotes `program level` encoding
@@ -139,16 +138,16 @@ Please use `--help` for further details.
 
 #### Flow-Aware Embeddings
 For all functions
-* `` ir2vec -fa -vocab vocabulary/seedEmbeddingVocab.txt -o <output_file> -level <p|f>  -class <class-number> <input_ll_file>``
+* `` ir2vec -fa -o <output_file> -level <p|f>  -class <class-number> <input_ll_file>``
 
 For a specific function
-* `` ir2vec -fa -vocab vocabulary/seedEmbeddingVocab.txt -o <output_file> -level f  -class <class-number> -funcName=\<function-name\><input_ll_file>``
+* `` ir2vec -fa -o <output_file> -level f  -class <class-number> -funcName=\<function-name\><input_ll_file>``
 
 #### Symbolic Embeddings
 For all functions
- * `` ir2vec -sym -vocab vocabulary/seedEmbeddingVocab.txt -o <output_file> -level <p|f> -class <class-number> <input_ll_file>``
+ * `` ir2vec -sym -o <output_file> -level <p|f> -class <class-number> <input_ll_file>``
 For a specific function
- * `` ir2vec -sym -vocab vocabulary/seedEmbeddingVocab.txt -o <output_file> -level f -class <class-number> -funcName=\<function-name\> <input_ll_file>``
+ * `` ir2vec -sym -o <output_file> -level f -class <class-number> -funcName=\<function-name\> <input_ll_file>``
 
 ## Using Libraries
 The libraries can be installed by passing the installation location to the `CMAKE_INSTALL_PREFIX` flag during `cmake` followed by `make install`.
@@ -176,8 +175,7 @@ The following example snippet shows how to query the exposed vector representati
 
 // Creating object to generate FlowAware representation
 auto ir2vec =
-      IR2Vec::Embeddings(<LLVM Module>, IR2Vec::IR2VecMode::FlowAware,
-                         "./vocabulary/seedEmbeddingVocab.txt");
+      IR2Vec::Embeddings(<LLVM Module>, IR2Vec::IR2VecMode::FlowAware);
 
 // Getting Instruction vectors corresponding to the instructions in <LLVM Module>
 auto instVecMap = ir2vec.getInstVecMap();
diff --git a/experiments/generate_IR2Vec_embeddings.sh b/experiments/generate_IR2Vec_embeddings.sh
index 4e72955c..20e91f2e 100644
--- a/experiments/generate_IR2Vec_embeddings.sh
+++ b/experiments/generate_IR2Vec_embeddings.sh
@@ -19,8 +19,6 @@ fi
 
 BUILD=$(realpath ${BUILD})
 
-Absolute_path_of_RepresentationFile=$(realpath ../vocabulary/seedEmbeddingVocab.txt)
-
 TASK_DIR=$1
 if [ -z "${TASK_DIR}" ]; then
 	echo "Task is not mentioned. Please enter value of DM for Device Mapping or TC for Thread_Coarsening."
@@ -88,7 +86,7 @@ ulimit -s unlimited
 for d in ./*.ll; do
 	let "a++"
 	echo "$a      $d" >>${ALL_FILE}
-	${BUILD}/bin/ir2vec -${PASS} -vocab $Absolute_path_of_RepresentationFile -class $a -o res_$Trans_type.txt -level p $WEIGHTS $d &>/dev/null
+	${BUILD}/bin/ir2vec -${PASS} -class $a -o res_$Trans_type.txt -level p $WEIGHTS $d &>/dev/null
 done
 cd ../..
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e951f8fb..16e3cb9f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,15 +1,16 @@
 
 configure_file (./include/version.h.cmake version.h @ONLY)
 include_directories(./include ${CMAKE_CURRENT_BINARY_DIR})
-
+include_directories(${CMAKE_BINARY_DIR})
 set(commonsrc FlowAware.cpp Symbolic.cpp utils.cpp)
 set(libsrc libIR2Vec.cpp ${commonsrc})
 set(binsrc CollectIR.cpp IR2Vec.cpp)
-
-file(GLOB RESOURCE_FILES ../vocabulary/seedEmbeddingVocab.txt)
-
 option(LLVM_IR2VEC "where to enable IR2Vec as subproject for LLVM" OFF)
-
+execute_process(
+    COMMAND python3 generate_vocabulary.py -o ${CMAKE_BINARY_DIR}/vocabulary.h
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+    COMMAND echo "Vocabulary file generated."
+)
 if(NOT LLVM_IR2VEC)
 
   set(LT_LLVM_INSTALL_DIR "" CACHE PATH "LLVM installation directory")
@@ -37,7 +38,6 @@ if(NOT LLVM_IR2VEC)
       VERSION ${PROJECT_VERSION}
       SOVERSION 1
       PUBLIC_HEADER "./include/IR2Vec.h"
-      RESOURCE ${RESOURCE_FILES}
       OUTPUT_NAME ${IR2VEC_LIB}
       LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
       ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
diff --git a/src/IR2Vec.cpp b/src/IR2Vec.cpp
index 79252d53..919f4d1b 100644
--- a/src/IR2Vec.cpp
+++ b/src/IR2Vec.cpp
@@ -32,11 +32,6 @@ cl::opt<bool> cl_collectIR(
     "collectIR", cl::Optional,
     cl::desc("Generate triplets for training seed embedding vocabulary"),
     cl::init(false), cl::cat(category));
-
-cl::opt<std::string> cl_vocab("vocab", cl::Optional, cl::init(""),
-                              cl::desc("Use embeddings from file path"),
-                              cl::cat(category));
-
 cl::opt<std::string> cl_iname(cl::Positional, cl::desc("Input file path"),
                               cl::Required, cl::cat(category));
 
@@ -81,7 +76,6 @@ int main(int argc, char **argv) {
   fa = cl_fa;
   sym = cl_sym;
   collectIR = cl_collectIR;
-  vocab = cl_vocab;
   iname = cl_iname;
   oname = cl_oname;
   // newly added
@@ -105,18 +99,12 @@ int main(int argc, char **argv) {
       errs() << "Invalid level specified: Use either p or f\n";
       failed = true;
     }
-    if (vocab.empty()) {
-      errs() << "Should specify vocab pointing to the path of vocabulary\n";
-      failed = true;
-    }
   } else {
     if (!collectIR) {
       errs() << "Either of sym, fa or collectIR should be specified\n";
       failed = true;
     } else if (level)
       errs() << "[WARNING] level would not be used in collectIR mode\n";
-    else if (!vocab.empty())
-      errs() << "[WARNING] vocab would not be used in collectIR mode\n";
   }
 
   if (failed)
diff --git a/src/generate_vocabulary.py b/src/generate_vocabulary.py
new file mode 100644
index 00000000..720e3795
--- /dev/null
+++ b/src/generate_vocabulary.py
@@ -0,0 +1,76 @@
+# Copyright (c) 2024, The Contributors of IR2Vec.
+#
+# Part of the IR2Vec project. This software is available under the BSD 4-Clause
+# License. Please see LICENSE file in the top-level directory for more details.
+#
+import argparse
+
+parser = argparse.ArgumentParser()
+parser.add_argument("-o", "--output", type=str, help="Output file name")
+args = parser.parse_args()
+
+if args.output is None:
+    print("Error: Output file path not provided.")
+    exit(1)
+
+output_file = args.output
+vocab_file = "../vocabulary/seedEmbeddingVocab.txt"
+
+# Define headers and opening/closing of map
+header = """\
+// Generated by IR2Vec. DO NOT EDIT!
+// This file contains the learned vocabulary used by IR2Vec.
+//
+// clang-format off
+
+#ifndef __VOCABULARY__
+#define __VOCABULARY__
+
+#include <map>
+#include <string>
+#include <vector>
+#include "IR2Vec.h"
+
+namespace IR2Vec {
+
+class Vocabulary {
+public:
+    static const std::map<std::string, IR2Vec::Vector>& getVocabulary() {
+        return vocabulary;
+    }
+private:
+    static const std::map<std::string, IR2Vec::Vector> vocabulary;
+};
+
+"""
+
+opening = "\nconst std::map<std::string, IR2Vec::Vector> Vocabulary::vocabulary = {\n"
+closing = """\
+};
+} // namespace IR2Vec
+
+#endif // __VOCABULARY__
+"""
+
+try:
+    with open(output_file, "w") as fw:
+        fw.write(header)
+        with open(vocab_file, "r") as fr:
+            # Write vector declarations to the output file
+            for line in fr.readlines():
+                key, val = line.strip().split(":")
+                e = val.find("]")
+                fw.write(f"const IR2Vec::Vector {key}_vector = {{  {val[1:e]} }};\n")
+
+        fw.write(opening)
+        with open(vocab_file, "r") as fr:
+            # Write map entries to the output file
+            for line in fr.readlines():
+                key, _ = line.strip().split(":")
+                fw.write(f'    {{ "{key}", {key}_vector }},\n')
+        fw.write(closing)
+
+    print(f"Generated {output_file}")
+
+except FileNotFoundError:
+    print(f"Error: Vocabulary file '{vocab_file}' not found.")
diff --git a/src/include/FlowAware.h b/src/include/FlowAware.h
index e2d12e6b..9a1dd893 100644
--- a/src/include/FlowAware.h
+++ b/src/include/FlowAware.h
@@ -132,7 +132,6 @@ class IR2Vec_FA {
 
     pgmVector = IR2Vec::Vector(DIM, 0);
     res = "";
-    IR2Vec::collectDataFromVocab(opcMap);
 
     memWriteOps.try_emplace("store", 1);
     memWriteOps.try_emplace("cmpxchg", 0);
@@ -176,8 +175,6 @@ class IR2Vec_FA {
       std::ostream *o = nullptr, std::string name = "",
       std::ostream *missCount = nullptr, std::ostream *cyclicCount = nullptr);
 
-  std::map<std::string, IR2Vec::Vector> opcMap;
-
   llvm::SmallMapVector<const llvm::Instruction *, IR2Vec::Vector, 128>
   getInstVecMap() {
     return instVecMap;
diff --git a/src/include/IR2Vec.h b/src/include/IR2Vec.h
index 1cdb4b83..1e801180 100644
--- a/src/include/IR2Vec.h
+++ b/src/include/IR2Vec.h
@@ -19,10 +19,10 @@ using Vector = llvm::SmallVector<double, DIM>;
 enum IR2VecMode { FlowAware, Symbolic };
 
 class Embeddings {
-  int generateEncodings(llvm::Module &M, IR2VecMode mode, std::string vocab,
-                        char level = '\0', std::string funcName = "",
-                        std::ostream *o = nullptr, int cls = -1, float WO = 1,
-                        float WA = 0.2, float WT = 0.5);
+  int generateEncodings(llvm::Module &M, IR2VecMode mode, char level = '\0',
+                        std::string funcName = "", std::ostream *o = nullptr,
+                        int cls = -1, float WO = 1, float WA = 0.2,
+                        float WT = 0.5);
 
   llvm::SmallMapVector<const llvm::Instruction *, Vector, 128> instVecMap;
   llvm::SmallMapVector<const llvm::Function *, Vector, 16> funcVecMap;
@@ -30,19 +30,18 @@ class Embeddings {
 
 public:
   Embeddings() = default;
-  Embeddings(llvm::Module &M, IR2VecMode mode, std::string vocab,
-             std::string funcName = "", float WO = 1, float WA = 0.2,
-             float WT = 0.5) {
-    generateEncodings(M, mode, vocab, '\0', funcName, nullptr, -1, WO, WA, WT);
+  Embeddings(llvm::Module &M, IR2VecMode mode, std::string funcName = "",
+             float WO = 1, float WA = 0.2, float WT = 0.5) {
+    generateEncodings(M, mode, '\0', funcName, nullptr, -1, WO, WA, WT);
   }
 
   // Use this constructor if the representations ought to be written to a
   // file. Analogous to the command line options that are being used in IR2Vec
   // binary.
-  Embeddings(llvm::Module &M, IR2VecMode mode, std::string vocab, char level,
-             std::ostream *o, std::string funcName = "", float WO = 1,
-             float WA = 0.2, float WT = 0.5) {
-    generateEncodings(M, mode, vocab, level, funcName, o, -1, WO, WA, WT);
+  Embeddings(llvm::Module &M, IR2VecMode mode, char level, std::ostream *o,
+             std::string funcName = "", float WO = 1, float WA = 0.2,
+             float WT = 0.5) {
+    generateEncodings(M, mode, level, funcName, o, -1, WO, WA, WT);
   }
 
   // Returns a map containing instructions and the corresponding vector
diff --git a/src/include/Symbolic.h b/src/include/Symbolic.h
index 554a531d..c83ec2ed 100644
--- a/src/include/Symbolic.h
+++ b/src/include/Symbolic.h
@@ -33,13 +33,11 @@ class IR2Vec_Symbolic {
   llvm::SmallMapVector<const llvm::Function *, IR2Vec::Vector, 16> funcVecMap;
   llvm::SmallMapVector<const llvm::Instruction *, IR2Vec::Vector, 128>
       instVecMap;
-  std::map<std::string, IR2Vec::Vector> opcMap;
 
 public:
   IR2Vec_Symbolic(llvm::Module &M) : M{M} {
     pgmVector = IR2Vec::Vector(DIM, 0);
     res = "";
-    IR2Vec::collectDataFromVocab(opcMap);
   }
 
   void generateSymbolicEncodings(std::ostream *o = nullptr);
diff --git a/src/include/utils.h b/src/include/utils.h
index 5e6b744b..5643bb74 100644
--- a/src/include/utils.h
+++ b/src/include/utils.h
@@ -13,6 +13,7 @@
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/raw_ostream.h"
+
 #include <cxxabi.h>
 
 #include <map>
@@ -34,7 +35,6 @@ extern bool fa;
 extern bool sym;
 extern bool printTime;
 extern bool collectIR;
-extern std::string vocab;
 extern std::string iname;
 extern std::string oname;
 extern std::string funcName;
@@ -44,9 +44,8 @@ extern float WO;
 extern float WA;
 extern float WT;
 extern bool debug;
-
+extern std::map<std::string, Vector> opcMap;
 std::unique_ptr<llvm::Module> getLLVMIR();
-void collectDataFromVocab(std::map<std::string, Vector> &opcMap);
 void scaleVector(Vector &vec, float factor);
 // newly added
 std::string getDemagledName(const llvm::Function *function);
diff --git a/src/libIR2Vec.cpp b/src/libIR2Vec.cpp
index 5c6d09b2..b5864df0 100644
--- a/src/libIR2Vec.cpp
+++ b/src/libIR2Vec.cpp
@@ -14,12 +14,11 @@
 #include "llvm/Support/CommandLine.h"
 
 int IR2Vec::Embeddings::generateEncodings(llvm::Module &M,
-                                          IR2Vec::IR2VecMode mode,
-                                          std::string vocab, char level,
+                                          IR2Vec::IR2VecMode mode, char level,
                                           std::string funcName, std::ostream *o,
                                           int cls, float WO, float WA,
                                           float WT) {
-  IR2Vec::vocab = vocab;
+
   IR2Vec::level = level;
   IR2Vec::cls = cls;
   IR2Vec::WO = WO;
diff --git a/src/utils.cpp b/src/utils.cpp
index d959ff88..1a929d2f 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -6,9 +6,9 @@
 //
 #include "utils.h"
 #include "IR2Vec.h"
+#include "vocabulary.h"
 #include <fstream>
 #include <string>
-
 using namespace llvm;
 using namespace IR2Vec;
 
@@ -16,7 +16,6 @@ bool IR2Vec::fa;
 bool IR2Vec::sym;
 bool IR2Vec::printTime;
 bool IR2Vec::collectIR;
-std::string IR2Vec::vocab;
 std::string IR2Vec::iname;
 std::string IR2Vec::oname;
 std::string IR2Vec::funcName;
@@ -26,7 +25,8 @@ float IR2Vec::WO;
 float IR2Vec::WA;
 float IR2Vec::WT;
 bool IR2Vec::debug;
-
+std::map<std::string, Vector> IR2Vec::opcMap =
+    IR2Vec::Vocabulary::getVocabulary();
 std::unique_ptr<Module> IR2Vec::getLLVMIR() {
   SMDiagnostic err;
   static LLVMContext context;
@@ -39,30 +39,6 @@ std::unique_ptr<Module> IR2Vec::getLLVMIR() {
   return M;
 }
 
-void IR2Vec::collectDataFromVocab(std::map<std::string, Vector> &opcMap) {
-  IR2VEC_DEBUG(errs() << "Reading from " + vocab + "\n");
-  std::ifstream i(vocab);
-  std::string delimiter = ":";
-  for (std::string line; getline(i, line);) {
-    std::string token = line.substr(0, line.find(delimiter));
-    Vector rep;
-    std::string vec = line.substr(line.find(delimiter) + 1, line.length());
-    std::string val = vec.substr(vec.find("[") + 1, vec.find(", ") - 1);
-    rep.push_back(stod(val));
-    int pos = vec.find(", ");
-    vec = vec.substr(pos + 1);
-    for (int i = 1; i < DIM - 1; i++) {
-      val = vec.substr(1, vec.find(", ") - 1);
-      rep.push_back(stod(val));
-      pos = vec.find(", ");
-      vec = vec.substr(pos + 1);
-    }
-    val = vec.substr(1, vec.find("]") - 1);
-    rep.push_back(stod(val));
-    opcMap[token] = rep;
-  }
-}
-
 void IR2Vec::scaleVector(Vector &vec, float factor) {
   for (unsigned i = 0; i < vec.size(); i++) {
     vec[i] = vec[i] * factor;


Test patch:
diff --git a/src/test-suite/generateOracle.sh b/src/test-suite/generateOracle.sh
index c50c339c..3a8ee559 100644
--- a/src/test-suite/generateOracle.sh
+++ b/src/test-suite/generateOracle.sh
@@ -28,15 +28,6 @@ LLVM_BUILD="/usr"
 #Update IR2Vec Path to use
 IR2VEC_PATH="../../build/bin/ir2vec"
 
-#Update Vocabulary Path to use
-VOCAB_PATH="../../vocabulary/seedEmbeddingVocab.txt"
-
-# does the VOCAB_PATH exist?
-if [ ! -f ${VOCAB_PATH} ]; then
-	echo "Vocabulary file does not exist.."
-	exit
-fi
-
 if [ -z ${LLVM_BUILD} ]; then
 	echo "Enter the llvm build path.."
 	exit
@@ -45,10 +36,6 @@ if [ -z ${IR2VEC_PATH} ]; then
 	echo "Enter the ir2vec path.."
 	exit
 fi
-if [ -z ${VOCAB_PATH} ]; then
-	echo "Enter the vocabulary path.."
-	exit
-fi
 
 functions=("main" "buildMatchingMachine" "search" "BellamFord" "BFS" "isBCUtil" "insertionSort" "binomialCoeff" "find" "countParenth" "boruvkaMST" "maxStackHeight" "badCharHeuristic" "bpm"
 	"count" "getMaxUtil" "buildSuffixArray" "countOnes" "countStrings" "countRec" "countWays" "AP" "cutRod" "isCyclic" "isDivisible" "DFS" "editDist" "eggDrop" "isSC" "isConnected" "printClosest"
@@ -61,15 +48,15 @@ functions=("main" "buildMatchingMachine" "search" "BellamFord" "BFS" "isBCUtil"
 cat index-${SEED_VERSION}.files | wc -l
 echo "generating P level files"
 while IFS= read -r d; do
-	${IR2VEC_PATH} -sym -vocab=${VOCAB_PATH} -level p -o ${DEST_FOLDER_SYM_P}/ir2vec.txt ${d} &>/dev/null
-	${IR2VEC_PATH} -fa -vocab=${VOCAB_PATH} -level p -o ${DEST_FOLDER_FA_P}/ir2vec.txt ${d} &>/dev/null
+	${IR2VEC_PATH} -sym -level p -o ${DEST_FOLDER_SYM_P}/ir2vec.txt ${d} &>/dev/null
+	${IR2VEC_PATH} -fa -level p -o ${DEST_FOLDER_FA_P}/ir2vec.txt ${d} &>/dev/null
 done <index-${SEED_VERSION}.files
 wait
 
 echo "generating F level files"
 while IFS= read -r d; do
-	${IR2VEC_PATH} -sym -vocab=${VOCAB_PATH} -level f -o ${DEST_FOLDER_SYM}/ir2vec.txt ${d} &>/dev/null
-	${IR2VEC_PATH} -fa -vocab=${VOCAB_PATH} -level f -o ${DEST_FOLDER_FA}/ir2vec.txt ${d} &>/dev/null
+	${IR2VEC_PATH} -sym -level f -o ${DEST_FOLDER_SYM}/ir2vec.txt ${d} &>/dev/null
+	${IR2VEC_PATH} -fa -level f -o ${DEST_FOLDER_FA}/ir2vec.txt ${d} &>/dev/null
 done <index-${SEED_VERSION}.files
 wait
 
@@ -77,8 +64,8 @@ echo "generating onDemand level files"
 while IFS= read -r d; do
 	echo $d
 	for func in "${functions[@]}"; do
-		${IR2VEC_PATH} -sym -vocab=${VOCAB_PATH} -level f -funcName=$func -o ${DEST_FOLDER_SYM_ONDEMAND}/ir2vec.txt ${d} &>/dev/null
-		${IR2VEC_PATH} -fa -vocab=${VOCAB_PATH} -level f -funcName=$func -o ${DEST_FOLDER_FA_ONDEMAND}/ir2vec.txt ${d} &>/dev/null
+		${IR2VEC_PATH} -sym -level f -funcName=$func -o ${DEST_FOLDER_SYM_ONDEMAND}/ir2vec.txt ${d} &>/dev/null
+		${IR2VEC_PATH} -fa -level f -funcName=$func -o ${DEST_FOLDER_FA_ONDEMAND}/ir2vec.txt ${d} &>/dev/null
 	done
 done <index-${SEED_VERSION}.files
 wait
diff --git a/src/test-suite/sanity_check.sh.cmake b/src/test-suite/sanity_check.sh.cmake
index 235fb620..3dd11112 100644
--- a/src/test-suite/sanity_check.sh.cmake
+++ b/src/test-suite/sanity_check.sh.cmake
@@ -24,7 +24,6 @@ else
 fi
 
 SEED_VERSION=$2
-VOCAB_PATH="./vocabulary/seedEmbeddingVocab.txt"
 IR2VEC_PATH="../../bin/ir2vec"
 
 functions=("main" "buildMatchingMachine" "search" "BellamFord" "BFS" "isBCUtil" "insertionSort" "binomialCoeff" "find" "countParenth" "boruvkaMST" "maxStackHeight" "badCharHeuristic" "bpm"
@@ -47,7 +46,7 @@ perform_vector_comparison() {
 
     if [[ "$FILE_PREFIX" == "p" || "$FILE_PREFIX" == "f" ]]; then
         while IFS= read -r d; do
-            ${IR2VEC_PATH} -${PASS} -vocab=${VOCAB_PATH} -level ${LEVEL} -o ${VIR_FILE} ${d} &> /dev/null
+            ${IR2VEC_PATH} -${PASS} -level ${LEVEL} -o ${VIR_FILE} ${d} &> /dev/null
         done < index-${SEED_VERSION}.files
         wait
     else
@@ -55,7 +54,7 @@ perform_vector_comparison() {
         do
             for func in "${functions[@]}"
             do
-                ${IR2VEC_PATH} -${PASS} -vocab=${VOCAB_PATH} -level ${LEVEL} -funcName=$func -o ${VIR_FILE} ${d_on} &> /dev/null
+                ${IR2VEC_PATH} -${PASS} -level ${LEVEL} -funcName=$func -o ${VIR_FILE} ${d_on} &> /dev/null
             done
         done < index-${SEED_VERSION}.files
         wait