diff --git a/sam/onyx/hw_nodes/compute_node.py b/sam/onyx/hw_nodes/compute_node.py index 560aa4db..283b771f 100644 --- a/sam/onyx/hw_nodes/compute_node.py +++ b/sam/onyx/hw_nodes/compute_node.py @@ -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(): diff --git a/sam/onyx/hw_nodes/fiberaccess_node.py b/sam/onyx/hw_nodes/fiberaccess_node.py index 63e7c85f..7e7a3722 100644 --- a/sam/onyx/hw_nodes/fiberaccess_node.py +++ b/sam/onyx/hw_nodes/fiberaccess_node.py @@ -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 diff --git a/sam/onyx/hw_nodes/intersect_node.py b/sam/onyx/hw_nodes/intersect_node.py index 5f4617d4..f84feeef 100644 --- a/sam/onyx/hw_nodes/intersect_node.py +++ b/sam/onyx/hw_nodes/intersect_node.py @@ -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": diff --git a/sam/onyx/hw_nodes/merge_node.py b/sam/onyx/hw_nodes/merge_node.py index 5dccdb88..f074e3e4 100644 --- a/sam/onyx/hw_nodes/merge_node.py +++ b/sam/onyx/hw_nodes/merge_node.py @@ -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() diff --git a/sam/onyx/hw_nodes/read_scanner_node.py b/sam/onyx/hw_nodes/read_scanner_node.py index 64c4cad0..74fd70ef 100644 --- a/sam/onyx/hw_nodes/read_scanner_node.py +++ b/sam/onyx/hw_nodes/read_scanner_node.py @@ -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' @@ -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 @@ -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 @@ -292,7 +292,6 @@ 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": @@ -300,7 +299,6 @@ def configure(self, attributes): else: vr_mode = 0 - cfg_kwargs = { 'dense': dense, 'dim_size': dim_size, @@ -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 } diff --git a/sam/onyx/hw_nodes/write_scanner_node.py b/sam/onyx/hw_nodes/write_scanner_node.py index 4ac63f81..25df864a 100644 --- a/sam/onyx/hw_nodes/write_scanner_node.py +++ b/sam/onyx/hw_nodes/write_scanner_node.py @@ -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 @@ -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": @@ -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 diff --git a/sam/onyx/parse_dot.py b/sam/onyx/parse_dot.py index b21f553d..8533c9a8 100644 --- a/sam/onyx/parse_dot.py +++ b/sam/onyx/parse_dot.py @@ -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 = {} @@ -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 @@ -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") @@ -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 @@ -227,25 +249,40 @@ 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}", @@ -253,7 +290,6 @@ def rewrite_VectorReducer(self): self.fa_color += 1 - self.graph.add_node(union) self.graph.add_node(add) self.graph.add_node(crd_buffet) @@ -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]) @@ -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') @@ -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)