Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: IITH-Compilers/IR2Vec
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.0
Choose a base ref
...
head repository: IITH-Compilers/IR2Vec
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: llvm10
Choose a head ref

Commits on Mar 3, 2021

  1. Copy the full SHA
    2c5754d View commit details
  2. Updating version

    svkeerthy committed Mar 3, 2021
    Copy the full SHA
    0c90d38 View commit details
  3. Merge pull request #21 from IITH-Compilers/vk-patch

    Changes to export vocabulary to install directory
    svkeerthy authored Mar 3, 2021
    Copy the full SHA
    3abce9f View commit details
  4. Merge pull request #22 from IITH-Compilers/main

    Patch to v1.0.0
    svkeerthy authored Mar 3, 2021
    Copy the full SHA
    2491cfd View commit details

Commits on Mar 6, 2021

  1. Copy the full SHA
    2b0601d View commit details
  2. Copy the full SHA
    b10fa04 View commit details

Commits on Apr 16, 2021

  1. Copy the full SHA
    cccb991 View commit details
  2. Update test.yml

    rohitaggarwal007 authored Apr 16, 2021
    Copy the full SHA
    84ba7f1 View commit details
  3. Update test.yml

    rohitaggarwal007 authored Apr 16, 2021
    Copy the full SHA
    ff22672 View commit details
  4. Merge pull request #27 from IITH-Compilers/HotFix-1

    Added Fix for possible infinite recursion issue (Issue #26)
    rohitaggarwal007 authored Apr 16, 2021
    Copy the full SHA
    fc20bad View commit details
  5. Update publish.yml

    rohitaggarwal007 authored Apr 16, 2021
    Copy the full SHA
    ae89a8b View commit details

Commits on Apr 17, 2021

  1. Copy the full SHA
    2d65b52 View commit details

Commits on Apr 19, 2021

  1. Update README.md

    svkeerthy authored Apr 19, 2021
    Copy the full SHA
    bebc0a3 View commit details
  2. Copy the full SHA
    f6ea1ff View commit details

Commits on Apr 20, 2021

  1. Copy the full SHA
    84462ee View commit details
  2. Copy the full SHA
    1348148 View commit details

Commits on May 22, 2021

  1. Copy the full SHA
    d11bbfd View commit details
  2. Copy the full SHA
    4848eb8 View commit details

Commits on May 23, 2021

  1. Copy the full SHA
    e26fab8 View commit details
  2. Merge pull request #24 from anilavakundu/openKE-patch

    Upgrading OpenKE TensorFlow dependency
    svkeerthy authored May 23, 2021
    Copy the full SHA
    712a116 View commit details
  3. Copy the full SHA
    f709ccb View commit details
  4. Merge pull request #32 from IITH-Compilers/svkeerthy-patch-2

    Updating Version in CMakeList for next release
    svkeerthy authored May 23, 2021
    Copy the full SHA
    aafd390 View commit details
  5. Copy the full SHA
    24bda42 View commit details
  6. Copy the full SHA
    83ba2fa View commit details
  7. Copy the full SHA
    cf9bed8 View commit details
  8. Copy the full SHA
    4b5e5ba View commit details
  9. Merge pull request #34 from IITH-Compilers/embeddings-fix-final

    Embeddings fix: 1. Accounting for args once 2. Adding check to differentiate constants that are not pointer type (symbolic and flow-aware).
    svkeerthy authored May 23, 2021
    Copy the full SHA
    5e59caa View commit details

Commits on May 27, 2021

  1. Bumping up versions for pyyaml (5.3 ==> 5.4) urllib3 (1.26.3 ==> 1.26…

    ….5) cryptography (3.2.1 ==> 3.3.2)
    anilavakundu committed May 27, 2021
    Copy the full SHA
    f118810 View commit details
  2. Merge pull request #35 from IITH-Compilers/openKE-patch-2

    Bumping up versions for openKE requirements
    svkeerthy authored May 27, 2021
    Copy the full SHA
    44c7c9d View commit details

Commits on Jun 5, 2021

  1. Adding kill and update

    anilavakundu committed Jun 5, 2021
    Copy the full SHA
    d9b0f19 View commit details
  2. Copy the full SHA
    62e4db8 View commit details

Commits on Jun 9, 2021

  1. Copy the full SHA
    5508e71 View commit details

Commits on Jun 10, 2021

  1. Copy the full SHA
    ba11b81 View commit details

Commits on Jun 12, 2021

  1. Fixed unreachable basic block error; Added Callgraph for adding funct…

    …ion vectors for call instructions
    anilavakundu committed Jun 12, 2021
    Copy the full SHA
    b332521 View commit details

Commits on Jun 14, 2021

  1. Copy the full SHA
    7ced4ed View commit details
  2. Solving merge commit

    anilavakundu committed Jun 14, 2021
    Copy the full SHA
    f1705c4 View commit details
  3. Changing cmakelist

    anilavakundu committed Jun 14, 2021
    Copy the full SHA
    b57d0d8 View commit details

Commits on Jun 18, 2021

  1. Peformance fixes

    anilavakundu committed Jun 18, 2021
    Copy the full SHA
    cfd71b7 View commit details

Commits on Jun 23, 2021

  1. Final performance fixes

    anilavakundu committed Jun 23, 2021
    Copy the full SHA
    e2bd3aa View commit details

Commits on Jun 25, 2021

  1. Updating oracle

    anilavakundu committed Jun 25, 2021
    Copy the full SHA
    05f1874 View commit details
  2. fixing format error

    anilavakundu committed Jun 25, 2021
    Copy the full SHA
    69b5986 View commit details

Commits on Jul 4, 2021

  1. Merge pull request #37 from IITH-Compilers/Dev-optimization

    Optimization-patch-1
    svkeerthy authored Jul 4, 2021
    Copy the full SHA
    0051f1c View commit details

Commits on Jul 12, 2021

  1. Copy the full SHA
    f6d2add View commit details
  2. Fixing format

    anilavakundu committed Jul 12, 2021
    Copy the full SHA
    af32154 View commit details
  3. Merge pull request #38 from IITH-Compilers/Final_Updates

    Adding optimization flags to CMakeList and updating readme
    svkeerthy authored Jul 12, 2021
    Copy the full SHA
    9bbbc7c View commit details
  4. Merge pull request #39 from IITH-Compilers/main

    Merging main to llvm10 for release
    anilavakundu authored Jul 12, 2021
    Copy the full SHA
    3ac7442 View commit details
  5. Copy the full SHA
    9e24d23 View commit details

Commits on Jul 13, 2021

  1. Merge pull request #41 from IITH-Compilers/svkeerthy-patch-2

    Updating README with LLVM Version
    anilavakundu authored Jul 13, 2021
    Copy the full SHA
    fe5374c View commit details
  2. Merge pull request #42 from IITH-Compilers/main

    Merging changes from main
    anilavakundu authored Jul 13, 2021
    Copy the full SHA
    1abf324 View commit details
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -15,7 +15,9 @@ jobs:

steps:
- name: Install LLVM-10.0.1
run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - && sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main" && sudo apt-get update && sudo apt-get install -y llvm-10 llvm-10-dev clang-10
run: |
wget https://apt.llvm.org/llvm.sh
sudo bash llvm.sh 10
- uses: actions/checkout@v2
- name: Eigen-setup
run: |
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -18,7 +18,9 @@ jobs:

steps:
- name: Install LLVM-10.0.1
run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - && sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main" && sudo apt-get update && sudo apt-get install -y llvm-10 llvm-10-dev clang-10
run: |
wget https://apt.llvm.org/llvm.sh
sudo bash llvm.sh 10
- uses: actions/checkout@v2
- name: Eigen-setup
run: |
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ Please see [here](https://compilers.cse.iith.ac.in/projects/ir2vec/) for more de

> IR2Vec: LLVM IR Based Scalable Program Embeddings, S. VenkataKeerthy, Rohit Aggarwal, Shalini Jain, Maunendra Sankar Desarkar, Ramakrishna Upadrasta, and Y. N. Srikant
![LLVM](https://img.shields.io/badge/LLVM-v10.0.1-blue)
![Tests](https://github.com/svkeerthy/IR2Vec/workflows/Tests/badge.svg)
![Publish](https://github.com/svkeerthy/IR2Vec/workflows/Publish/badge.svg)
![pre-commit checks](https://github.com/svkeerthy/IR2Vec/workflows/pre-commit%20checks/badge.svg)
@@ -55,8 +56,6 @@ Binaries and Libraries (.a and .so) are autogenerated for every relevant checkin

This process would generate `ir2vec` binary under `build/bin` directory, `libIR2Vec.a` and `libIR2Vec.so` under `build/lib` directory.

Generating embeddings for some programs may need more stack space, so set `ulimit -s unlimited` in each session or, you can add this command in `.bashrc`.

To ensure the correctness, run `make verify-all`

## Generating program representations
@@ -187,9 +186,5 @@ keywords = {heterogeneous systems, representation learning, compiler optimizatio
## Contributions
Please feel free to raise issues to file a bug, to pose a question, or to initiate any related discussions. Pull requests are welcome :)
##### Contributors
1. [S. VenkataKeerthy](https://github.com/svkeerthy)
2. [Rohit Aggarwal](https://github.com/rohitaggarwal007)
## License
IR2Vec is released under a BSD 4-Clause License. See the LICENSE file for more details.
56 changes: 40 additions & 16 deletions seed_embeddings/OpenKE/base/Base.cpp
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
#include "Reader.h"
#include "Setting.h"
#include "Test.h"
#include "Valid.h"
#include <cstdlib>
#include <pthread.h>

@@ -14,6 +15,10 @@ extern "C" void setWorkThreads(INT threads);

extern "C" void setBern(INT con);

extern "C" void setHeadTailCrossSampling(INT con);

extern "C" bool judgeHeadBatch();

extern "C" INT getWorkThreads();

extern "C" INT getEntityTotal();
@@ -41,6 +46,7 @@ struct Parameter {
INT batchSize;
INT negRate;
INT negRelRate;
INT headBatchFlag;
};

void *getBatch(void *con) {
@@ -53,6 +59,7 @@ void *getBatch(void *con) {
INT batchSize = para->batchSize;
INT negRate = para->negRate;
INT negRelRate = para->negRelRate;
INT headBatchFlag = para->headBatchFlag;
INT lef, rig;
if (batchSize % workThreads == 0) {
lef = id * (batchSize / workThreads);
@@ -72,23 +79,39 @@ void *getBatch(void *con) {
batch_y[batch] = 1;
INT last = batchSize;
for (INT times = 0; times < negRate; times++) {
if (bernFlag)
prob = 1000 * right_mean[trainList[i].r] /
(right_mean[trainList[i].r] + left_mean[trainList[i].r]);
if (randd(id) % 1000 < prob) {
batch_h[batch + last] = trainList[i].h;
batch_t[batch + last] =
corrupt_head(id, trainList[i].h, trainList[i].r);
batch_r[batch + last] = trainList[i].r;
if (!crossSamplingFlag) {
if (bernFlag)
prob = 1000 * right_mean[trainList[i].r] /
(right_mean[trainList[i].r] + left_mean[trainList[i].r]);
if (randd(id) % 1000 < prob) {
batch_h[batch + last] = trainList[i].h;
batch_t[batch + last] =
corrupt_head(id, trainList[i].h, trainList[i].r);
batch_r[batch + last] = trainList[i].r;
} else {
batch_h[batch + last] =
corrupt_tail(id, trainList[i].t, trainList[i].r);
;
batch_t[batch + last] = trainList[i].t;
batch_r[batch + last] = trainList[i].r;
}
batch_y[batch + last] = -1;
last += batchSize;
} else {
batch_h[batch + last] =
corrupt_tail(id, trainList[i].t, trainList[i].r);
;
batch_t[batch + last] = trainList[i].t;
batch_r[batch + last] = trainList[i].r;
if (headBatchFlag) {
batch_h[batch + last] =
corrupt_tail(id, trainList[i].t, trainList[i].r);
batch_t[batch + last] = trainList[i].t;
batch_r[batch + last] = trainList[i].r;
} else {
batch_h[batch + last] = trainList[i].h;
batch_t[batch + last] =
corrupt_head(id, trainList[i].h, trainList[i].r);
batch_r[batch + last] = trainList[i].r;
}
batch_y[batch + last] = -1;
last += batchSize;
}
batch_y[batch + last] = -1;
last += batchSize;
}
for (INT times = 0; times < negRelRate; times++) {
batch_h[batch + last] = trainList[i].h;
@@ -103,7 +126,7 @@ void *getBatch(void *con) {

extern "C" void sampling(INT *batch_h, INT *batch_t, INT *batch_r,
REAL *batch_y, INT batchSize, INT negRate = 1,
INT negRelRate = 0) {
INT negRelRate = 0, INT headBatchFlag = 0) {
pthread_t *pt = (pthread_t *)malloc(workThreads * sizeof(pthread_t));
Parameter *para = (Parameter *)malloc(workThreads * sizeof(Parameter));
for (INT threads = 0; threads < workThreads; threads++) {
@@ -115,6 +138,7 @@ extern "C" void sampling(INT *batch_h, INT *batch_t, INT *batch_r,
para[threads].batchSize = batchSize;
para[threads].negRate = negRate;
para[threads].negRelRate = negRelRate;
para[threads].headBatchFlag = headBatchFlag;
pthread_create(&pt[threads], NULL, getBatch, (void *)(para + threads));
}
for (INT threads = 0; threads < workThreads; threads++)
1 change: 1 addition & 0 deletions seed_embeddings/OpenKE/base/Reader.h
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ INT *testLef, *testRig;
INT *validLef, *validRig;

extern "C" void importTrainFiles() {

printf("The toolkit is importing datasets.\n");
FILE *fin;
int tmp;
3 changes: 3 additions & 0 deletions seed_embeddings/OpenKE/base/Setting.h
Original file line number Diff line number Diff line change
@@ -62,7 +62,10 @@ extern "C" INT getValidTotal() { return validTotal; }
*/

INT bernFlag = 0;
INT crossSamplingFlag = 0;

extern "C" void setBern(INT con) { bernFlag = con; }

extern "C" void setHeadTailCrossSampling(INT con) { crossSamplingFlag = con; }

#endif
46 changes: 22 additions & 24 deletions seed_embeddings/OpenKE/base/Test.h
Original file line number Diff line number Diff line change
@@ -25,6 +25,27 @@ REAL l3_filter_tot_constrain = 0, l3_tot_constrain = 0, r3_tot_constrain = 0,
r_filter_tot_constrain = 0, r_filter_rank_constrain = 0,
r_rank_constrain = 0, r_filter_reci_rank_constrain = 0,
r_reci_rank_constrain = 0;

extern "C" void initTest() {
lastHead = 0;
lastTail = 0;
l1_filter_tot = 0, l1_tot = 0, r1_tot = 0, r1_filter_tot = 0, l_tot = 0,
r_tot = 0, l_filter_rank = 0, l_rank = 0, l_filter_reci_rank = 0,
l_reci_rank = 0;
l3_filter_tot = 0, l3_tot = 0, r3_tot = 0, r3_filter_tot = 0,
l_filter_tot = 0, r_filter_tot = 0, r_filter_rank = 0, r_rank = 0,
r_filter_reci_rank = 0, r_reci_rank = 0;

l1_filter_tot_constrain = 0, l1_tot_constrain = 0, r1_tot_constrain = 0,
r1_filter_tot_constrain = 0, l_tot_constrain = 0, r_tot_constrain = 0,
l_filter_rank_constrain = 0, l_rank_constrain = 0,
l_filter_reci_rank_constrain = 0, l_reci_rank_constrain = 0;
l3_filter_tot_constrain = 0, l3_tot_constrain = 0, r3_tot_constrain = 0,
r3_filter_tot_constrain = 0, l_filter_tot_constrain = 0,
r_filter_tot_constrain = 0, r_filter_rank_constrain = 0, r_rank_constrain = 0,
r_filter_reci_rank_constrain = 0, r_reci_rank_constrain = 0;
}

extern "C" void getHeadBatch(INT *ph, INT *pt, INT *pr) {
for (INT i = 0; i < entityTotal; i++) {
ph[i] = i;
@@ -111,10 +132,6 @@ extern "C" void testHead(REAL *con) {
l_reci_rank_constrain += 1.0 / (l_s_constrain + 1);

lastHead++;

printf("l_filter_s: %ld\n", l_filter_s);
printf("%f %f %f %f \n", l_tot / lastHead, l_filter_tot / lastHead,
l_rank / lastHead, l_filter_rank / lastHead);
}

extern "C" void testTail(REAL *con) {
@@ -185,9 +202,6 @@ extern "C" void testTail(REAL *con) {
r_reci_rank_constrain += 1.0 / (1 + r_s_constrain);

lastTail++;
printf("r_filter_s: %ld\n", r_filter_s);
printf("%f %f %f %f\n", r_tot / lastTail, r_filter_tot / lastTail,
r_rank / lastTail, r_filter_rank / lastTail);
}

extern "C" void test_link_prediction() {
@@ -307,14 +321,6 @@ extern "C" void getNegTest() {
negTestList[i] = testList[i];
negTestList[i].t = corrupt(testList[i].h, testList[i].r);
}
FILE *fout = fopen((inPath + "test_neg.txt").c_str(), "w");
for (INT i = 0; i < testTotal; i++) {
fprintf(fout, "%ld\t%ld\t%ld\t%ld\n", testList[i].h, testList[i].t,
testList[i].r, INT(1));
fprintf(fout, "%ld\t%ld\t%ld\t%ld\n", negTestList[i].h, negTestList[i].t,
negTestList[i].r, INT(-1));
}
fclose(fout);
}

Triple *negValidList;
@@ -324,14 +330,6 @@ extern "C" void getNegValid() {
negValidList[i] = validList[i];
negValidList[i].t = corrupt(validList[i].h, validList[i].r);
}
FILE *fout = fopen((inPath + "valid_neg.txt").c_str(), "w");
for (INT i = 0; i < validTotal; i++) {
fprintf(fout, "%ld\t%ld\t%ld\t%ld\n", validList[i].h, validList[i].t,
validList[i].r, INT(1));
fprintf(fout, "%ld\t%ld\t%ld\t%ld\n", negValidList[i].h, negValidList[i].t,
negValidList[i].r, INT(-1));
}
fclose(fout);
}

extern "C" void getTestBatch(INT *ph, INT *pt, INT *pr, INT *nh, INT *nt,
@@ -359,7 +357,7 @@ extern "C" void getValidBatch(INT *ph, INT *pt, INT *pr, INT *nh, INT *nt,
nr[i] = negValidList[i].r;
}
}
// REAL* relThresh;

REAL threshEntire;
extern "C" void getBestThreshold(REAL *relThresh, REAL *score_pos,
REAL *score_neg) {
78 changes: 78 additions & 0 deletions seed_embeddings/OpenKE/base/Valid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#ifndef VALID_H
#define VALID_H
#include "Corrupt.h"
#include "Reader.h"
#include "Setting.h"

INT lastValidHead = 0;
INT lastValidTail = 0;

REAL l_valid_filter_tot = 0;
REAL r_valid_filter_tot = 0;

extern "C" void validInit() {
lastValidHead = 0;
lastValidTail = 0;
l_valid_filter_tot = 0;
r_valid_filter_tot = 0;
}

extern "C" void getValidHeadBatch(INT *ph, INT *pt, INT *pr) {
for (INT i = 0; i < entityTotal; i++) {
ph[i] = i;
pt[i] = validList[lastValidHead].t;
pr[i] = validList[lastValidHead].r;
}
}

extern "C" void getValidTailBatch(INT *ph, INT *pt, INT *pr) {
for (INT i = 0; i < entityTotal; i++) {
ph[i] = validList[lastValidTail].h;
pt[i] = i;
pr[i] = validList[lastValidTail].r;
}
}

extern "C" void validHead(REAL *con) {
INT h = validList[lastValidHead].h;
INT t = validList[lastValidHead].t;
INT r = validList[lastValidHead].r;
REAL minimal = con[h];
INT l_filter_s = 0;
for (INT j = 0; j < entityTotal; j++) {
if (j != h) {
REAL value = con[j];
if (value < minimal && !_find(j, t, r))
l_filter_s += 1;
}
}
if (l_filter_s < 10)
l_valid_filter_tot += 1;
lastValidHead++;
}

extern "C" void validTail(REAL *con) {
INT h = validList[lastValidTail].h;
INT t = validList[lastValidTail].t;
INT r = validList[lastValidTail].r;
REAL minimal = con[t];
INT r_filter_s = 0;
for (INT j = 0; j < entityTotal; j++) {
if (j != t) {
REAL value = con[j];
if (value < minimal && !_find(h, j, r))
r_filter_s += 1;
}
}
if (r_filter_s < 10)
r_valid_filter_tot += 1;
lastValidTail++;
}

extern "C" REAL getValidHit10() {
return (l_valid_filter_tot / validTotal + r_valid_filter_tot / validTotal) /
2;
;
}

#endif
Loading