Skip to content

Commit

Permalink
Style fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoduoza committed Nov 17, 2023
1 parent 820d6b8 commit 8b313f8
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 72 deletions.
2 changes: 1 addition & 1 deletion sam/onyx/hw_nodes/compute_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def connect(self, other, edge, kwargs=None):
# isect_conn = other.get_num_inputs()

if 'vector_reduce_mode' in edge.get_attributes():
if edge.get_attributes()['vector_reduce_mode'] == True:
if edge.get_attributes()['vector_reduce_mode']:
isect_conn = 0
else:
if 'tensor' not in edge.get_attributes():
Expand Down
8 changes: 4 additions & 4 deletions sam/onyx/hw_nodes/fiberaccess_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ def configure(self, attributes, flavor):
cfg_kwargs['flavor'] = flavor
print("THESE ARE MY CONFIG KWARGS")
print(cfg_kwargs)
#breakpoint()
# breakpoint()

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

return cfg_tuple, cfg_kwargs
1 change: 0 additions & 1 deletion sam/onyx/hw_nodes/intersect_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ def configure(self, attributes):
cmrg_stop_lvl = 0
type_op = attributes['type'].strip('"')


if 'vector_reduce_mode' in attributes:
is_in_vr_mode = attributes['vector_reduce_mode'].strip('"')
if is_in_vr_mode == "true":
Expand Down
2 changes: 1 addition & 1 deletion sam/onyx/hw_nodes/merge_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def connect(self, other, edge, kwargs=None):
}

return new_conns
#raise NotImplementedError(f'Cannot connect MergeNode to {other_type}')
# raise NotImplementedError(f'Cannot connect MergeNode to {other_type}')
elif other_type == ReduceNode:
# raise NotImplementedError(f'Cannot connect MergeNode to {other_type}')
other_red = other.get_name()
Expand Down
14 changes: 6 additions & 8 deletions sam/onyx/hw_nodes/read_scanner_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def connect(self, other, edge, kwargs=None):
if 'use_alt_out_port' in edge_attr:
out_conn = 'block_rd_out'
elif ('vector_reduce_mode' in edge_attr):
if (edge_attr['vector_reduce_mode'] == True):
if (edge_attr['vector_reduce_mode']):
out_conn = 'pos_out'
else:
out_conn = 'coord_out'
Expand All @@ -106,7 +106,7 @@ def connect(self, other, edge, kwargs=None):
# Send both....
isect = other.get_name()
if 'vector_reduce_mode' in edge.get_attributes():
if edge.get_attributes()['vector_reduce_mode'] == True:
if edge.get_attributes()['vector_reduce_mode']:
isect_conn = 1
elif 'special' in edge.get_attributes():
isect_conn = 0
Expand Down Expand Up @@ -256,11 +256,11 @@ def configure(self, attributes):
dim_size = 1
stop_lvl = 0

#if 'spacc' in attributes:
# if 'spacc' in attributes:
# spacc_mode = 1
# assert 'stop_lvl' in attributes
# stop_lvl = int(attributes['stop_lvl'].strip('"'))
#else:
# else:
# spacc_mode = 0

# This is a fiberwrite's opposing read scanner for comms with GLB
Expand Down Expand Up @@ -292,15 +292,13 @@ def configure(self, attributes):
lookup = 0
block_mode = int(attributes['type'].strip('"') == 'fiberwrite')


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 = {
'dense': dense,
'dim_size': dim_size,
Expand All @@ -312,10 +310,10 @@ def configure(self, attributes):
'do_repeat': do_repeat,
'repeat_outer': repeat_outer,
'repeat_factor': repeat_factor,
#'stop_lvl': stop_lvl,
# 'stop_lvl': stop_lvl,
'block_mode': block_mode,
'lookup': lookup,
#'spacc_mode': spacc_mode
# 'spacc_mode': spacc_mode
'vr_mode': vr_mode
}

Expand Down
8 changes: 4 additions & 4 deletions sam/onyx/hw_nodes/write_scanner_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ def configure(self, attributes):
else:
compressed = 1

#if 'spacc' in attributes:
# if 'spacc' in attributes:
# spacc_mode = 1
# init_blank = 1
# assert 'stop_lvl' in attributes
# stop_lvl = int(attributes['stop_lvl'].strip('"'))
#else:
# else:
# spacc_mode = 0
# init_blank = 0

Expand All @@ -112,7 +112,7 @@ def configure(self, attributes):
block_mode = 1
else:
block_mode = 0

if 'vector_reduce_mode' in attributes:
is_in_vr_mode = attributes['vector_reduce_mode'].strip('"')
if is_in_vr_mode == "true":
Expand All @@ -131,6 +131,6 @@ def configure(self, attributes):
'block_mode': block_mode,
'vr_mode': vr_mode,
'init_blank': init_blank
#'spacc_mode': spacc_mode
# 'spacc_mode': spacc_mode
}
return cfg_tuple, cfg_kwargs
159 changes: 106 additions & 53 deletions sam/onyx/parse_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ def rewrite_VectorReducer(self):

# TODO: Get redux crd
output_crd = attrs['accum_index'].strip('"')
#input_crd = None
# input_crd = None

incoming_edges = [edge for edge in self.graph.get_edges() if edge.get_destination() == vr_node.get_name()]
outgoing_edges = [edge for edge in self.graph.get_edges() if edge.get_source() == vr_node.get_name()]

in_val_node = None
in_crd_node = None
#in_input_node = None
# in_input_node = None

# Keep these for the edges
in_edge_attrs = {}
Expand All @@ -167,11 +167,11 @@ def rewrite_VectorReducer(self):
in_val_node = incoming_edge_.get_source()
in_edge_attrs[in_val_node] = edge_attr
elif edge_attr['type'].strip('"') == 'crd':
#edge_comment = edge_attr['comment'].strip('"')
#if output_crd in edge_comment:
# edge_comment = edge_attr['comment'].strip('"')
# if output_crd in edge_comment:
in_crd_node = incoming_edge_.get_source()
in_edge_attrs[in_crd_node] = edge_attr
#else:
# else:
# input_crd = edge_comment
# in_input_node = incoming_edge_.get_source()
# in_edge_attrs[in_input_node] = edge_attr
Expand All @@ -190,16 +190,22 @@ def rewrite_VectorReducer(self):
og_type = attrs['type']
del attrs['type']

#rsg = pydot.Node(f"vr_rsg_{self.get_next_seq()}",
# rsg = pydot.Node(f"vr_rsg_{self.get_next_seq()}",
# **attrs, label=f"{og_label}_rsg", hwnode=f"{HWNodeType.RepSigGen}",
# type=og_type)

#repeat = pydot.Node(f"vr_repeat_{self.get_next_seq()}",
# repeat = pydot.Node(f"vr_repeat_{self.get_next_seq()}",
# **attrs, label=f"{og_label}_repeat", hwnode=f"{HWNodeType.Repeat}",
# root="true", type=og_type, spacc="true")

union = pydot.Node(f"vr_union_{self.get_next_seq()}", label=f"{og_label}_union", hwnode=f"{HWNodeType.Intersect}",
type="union", vector_reduce_mode="true", comment=f"type=union,index={output_crd}", index=output_crd)
union = pydot.Node(
f"vr_union_{self.get_next_seq()}",
label=f"{og_label}_union",
hwnode=f"{HWNodeType.Intersect}",
type="union",
vector_reduce_mode="true",
comment=f"type=union,index={output_crd}",
index=output_crd)

add = pydot.Node(f"vr_add_{self.get_next_seq()}", label=f"{og_label}_Add", hwnode=f"{HWNodeType.Compute}",
type="add", sub="0", comment="type=add,sub=0")
Expand All @@ -208,14 +214,30 @@ def rewrite_VectorReducer(self):
label=f"{og_label}_crd_buffet", hwnode=f"{HWNodeType.Buffet}",
type="buffet", vector_reduce_mode="true", fa_color=self.fa_color, comment="crd_buffet")

crd_rd_scanner = pydot.Node(f"vr_crd_rd_scanner_{self.get_next_seq()}",
label=f"{og_label}_crd_rd_scanner", hwnode=f"{HWNodeType.ReadScanner}",
tensor="X", type="fiberlookup", root="false", format="compressed",
mode="0", index=f"{output_crd}", vector_reduce_mode="true", fa_color=self.fa_color, comment="crd_rd_scanner")

crd_wr_scanner = pydot.Node(f"vr_crd_wr_scanner_{self.get_next_seq()}",
label=f"{og_label}_crd_wr_scanner", hwnode=f"{HWNodeType.WriteScanner}",
type="fiberwrite", mode="0", format="compressed", vector_reduce_mode="true", fa_color=self.fa_color, comment="crd_wr_scanner")
crd_rd_scanner = pydot.Node(
f"vr_crd_rd_scanner_{self.get_next_seq()}",
label=f"{og_label}_crd_rd_scanner",
hwnode=f"{HWNodeType.ReadScanner}",
tensor="X",
type="fiberlookup",
root="false",
format="compressed",
mode="0",
index=f"{output_crd}",
vector_reduce_mode="true",
fa_color=self.fa_color,
comment="crd_rd_scanner")

crd_wr_scanner = pydot.Node(
f"vr_crd_wr_scanner_{self.get_next_seq()}",
label=f"{og_label}_crd_wr_scanner",
hwnode=f"{HWNodeType.WriteScanner}",
type="fiberwrite",
mode="0",
format="compressed",
vector_reduce_mode="true",
fa_color=self.fa_color,
comment="crd_wr_scanner")

self.fa_color += 1

Expand All @@ -227,33 +249,47 @@ def rewrite_VectorReducer(self):
label=f"{og_label}_vals_buffet", hwnode=f"{HWNodeType.Buffet}",
type="buffet", vector_reduce_mode="true", fa_color=self.fa_color, comment="vals_buffet")

#vals_rd_scanner = pydot.Node(f"vr_vals_rd_scanner_{self.get_next_seq()}",
# vals_rd_scanner = pydot.Node(f"vr_vals_rd_scanner_{self.get_next_seq()}",
# label=f"{og_label}_vals_rd_scanner", hwnode=f"{HWNodeType.ReadScanner}",
# tensor="X", type="arrayvals", root="false", format="vals",
# mode="vals", vector_reduce_mode="true", fa_color=self.fa_color, comment="vals_rd_scanner")

vals_rd_scanner = pydot.Node(f"vr_vals_rd_scanner_{self.get_next_seq()}",
label=f"{og_label}_vals_rd_scanner", hwnode=f"{HWNodeType.ReadScanner}",
tensor="X", type="fiberlookup", root="false", format="compressed",
mode="1", vector_reduce_mode="true", fa_color=self.fa_color, comment="vals_rd_scanner")

#vals_wr_scanner = pydot.Node(f"vr_vals_wr_scanner_{self.get_next_seq()}",
# mode="vals", vector_reduce_mode="true", fa_color=self.fa_color,
# comment="vals_rd_scanner")

vals_rd_scanner = pydot.Node(
f"vr_vals_rd_scanner_{self.get_next_seq()}",
label=f"{og_label}_vals_rd_scanner",
hwnode=f"{HWNodeType.ReadScanner}",
tensor="X",
type="fiberlookup",
root="false",
format="compressed",
mode="1",
vector_reduce_mode="true",
fa_color=self.fa_color,
comment="vals_rd_scanner")

# vals_wr_scanner = pydot.Node(f"vr_vals_wr_scanner_{self.get_next_seq()}",
# label=f"{og_label}_vals_wr_scanner", hwnode=f"{HWNodeType.WriteScanner}",
# type="fiberwrite", mode="vals", vector_reduce_mode="true", fa_color=self.fa_color, comment="vals_wr_scanner")


vals_wr_scanner = pydot.Node(f"vr_vals_wr_scanner_{self.get_next_seq()}",
label=f"{og_label}_vals_wr_scanner", hwnode=f"{HWNodeType.WriteScanner}",
type="fiberwrite", mode="1", format="compressed", vector_reduce_mode="true", fa_color=self.fa_color, comment="vals_wr_scanner")

# type="fiberwrite", mode="vals", vector_reduce_mode="true",
# fa_color=self.fa_color, comment="vals_wr_scanner")

vals_wr_scanner = pydot.Node(
f"vr_vals_wr_scanner_{self.get_next_seq()}",
label=f"{og_label}_vals_wr_scanner",
hwnode=f"{HWNodeType.WriteScanner}",
type="fiberwrite",
mode="1",
format="compressed",
vector_reduce_mode="true",
fa_color=self.fa_color,
comment="vals_wr_scanner")

# glb_vals = pydot.Node(f"vr_crd_vals_{self.get_next_seq()}", **attrs,
# label=f"{og_label}_glb_vals_read", hwnode=f"{HWNodeType.GLB}",
# tensor="x", mode="vals", format="vals", type=og_type)

self.fa_color += 1


self.graph.add_node(union)
self.graph.add_node(add)
self.graph.add_node(crd_buffet)
Expand All @@ -263,7 +299,7 @@ def rewrite_VectorReducer(self):
self.graph.add_node(vals_rd_scanner)
self.graph.add_node(vals_wr_scanner)

#print(in_edge_attrs[in_input_node])
# print(in_edge_attrs[in_input_node])
print(in_edge_attrs[in_crd_node])
print(in_edge_attrs[in_val_node])

Expand All @@ -272,17 +308,24 @@ def rewrite_VectorReducer(self):
del in_edge_attrs[in_crd_node]['type']

# Edges
#input_to_rsg_edge = pydot.Edge(src=in_input_node, dst=rsg, **in_edge_attrs[in_input_node])
#rsg_to_repeat = pydot.Edge(src=rsg, dst=repeat)
#repeat_to_crd_rd_scan = pydot.Edge(src=repeat, dst=crd_rd_scanner)
#crd_rd_scan_to_val_rd_scan = pydot.Edge(src=crd_rd_scanner, dst=vals_rd_scanner)
# input_to_rsg_edge = pydot.Edge(src=in_input_node, dst=rsg, **in_edge_attrs[in_input_node])
# rsg_to_repeat = pydot.Edge(src=rsg, dst=repeat)
# repeat_to_crd_rd_scan = pydot.Edge(src=repeat, dst=crd_rd_scanner)
# crd_rd_scan_to_val_rd_scan = pydot.Edge(src=crd_rd_scanner, dst=vals_rd_scanner)
in_crd_to_union = pydot.Edge(src=in_crd_node, dst=union,
**in_edge_attrs[in_crd_node], type="crd", comment=f"in-B")
**in_edge_attrs[in_crd_node], type="crd", comment=f"in-B")
in_val_to_union = pydot.Edge(src=in_val_node, dst=union, **in_edge_attrs[in_val_node],
type="ref", comment=f"in-B", val="true", vector_reduce_mode=True)
type="ref", comment=f"in-B", val="true", vector_reduce_mode=True)
# type="ref", comment=f"in-C", val="true")
crd_rd_scan_to_union = pydot.Edge(src=crd_rd_scanner, dst=union, type="crd", comment="in-x", vector_reduce_mode=True)
val_rd_scan_to_union = pydot.Edge(src=vals_rd_scanner, dst=union, type="ref", comment="in-x", val="true", vector_reduce_mode=True)
crd_rd_scan_to_union = pydot.Edge(src=crd_rd_scanner, dst=union, type="crd",
comment="in-x", vector_reduce_mode=True)
val_rd_scan_to_union = pydot.Edge(
src=vals_rd_scanner,
dst=union,
type="ref",
comment="in-x",
val="true",
vector_reduce_mode=True)
union_crd_to_crd_wr_scan = pydot.Edge(src=union, dst=crd_wr_scanner, type="crd")
union_val0_to_alu = pydot.Edge(src=union, dst=add, comment='out-B')
# union_val0_to_alu = pydot.Edge(src=union, dst=add, comment='out-C')
Expand Down Expand Up @@ -315,16 +358,26 @@ def rewrite_VectorReducer(self):
print(val_edge_attr)
del crd_edge_attr['comment']

#crd_rd_scan_to_glb = pydot.Edge(src=crd_rd_scanner, dst=dst_crd, **crd_edge_attr, use_alt_out_port="1")
#val_rd_scan_to_glb = pydot.Edge(src=vals_rd_scanner, dst=dst_vals, **val_edge_attr, use_alt_out_port="1")

crd_rd_scan_to_ds = pydot.Edge(src=crd_rd_scanner, dst=dst_crd, **crd_edge_attr, comment="final-crd", vector_reduce_mode=True)
val_rd_scan_to_ds = pydot.Edge(src=vals_rd_scanner, dst=dst_vals, **val_edge_attr, comment="final-val", vector_reduce_mode=True)

#self.graph.add_edge(input_to_rsg_edge)
#self.graph.add_edge(rsg_to_repeat)
#self.graph.add_edge(repeat_to_crd_rd_scan)
#self.graph.add_edge(crd_rd_scan_to_val_rd_scan)
# crd_rd_scan_to_glb = pydot.Edge(src=crd_rd_scanner, dst=dst_crd, **crd_edge_attr, use_alt_out_port="1")
# val_rd_scan_to_glb = pydot.Edge(src=vals_rd_scanner, dst=dst_vals, **val_edge_attr, use_alt_out_port="1")

crd_rd_scan_to_ds = pydot.Edge(
src=crd_rd_scanner,
dst=dst_crd,
**crd_edge_attr,
comment="final-crd",
vector_reduce_mode=True)
val_rd_scan_to_ds = pydot.Edge(
src=vals_rd_scanner,
dst=dst_vals,
**val_edge_attr,
comment="final-val",
vector_reduce_mode=True)

# self.graph.add_edge(input_to_rsg_edge)
# self.graph.add_edge(rsg_to_repeat)
# self.graph.add_edge(repeat_to_crd_rd_scan)
# self.graph.add_edge(crd_rd_scan_to_val_rd_scan)
self.graph.add_edge(in_crd_to_union)
self.graph.add_edge(in_val_to_union)
self.graph.add_edge(crd_rd_scan_to_union)
Expand Down

0 comments on commit 8b313f8

Please sign in to comment.