Skip to content

Commit

Permalink
more style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kalhankoul96 committed Jan 9, 2024
1 parent cd2dda3 commit 7af1acc
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions generate_spmv_sparsity_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# generating matrix dimensions and storing results in an array, array size is 2, 1 matrix and 2 dimensions per matrix

# conditions which need to be met for each set of 3 tensor dimensions: no dimension can't be 0,
# conditions which need to be met for each set of 3 tensor dimensions: no dimension can't be 0,
# and can't have a tensor with more than 900 elements (meaning dimension1*dimension2*dimension3 <= 900)
# note try to make it so no dimension is 1 or 2 (gives slight issues later, esp 2nd and 3rd dimensions)
dimensions = [0] * 2
Expand Down Expand Up @@ -129,7 +129,7 @@

# first step: one randomly generated 3D tensor given first set dimensions
# Note: generally if 2/3 elems in a tensor is 0, it can be considered sparse
# approach: 2/3 of the time add in a 0, 1/3 of the time add in an integer from 0 to 100
# approach: 2/3 of the time add in a 0, 1/3 of the time add in an integer from 0 to 100
# (use randint to generate num from 1 to 9 inclusive, and depending on where the num is, insert number or not)
# print('dimensions:')
# print(dimensions[0])
Expand Down
6 changes: 3 additions & 3 deletions maximum_tiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ def pair_tiles(app_name):
continue
for f in f_tensors:
f_loc = get_tile_id(f)
if (d_loc[1] == e_loc[0] and d_loc[3] == e_loc[2] and
if (d_loc[1] == e_loc[0] and d_loc[3] == e_loc[2] and
c_loc[1] == d_loc[0] and c_loc[3] == d_loc[2] and
b_loc[1] == c_loc[0] and b_loc[3] == c_loc[2] and
e_loc[1] == f_loc[0] and e_loc[3] == f_loc[1]):
b_loc[1] == c_loc[0] and b_loc[3] == c_loc[2] and
e_loc[1] == f_loc[0] and e_loc[3] == f_loc[1]):
tile_pairing[tile] = [b, c, d, e, f]
tile += 1

Expand Down
24 changes: 12 additions & 12 deletions sam/sim/src/tiling/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
sys.path.append(custom_path)

SAM_STRS = {
"matmul_kij": "X(i,j)=B(i,k)*C(k,j) -f=X:ss -f=B:ss:1,0 -f=C:ss -s=reorder(k,i,j)",
"matmul_ikj": "X(i,j)=B(i,k)*C(k,j) -f=X:ss -f=B:ss -f=C:ss -s=reorder(i,k,j)",
"matmul_ijk": "X(i,j)=B(i,k)*C(k,j) -f=X:ss -f=B:ss -f=C:ss:1,0 -s=reorder(i,j,k)",
"mat_elemadd": "X(i,j)=B(i,j)+C(i,j) -f=X:ss -f=B:ss -f=C:ss:1,0 -s=reorder(i,j,k)",
"mat_elemmul": "X(i,j)=B(i,j)*C(i,j) -f=X:ss -f=B:ss -f=C:ss:1,0 -s=reorder(i,j,k)",
"mat_mattransmul": "X(i,j)=B(j,i)*c(j)+d(i) -f=X:ss -f=B:ss -f=c:ss:0 -f=d:ss:0 -s=reorder(i,j)",
"mat_vecmul_ij": "X(i,j)=B(i,j)*c(j) -f=X:ss -f=B:ss -f=c:ss:0 -s=reorder(i,j)",
"mat_residual": "X(i,j)=b(i)-C(i,j)*d(j) -f=X:ss -f=C:ss -f=b:ss:0 -f=d:ss:0 -s=reorder(i,j)",
"mat_sddmm": "X(i,j)=B(i,j)*C(i,k)*D(k,j) -f=X:ss -f=B:ss -f=C:dd -f=D:dd:1,0 -s=reorder(i,j,k)",
"mat_elemadd3": "X(i,j)=B(i,j)+C(i,j)+D(i,j) -f=X:ss -f=B:ss -f=C:ss -f=D:ss",
"mat_mask_tri": "X(i,j)=B(i,j)*C(i,k)*D(k,j) -f=X:ss -f=B:ss -f=C:ss -f=D:ss:1,0 -s=reorder(i,j,k)",
"mat_vecmul_iter": "X(i,j)=B(i,j)*C(j,k)*D(k,l)*E(l,m)*f(m) -f=X:ss -f=B:ss -f=C:ss -f=D:ss -f=E:ss -f=f:s -s=reorder(i,j,k,l,m)"
"matmul_kij": "X(i,j)=B(i,k)*C(k,j) -f=X:ss -f=B:ss:1,0 -f=C:ss -s=reorder(k,i,j)",
"matmul_ikj": "X(i,j)=B(i,k)*C(k,j) -f=X:ss -f=B:ss -f=C:ss -s=reorder(i,k,j)",
"matmul_ijk": "X(i,j)=B(i,k)*C(k,j) -f=X:ss -f=B:ss -f=C:ss:1,0 -s=reorder(i,j,k)",
"mat_elemadd": "X(i,j)=B(i,j)+C(i,j) -f=X:ss -f=B:ss -f=C:ss:1,0 -s=reorder(i,j,k)",
"mat_elemmul": "X(i,j)=B(i,j)*C(i,j) -f=X:ss -f=B:ss -f=C:ss:1,0 -s=reorder(i,j,k)",
"mat_mattransmul": "X(i,j)=B(j,i)*c(j)+d(i) -f=X:ss -f=B:ss -f=c:ss:0 -f=d:ss:0 -s=reorder(i,j)",
"mat_vecmul_ij": "X(i,j)=B(i,j)*c(j) -f=X:ss -f=B:ss -f=c:ss:0 -s=reorder(i,j)",
"mat_residual": "X(i,j)=b(i)-C(i,j)*d(j) -f=X:ss -f=C:ss -f=b:ss:0 -f=d:ss:0 -s=reorder(i,j)",
"mat_sddmm": "X(i,j)=B(i,j)*C(i,k)*D(k,j) -f=X:ss -f=B:ss -f=C:dd -f=D:dd:1,0 -s=reorder(i,j,k)",
"mat_elemadd3": "X(i,j)=B(i,j)+C(i,j)+D(i,j) -f=X:ss -f=B:ss -f=C:ss -f=D:ss",
"mat_mask_tri": "X(i,j)=B(i,j)*C(i,k)*D(k,j) -f=X:ss -f=B:ss -f=C:ss -f=D:ss:1,0 -s=reorder(i,j,k)",
"mat_vecmul_iter": "X(i,j)=B(i,j)*C(j,k)*D(k,l)*E(l,m)*f(m) -f=X:ss -f=B:ss -f=C:ss -f=D:ss -f=E:ss -f=f:s -s=reorder(i,j,k,l,m)"
}


Expand Down
20 changes: 10 additions & 10 deletions scripts/tiling/generate_gold_mattransmul.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ def generate_gold_mattransmul_tiled(tile_crd_b, tile_crd_c, tile_crd_d, dirname,
# print(gold_nd)

gold_out = gold_nd.tocoo()
assert (tile_crd_b[1] == tile_crd_c[0] and tile_crd_b[3] == tile_crd_c[1]
and tile_crd_b[0] == tile_crd_d[0] and tile_crd_b[2] == tile_crd_d[1])
assert (tile_crd_b[1] == tile_crd_c[0] and tile_crd_b[3] == tile_crd_c[1] and
tile_crd_b[0] == tile_crd_d[0] and tile_crd_b[2] == tile_crd_d[1])
# assert tile_crd_b[1] == tile_crd_c[0] and tile_crd_b[3] == tile_crd_c[2]
scipy.io.mmwrite(
dirname + "out_" + str(tile_crd_b[0]) + "_" + str(tile_crd_b[1]) + "_" + str(tile_crd_b[3]) + "_"
+ str(tile_crd_b[2]) + "_" + str(tile_crd_c[0]) + "_" + str(tile_crd_c[1])
+ "_" + str(tile_crd_d[0]) + "_" + str(tile_crd_d[1]) + ".mtx", gold_out)
dirname + "out_" + str(tile_crd_b[0]) + "_" + str(tile_crd_b[1]) + "_" + str(tile_crd_b[3]) + "_" +
str(tile_crd_b[2]) + "_" + str(tile_crd_c[0]) + "_" + str(tile_crd_c[1]) +
"_" + str(tile_crd_d[0]) + "_" + str(tile_crd_d[1]) + ".mtx", gold_out)
elif os.path.exists(d_filename):
d_scipy = scipy.io.mmread(d_filename)
# print("\nd_scipy: ", d_scipy)
Expand Down Expand Up @@ -127,14 +127,14 @@ def generate_gold_mattransmul_tiled(tile_crd_b, tile_crd_c, tile_crd_d, dirname,
return

gold_out = gold_nd.tocoo()
# assert tile_crd_b[1] == tile_crd_c[0] and tile_crd_b[3] == tile_crd_c[1]
# assert tile_crd_b[1] == tile_crd_c[0] and tile_crd_b[3] == tile_crd_c[1]
# and tile_crd_b[0] == tile_crd_d[0] and tile_crd_b[2] == tile_crd_d[1]
# assert tile_crd_b[1] == tile_crd_c[0] and tile_crd_b[3] == tile_crd_c[2]
scipy.io.mmwrite(
dirname + "out_" + str(tile_crd_b[0]) + "_" + str(tile_crd_b[1])
+ "_" + str(tile_crd_b[3]) + "_" + str(tile_crd_b[2]) + "_"
+ str(tile_crd_c[0]) + "_" + str(tile_crd_c[1]) + "_"
+ str(tile_crd_d[0]) + "_" + str(tile_crd_d[1]) + ".mtx", gold_out)
dirname + "out_" + str(tile_crd_b[0]) + "_" + str(tile_crd_b[1]) +
"_" + str(tile_crd_b[3]) + "_" + str(tile_crd_b[2]) + "_" +
str(tile_crd_c[0]) + "_" + str(tile_crd_c[1]) + "_" +
str(tile_crd_d[0]) + "_" + str(tile_crd_d[1]) + ".mtx", gold_out)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion setup_tiling_mat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Usage: python3 setup_tiling_mat.py <app_name> <data_file> <tile_size> <docker_path>


# PARAMS
# PARAMS
data = [sys.argv[2]]
tilesizes = [int(sys.argv[3])]
app_name = sys.argv[1]
Expand Down
2 changes: 1 addition & 1 deletion setup_tiling_tensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import shutil
from scripts.util.util import FormatWriter, InputCacheSuiteSparse

# PARAMS
# PARAMS
tile = True
app_name = "tensor3_ttv"
vector_names = ['c']
Expand Down

0 comments on commit 7af1acc

Please sign in to comment.