Skip to content

Commit

Permalink
Final Implementation llvm16
Browse files Browse the repository at this point in the history
  • Loading branch information
nishant-sachdeva committed Dec 20, 2023
1 parent ea10020 commit 7dcd544
Show file tree
Hide file tree
Showing 270 changed files with 20,652 additions and 120,714 deletions.
63 changes: 27 additions & 36 deletions Manylinux2014_Compliant_Source/pkg/IR2Vec/refactoredCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,50 +355,41 @@ ir2vecHandlerObject *createIR2VECObject(const char *filename, const char *output

PyObject *initEmbedding(PyObject *self, PyObject *args) {
Py_Initialize();
PyObject *Embedding_dict = PyDict_New();
// setting default values
PyDict_SetDefault(Embedding_dict, PyUnicode_FromString("fileName"), Py_None);
PyDict_SetDefault(Embedding_dict, PyUnicode_FromString("outputFile"), Py_None);
PyDict_SetDefault(Embedding_dict, PyUnicode_FromString("Message"), PyUnicode_FromString(""));
PyDict_SetDefault(Embedding_dict, PyUnicode_FromString("Status"), Py_False);

const char *filename = "\0";
const char *mode = "\0";
const char *level = "\0";
const char *output_file = "\0";

if (PyArg_ParseTuple(args, "s", &filename, &output_file)) {
if (fileNotValid(filename)) {
PyDict_SetItemString(
Embedding_dict, "Message",
PyUnicode_FromString(
"Eroneous or empty .bc/.ll file location entred"));
PyDict_SetItemString(Embedding_dict, "Status", Py_False);
return Embedding_dict;
}
if (!PyArg_ParseTuple(args, "sss|s", &filename, &mode, &level, &output_file)) {
// raise error here
PyErr_SetString(PyExc_TypeError, "Invalid Arguments");
return NULL;
}

if (string(output_file).empty() == false) {
if (fileNotValid(output_file)) {
PyDict_SetItemString(
Embedding_dict, "Message",
PyUnicode_FromString(
"Eroneous or empty output file location entred"));
PyDict_SetItemString(Embedding_dict, "Status", Py_False);
return Embedding_dict;
}
if (fileNotValid(filename)) {
PyErr_SetString(PyExc_TypeError, "Invalid File Path");
return NULL;
}

if (string(output_file).empty() == false) {
if (fileNotValid(output_file)) {
PyErr_SetString(PyExc_TypeError, "Invalid Output File Path");
return NULL;
}
}

PyDict_SetItemString(Embedding_dict, "fileName", PyUnicode_FromString(filename));
PyDict_SetItemString(Embedding_dict, "outputFile", PyUnicode_FromString(output_file));
PyDict_SetItemString(Embedding_dict, "Message", PyUnicode_FromString("Success"));
PyDict_SetItemString(Embedding_dict, "Status", Py_True);
return Embedding_dict;
} else {
PyDict_SetItemString(Embedding_dict, "Status", Py_False);
PyDict_SetItemString(Embedding_dict, "Message",
PyUnicode_FromString("Invalid Arguments"));
return Embedding_dict;
if (string(mode) != string("sym") && string(mode) != string("fa")) {
PyErr_SetString(PyExc_TypeError,
"Eroneous mode entered . Either of sym, fa should be "
"specified");
return NULL;
}
}

if (level[0] != 'p' && level[0] != 'f') {
PyErr_SetString(PyExc_TypeError,
"Invalid level specified: Use either p or f");
return NULL;
}

ir2vecHandlerObject *ir2vecObj = createIR2VECObject(filename, output_file, mode, level);

Expand Down
2 changes: 1 addition & 1 deletion Manylinux2014_Compliant_Source/pkg/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ cmake -DCMAKE_BUILD_TYPE=Release ../src && make -j"$(nproc)" && make install
cd ..
cp src/include/*.h Manylinux2014_Compliant_Source/pkg/IR2Vec/
cp build/version.h Manylinux2014_Compliant_Source/pkg/IR2Vec/
cp vocabulary/seedEmbeddingVocab-*.txt Manylinux2014_Compliant_Source/pkg/IR2Vec/
cp vocabulary/seedEmbeddingVocab-llvm16.txt Manylinux2014_Compliant_Source/pkg/IR2Vec/

bash Manylinux2014_Compliant_Source/pkg/regen-oracle.sh
10 changes: 4 additions & 6 deletions Manylinux2014_Compliant_Source/pkg/tests/test_ir2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ def test_fa_p():
progVector2 = initObj.getProgramVector()
assert_valid_progVector(progVector2)

for idx, v in enumerate(progVector1):
assert v == pytest.approx(progVector2[idx], abs=ABS_ACCURACY)
assert(progVector1 == pytest.approx(progVector2, abs=ABS_ACCURACY))

p_vectors.append(progVector1)

Expand All @@ -138,13 +137,12 @@ def test_sym_p():
assert(initObj is not None)

progVector1 = IR2Vec.getProgramVector(initObj)
assert(progVector1 is not None)
assert_valid_progVector(progVector1)

progVector2 = initObj.getProgramVector()
assert(progVector2 is not None)
assert_valid_progVector(progVector2)

for idx, v in enumerate(progVector1):
assert v == pytest.approx(progVector2[idx], abs=ABS_ACCURACY)
assert progVector1 == pytest.approx(progVector2, abs=ABS_ACCURACY)

p_vectors.append(progVector1)

Expand Down
14 changes: 6 additions & 8 deletions seed_embeddings/OpenKE/generate_embedding_ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,12 @@ def findRep(src, dest, index_dir):
"epoch": arg_conf.epoch,
"dim": arg_conf.dim,
"index_dir": arg_conf.index_dir,
"nbatches": tune.grid_search([2**x for x in range(7, 11)]),
# [300, 350]),
#
# ),
"margin": tune.grid_search([x for x in np.arange(3, 5, 0.05)]),
# tune.grid_search([3.5])
# [x for x in np.arange(3.0, 5.0, 1)]
# ),
"nbatches": tune.grid_search([
x for x in range(300, 500, 50)
]),
"margin": tune.grid_search([
x for x in np.arange(3, 5, 0.5)
]),
}

try:
Expand Down
Loading

0 comments on commit 7dcd544

Please sign in to comment.