From d1ed8f703f7378338ba49509a79efc756340d7e9 Mon Sep 17 00:00:00 2001 From: Samidh Mehta Date: Wed, 28 Feb 2024 17:01:51 -0800 Subject: [PATCH] 1. Adding floating point capabilities to reduce block. 2. Fix for generate matrix BF16 compressed mode --- sam/onyx/generate_matrices.py | 9 ++++++--- sam/onyx/hw_nodes/reduce_node.py | 11 ++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sam/onyx/generate_matrices.py b/sam/onyx/generate_matrices.py index 83c7443f..d8eb0532 100644 --- a/sam/onyx/generate_matrices.py +++ b/sam/onyx/generate_matrices.py @@ -195,10 +195,13 @@ def dump_outputs(self, format=None, tpose=False, dump_shape=True, flat_array.append(val) if glb_override: lines = [len(flat_array), *flat_array] - self.write_array(lines, name=f"tensor_{self.name}_mode_vals{suffix}", dump_dir=use_dir, dump_hex=print_hex) + self.write_array(lines, name=f"tensor_{self.name}_mode_vals{suffix}", + dump_dir=use_dir, dump_hex=print_hex, is_val=True) else: - self.write_array(flat_array, name=f"tensor_{self.name}_mode_vals{suffix}", dump_dir=use_dir, - dump_hex=print_hex) + self.write_array(flat_array, name=f"tensor_{self.name}_mode_vals{suffix}", + dump_dir=use_dir, dump_hex=print_hex, is_val=True) + + elif self.format == "COO": crd_dict = dict() order = len(self.array.shape) diff --git a/sam/onyx/hw_nodes/reduce_node.py b/sam/onyx/hw_nodes/reduce_node.py index 0700373e..96edda0e 100644 --- a/sam/onyx/hw_nodes/reduce_node.py +++ b/sam/onyx/hw_nodes/reduce_node.py @@ -112,7 +112,16 @@ def configure(self, attributes): # TODO: make this use the metamapper instr_type = strip_modifiers(lassen_fc.Py.input_t.field_dict['inst']) asm_ = Assembler(instr_type) - op = int(asm_.assemble(asm.add())) + + if 'fp' in attributes: + is_fp = attributes['fp'].strip('"') + if (is_fp == 'true'): + op = int(asm_.assemble(asm.fp_add())) + else: + op = int(asm_.assemble(asm.add())) + else: + op = int(asm_.assemble(asm.add())) + cfg_kwargs = { 'stop_lvl': stop_lvl, 'pe_connected_to_reduce': pe_connected_to_reduce,