Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/mapping_to_cgra' into matmul_relu
Browse files Browse the repository at this point in the history
  • Loading branch information
bobcheng15 committed Nov 23, 2023
2 parents e63d352 + 5deea43 commit 8a3c937
Show file tree
Hide file tree
Showing 14 changed files with 440 additions and 138 deletions.
27 changes: 27 additions & 0 deletions compiler/sam-outputs/onyx-dot/masked_broadcast.gv
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
digraph SAM {
comment="X=ss01,B=ss01,c=s0"
0 [comment="type=fiberlookup,index=i,tensor=B,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: B\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="B" mode="0" format="compressed" src="true" root="true"]
1 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"]
2 [comment="type=repeat,index=i,tensor=c,root=true" label="Repeat i: B" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="c" root="true"]
3 [comment="type=fiberlookup,index=i,tensor=c,mode=0,format=compressed,src=true,root=false" label="FiberLookup i: c\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="c" mode="0" format="compressed" src="true" root="false"]
4 [comment="type=fiberlookup,index=j,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: B\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="B" mode="1" format="compressed" src="true" root="false"]
5 [comment="type=intersect,index=j" label="intersect j" color=purple shape=box style=filled type="intersect" index="j"]
6 [comment="type=arrayvals,tensor=c" label="Array Vals: c" color=green2 shape=box style=filled type="arrayvals" tensor="c"]
7 [comment="type=fiberwrite,index=i,tensor=X,mode=0,format=compressed,segsize=2,crdsize=B0_dim,sink=true" label="FiberWrite i: X0\ncompressed" color=green3 shape=box style=filled type="fiberwrite" index="i" tensor="X" mode="0" format="compressed" segsize="2" crdsize="B0_dim" sink="true"]
8 [comment="type=fiberwrite,index=j,tensor=X,mode=1,format=compressed,segsize=B0_dim+1,crdsize=B0_dim*B1_dim,sink=true" label="FiberWrite j: X1\ncompressed" color=green3 shape=box style=filled type="fiberwrite" index="j" tensor="X" mode="1" format="compressed" segsize="B0_dim+1" crdsize="B0_dim*B1_dim" sink="true"]
9 [comment="type=fiberwrite,mode=vals,tensor=X,size=1*B0_dim*B1_dim,sink=true" label="FiberWrite Vals: X" color=green3 shape=box style=filled type="fiberwrite" tensor="X" mode="vals" size="1*B0_dim*B1_dim" sink="true"]
10 [comment="type=broadcast" shape=point style=invis type="broadcast"]
0 -> 10 [label="crd" style=dashed type="crd"]
10 -> 1 [label="crd" style=dashed type="crd"]
1 -> 2 [label="repsig" style=dotted type="repsig"]
2 -> 3 [label="ref" style=bold type="ref"]
0 -> 4 [label="ref" style=bold type="ref"]
3 -> 5 [label="ref_in-c" style=bold type="ref" comment="in-c"]
3 -> 5 [label="crd_in-c" style=dashed type="crd" comment="in-c"]
4 -> 5 [label="ref_in-B", style=bold type="ref" comment="in-B"]
4 -> 5 [label="crd_in-B", style=dashed type="crd" comment="in-B"]
5 -> 6 [label="ref_out-c", style=bold type="ref" comment="out-c"]
10 -> 7 [label="crd", style=dashed type="crd"]
5 -> 8 [label="crd", style=dashed type="crd"]
6 -> 9 [label="val", type="val"]
}
44 changes: 44 additions & 0 deletions compiler/sam-outputs/onyx-dot/matmul_ikj.gv
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
digraph SAM {
comment="X=ss01,B=ss01,C=ss01"
20 [comment="type=vectorreducer,index=j" label="VectorReducer j" color=brown shape=box style=filled type="vectorreducer" accum_index="j"]
0 [comment="type=fiberwrite,mode=vals,tensor=X,size=1*B0_dim*C1_dim,sink=true" label="FiberWrite Vals: X" color=green3 shape=box style=filled type="fiberwrite" tensor="X" mode="vals" size="1*B0_dim*C1_dim" sink="true"]
1 [comment="type=fiberwrite,index=j,tensor=X,mode=1,format=compressed,segsize=B0_dim+1,crdsize=B0_dim*C1_dim,sink=true" label="FiberWrite j: X1\ncompressed" color=green3 shape=box style=filled type="fiberwrite" index="j" tensor="X" mode="1" format="compressed" segsize="B0_dim+1" crdsize="B0_dim*C1_dim" sink="true"]
19 [comment="type=fiberlookup,index=i,tensor=B,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: B0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="B" mode="0" format="compressed" src="true" root="true"]
18 [comment="type=broadcast" shape=point style=invis type="broadcast"]
2 [comment="type=fiberwrite,index=i,tensor=X,mode=0,format=compressed,segsize=2,crdsize=B0_dim,sink=true" label="FiberWrite i: X0\ncompressed" color=green3 shape=box style=filled type="fiberwrite" index="i" tensor="X" mode="0" format="compressed" segsize="2" crdsize="B0_dim" sink="true"]
17 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"]
16 [comment="type=repeat,index=i,tensor=C,root=true" label="Repeat i: C" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="C" root="true"]
15 [comment="type=fiberlookup,index=k,tensor=C,mode=0,format=compressed,src=true,root=false" label="FiberLookup k: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="C" mode="0" format="compressed" src="true" root="false"]
13 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"]
9 [comment="type=repeat,index=j,tensor=B,root=false" label="Repeat j: B" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="B" root="false"]
7 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"]
6 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"]
12 [comment="type=fiberlookup,index=j,tensor=C,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: C1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="C" mode="1" format="compressed" src="true" root="false"]
11 [comment="type=broadcast" shape=point style=invis type="broadcast"]
10 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"]
8 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"]
14 [comment="type=fiberlookup,index=k,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup k: B1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="B" mode="1" format="compressed" src="true" root="false"]
19 -> 18 [label="crd" style=dashed type="crd" comment=""]
18 -> 17 [label="crd" style=dashed type="crd" comment=""]
17 -> 16 [label="repsig" style=dotted type="repsig"]
16 -> 15 [label="ref" style=bold type="ref"]
15 -> 13 [label="crd_in-C" style=dashed type="crd" comment="in-C"]
13 -> 9 [label="ref_out-B" style=bold type="ref" comment="out-B"]
9 -> 7 [label="ref" style=bold type="ref"]
7 -> 6 [label="val" type="val"]
13 -> 12 [label="ref_out-C" style=bold type="ref" comment="out-C"]
12 -> 11 [label="crd" style=dashed type="crd" comment=""]
19 -> 2 [label="crd_i" style=dashed type="crd" comment="i"]
11 -> 20 [label="crd_j" style=dashed type="crd" comment="j" special="true"]
11 -> 10 [label="crd" style=dashed type="crd" comment=""]
10 -> 9 [label="repsig" style=dotted type="repsig"]
12 -> 8 [label="ref" style=bold type="ref" comment=""]
8 -> 6 [label="val" type="val"]
15 -> 13 [label="ref_in-C" style=bold type="ref" comment="in-C"]
19 -> 14 [label="ref" style=bold type="ref" comment=""]
14 -> 13 [label="crd_in-B" style=dashed type="crd" comment="in-B"]
14 -> 13 [label="ref_in-B" style=bold type="ref" comment="in-B"]
6 -> 20 [label="mul_val_out" type="val"]
20 -> 0 [label="final_vals" type="val"]
20 -> 1 [label="crd_out-j" style=dashed type="crd" comment="out-j"]
}
55 changes: 55 additions & 0 deletions compiler/sam-outputs/onyx-dot/spmm_ijk_crddrop.gv
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
digraph SAM {
comment="X=ss01,B=dd01,C=ss10"
17 [comment="type=fiberlookup,index=i,tensor=B,mode=0,format=dense,src=true,root=true" label="FiberLookup i: B0\ndense" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="B" mode="0" format="dense" src="true" root="true"]
16 [comment="type=broadcast" shape=point style=invis type="broadcast"]
2 [comment="type=fiberwrite,index=i,tensor=X,mode=0,format=compressed,segsize=2,crdsize=B0_dim,sink=true" label="FiberWrite i: X0\ncompressed" color=green3 shape=box style=filled type="fiberwrite" index="i" tensor="X" mode="0" format="compressed" segsize="2" crdsize="B0_dim" sink="true"]
15 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"]
14 [comment="type=repeat,index=i,tensor=C,root=true" label="Repeat i: C" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="C" root="true"]
13 [comment="type=fiberlookup,index=j,tensor=C,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: C1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="C" mode="1" format="compressed" src="true" root="false"]
12 [comment="type=broadcast" shape=point style=invis type="broadcast"]
1 [comment="type=fiberwrite,index=j,tensor=X,mode=1,format=compressed,segsize=B0_dim+1,crdsize=B0_dim*C1_dim,sink=true" label="FiberWrite j: X1\ncompressed" color=green3 shape=box style=filled type="fiberwrite" index="j" tensor="X" mode="1" format="compressed" segsize="B0_dim+1" crdsize="B0_dim*C1_dim" sink="true"]
11 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"]
10 [comment="type=repeat,index=j,tensor=B,root=false" label="Repeat j: B" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="B" root="false"]
8 [comment="type=fiberlookup,index=k,tensor=B,mode=1,format=dense,src=true,root=false" label="FiberLookup k: B1\ndense" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="B" mode="1" format="dense" src="true" root="false"]
7 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"]
5 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"]
4 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"]
3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"]
0 [comment="type=fiberwrite,mode=vals,tensor=X,size=1*B0_dim*C1_dim,sink=true" label="FiberWrite Vals: X" color=green3 shape=box style=filled type="fiberwrite" tensor="X" mode="vals" size="1*B0_dim*C1_dim" sink="true"]
6 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"]
9 [comment="type=fiberlookup,index=k,tensor=C,mode=0,format=compressed,src=true,root=false" label="FiberLookup k: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="C" mode="0" format="compressed" src="true" root="false"]
18 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"]
19 [comment="type=crddrop,outer=j,inner=k" label="CrdDrop j,k" color=orange shape=box style=filled type="crddrop" outer="j" inner="k"]

17 -> 16 [label="crd" style=dashed type="crd" comment=""]
# 16 -> 2 [label="crd" style=dashed type="crd"]
16 -> 15 [label="crd" style=dashed type="crd"]
15 -> 14 [label="repsig" style=dotted type="repsig"]
14 -> 13 [label="ref" style=bold type="ref"]
13 -> 12 [label="crd" style=dashed type="crd" comment=""]
# 12 -> 1 [label="crd" style=dashed type="crd"]
12 -> 11 [label="crd" style=dashed type="crd"]
11 -> 10 [label="repsig" style=dotted type="repsig"]
10 -> 8 [label="ref" style=bold type="ref"]
8 -> 7 [label="crd_in-B" style=dashed type="crd" comment="in-B"]
7 -> 5 [label="ref_out-B" style=bold type="ref" comment="out-B"]
5 -> 4 [label="val" type="val"]
# 4 -> 3 [label="val" type="val"]
3 -> 0 [label="val" type="val"]
7 -> 6 [label="ref_out-C" style=bold type="ref" comment="out-C"]
6 -> 4 [label="val" type="val"]
8 -> 7 [label="ref_in-B" style=bold type="ref" comment="in-B"]
13 -> 9 [label="ref" style=bold type="ref" comment=""]
9 -> 7 [label="crd_in-C" style=dashed type="crd" comment="in-C"]
9 -> 7 [label="ref_in-C" style=bold type="ref" comment="in-C"]
17 -> 10 [label="ref" style=bold type="ref" comment=""]

4 -> 19 [label="val_inner-k" type="val" comment="inner-k"]
12 -> 19 [label="crd_outer-j" style=dashed type="crd" comment="outer-j"]
18 -> 1 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"]
19 -> 3 [label="val_inner-k" type="val" comment="inner-k"]

19 -> 18 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"]
16 -> 18 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"]
18 -> 2 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"]
}
27 changes: 27 additions & 0 deletions compiler/sam-outputs/onyx-dot/trans_masked_broadcast.gv
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
digraph SAM {
comment="X=ss01,B=ss01,c=s0"
0 [comment="type=fiberlookup,index=i,tensor=B,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: B\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="B" mode="0" format="compressed" src="true" root="true"]
1 [comment="type=fiberlookup,index=i,tensor=c,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: c\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="c" mode="0" format="compressed" src="true" root="true"]
2 [comment="type=intersect,index=i" label="intersect i" color=purple shape=box style=filled type="intersect" index="i"]
3 [comment="type=fiberlookup,index=j,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: B\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="B" mode="1" format="compressed" src="true" root="false"]
4 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"]
5 [comment="type=repeat,index=j,tensor=c,root=false" label="Repeat j: B" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="c" root="false"]
6 [comment="type=arrayvals,tensor=c" label="Array Vals: c" color=green2 shape=box style=filled type="arrayvals" tensor="c"]
7 [comment="type=fiberwrite,index=i,tensor=X,mode=0,format=compressed,segsize=2,crdsize=B0_dim,sink=true" label="FiberWrite i: X0\ncompressed" color=green3 shape=box style=filled type="fiberwrite" index="i" tensor="X" mode="0" format="compressed" segsize="2" crdsize="B0_dim" sink="true"]
8 [comment="type=fiberwrite,index=j,tensor=X,mode=1,format=compressed,segsize=B0_dim+1,crdsize=B0_dim*B1_dim,sink=true" label="FiberWrite j: X1\ncompressed" color=green3 shape=box style=filled type="fiberwrite" index="j" tensor="X" mode="1" format="compressed" segsize="B0_dim+1" crdsize="B0_dim*B1_dim" sink="true"]
9 [comment="type=fiberwrite,mode=vals,tensor=X,size=1*B0_dim*B1_dim,sink=true" label="FiberWrite Vals: X" color=green3 shape=box style=filled type="fiberwrite" tensor="X" mode="vals" size="1*B0_dim*B1_dim" sink="true"]
10 [comment="type=broadcast" shape=point style=invis type="broadcast"]
0 -> 2 [label="ref_in-B" style=bold type="ref" comment="in-B"]
0 -> 2 [label="crd_in-B" style=dashed type="crd" comment="in-B"]
1 -> 2 [label="ref_in-c" style=bold type="ref" comment="in-c"]
1 -> 2 [label="crd_in-c" style=dashed type="crd" comment="in-c"]
2 -> 3 [label="ref_out-B" style=bold type="ref" comment="out-B"]
2 -> 7 [label="crd" style=dashed type="crd"]
3 -> 10 [label="crd" style=dashed type="crd"]
10 -> 4 [label="crd" style=dashed type="crd"]
10 -> 8 [label="crd" style=dashed type="crd"]
4 -> 5 [label="repsig" style=dotted type="repsig"]
2 -> 5 [label="ref_out-c" style=bold type="ref" comment="out-c"]
5 -> 6 [label="ref" style=bold type="ref"]
6 -> 9 [label="val" type="val"]
}
12 changes: 10 additions & 2 deletions sam/onyx/hw_nodes/buffet_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,16 @@ def configure(self, attributes):
cap0 = kratos.clog2(capacity_0) - fetch_width_log
cap1 = kratos.clog2(capacity_1) - fetch_width_log

if 'vector_reduce_mode' in attributes:
is_in_vr_mode = attributes['vector_reduce_mode'].strip('"')
if is_in_vr_mode == "true":
vr_mode = 1
else:
vr_mode = 0

cfg_kwargs = {
'capacity_0': cap0,
'capacity_1': cap1
'capacity_1': cap1,
'vr_mode': vr_mode
}
return (capacity_0, capacity_1), cfg_kwargs
return (capacity_0, capacity_1, vr_mode), cfg_kwargs
29 changes: 21 additions & 8 deletions sam/onyx/hw_nodes/compute_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ def connect(self, other, edge, kwargs=None):
pe = self.get_name()
# isect_conn = other.get_num_inputs()

if 'tensor' not in edge.get_attributes():
# Taking some liberties here - but technically this is the combo val
# isect_conn = other.get_connection_from_tensor('B')
isect_conn = other.get_connection_from_tensor('C')
if 'vector_reduce_mode' in edge.get_attributes():
if edge.get_attributes()['vector_reduce_mode']:
isect_conn = 0
else:
isect_conn = other.get_connection_from_tensor(edge.get_tensor())
if 'tensor' not in edge.get_attributes():
# Taking some liberties here - but technically this is the combo val
# isect_conn = other.get_connection_from_tensor('B')
isect_conn = other.get_connection_from_tensor('C')
else:
isect_conn = other.get_connection_from_tensor(edge.get_tensor())

new_conns = {
f'pe_to_isect_{in_str}_{isect_conn}': [
Expand All @@ -83,7 +87,7 @@ def connect(self, other, edge, kwargs=None):
pe = self.get_name()
new_conns = {
f'pe_to_reduce': [
([(pe, "res"), (other_red, f"data_in")], 17),
([(pe, "res"), (other_red, f"reduce_data_in")], 17),
]
}
return new_conns
Expand Down Expand Up @@ -153,6 +157,12 @@ def configure(self, attributes):
comment = attributes['comment'].strip('"')
print(c_op)
op_code = 0
# configuring via sam, it is a sparse app
use_dense = False
# mapping to pe only, configuring only the pe, ignore the reduce
pe_only = True
# data I/O should interface with other primitive outside of the cluster
pe_in_external = 1
if c_op == 'mul':
op_code = 1
elif c_op == 'add' and 'sub=1' not in comment:
Expand All @@ -162,6 +172,9 @@ def configure(self, attributes):
elif c_op == 'max':
op_code = 4
cfg_kwargs = {
'op': op_code
'op': op_code,
'use_dense': use_dense,
'pe_only': pe_only,
'pe_in_external': pe_in_external
}
return op_code, cfg_kwargs
return (op_code, use_dense, pe_only, pe_in_external), cfg_kwargs
7 changes: 7 additions & 0 deletions sam/onyx/hw_nodes/fiberaccess_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,12 @@ def configure(self, attributes, flavor):

cfg_tuple, cfg_kwargs = self.get_flavor(flavor=flavor).configure(attributes)
cfg_kwargs['flavor'] = flavor
print("THESE ARE MY CONFIG KWARGS")
print(cfg_kwargs)
# breakpoint()

# vr_mode = 0
# cfg_tuple += (vr_mode,)
# cfg_kwargs["vr_mode"] = vr_mode

return cfg_tuple, cfg_kwargs
2 changes: 1 addition & 1 deletion sam/onyx/hw_nodes/hw_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class HWNodeType(Enum):
Broadcast = 12
RepSigGen = 13
CrdHold = 14
SpAccumulator = 15
VectorReducer = 15
FiberAccess = 16


Expand Down
Loading

0 comments on commit 8a3c937

Please sign in to comment.