Skip to content

Commit

Permalink
Pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
i-colbert committed Feb 20, 2024
1 parent a243b68 commit e8d0c22
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/qonnx/core/datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def to_numpy_dt(self):
def get_canonical_name(self):
return "FLOAT32"


class Float16Type(BaseDataType):
def bitwidth(self):
return 16
Expand Down Expand Up @@ -175,6 +176,7 @@ def to_numpy_dt(self):
def get_canonical_name(self):
return "FLOAT16"


class IntType(BaseDataType):
def __init__(self, bitwidth, signed):
super().__init__()
Expand Down
13 changes: 6 additions & 7 deletions tests/analysis/test_matmul_mac_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,19 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


import pytest
import qonnx
from pkgutil import get_data

import qonnx.util.inference_cost as infc
from qonnx.util.cleanup import cleanup_model
from qonnx.core.modelwrapper import ModelWrapper
from qonnx.util.cleanup import cleanup_model


def test_matmul_mac_cost():
raw_model = get_data("qonnx","data/onnx/matmul_update/sdp.onnx")
raw_model = get_data("qonnx", "data/onnx/matmul_update/sdp.onnx")
model = ModelWrapper(raw_model)
cleaned_model = cleanup_model(model)
# Two Matmul layers with shape (i_shape, w_shape, o_shape), L1: ([4, 64, 32], [4, 32, 64], [4, 64, 64]) and L2: ([4, 64, 64], [4, 64, 32], [4, 64, 32])
# Two Matmul layers with shape (i_shape, w_shape, o_shape),
# L1: ([4, 64, 32], [4, 32, 64], [4, 64, 64]) and L2: ([4, 64, 64], [4, 64, 32], [4, 64, 32])
inf_cost_dict = infc.inference_cost(cleaned_model, discount_sparsity=False)
mac_cost = inf_cost_dict['op_mac_FLOAT32_FLOAT32'] # Expected mac cost 4*32*64*64 + 4*64*64*32 = 1048576
mac_cost = inf_cost_dict["op_mac_FLOAT32_FLOAT32"] # Expected mac cost 4*32*64*64 + 4*64*64*32 = 1048576
assert mac_cost == 1048576.0, "Error: discrepancy in mac cost."
4 changes: 2 additions & 2 deletions tests/transformation/test_nn_resize_to_deconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_resize_conv_to_deconv_quant_model(maintain_bit_width: bool):
# shouldn't be expected to maintain reasonable functional similarity
if not maintain_bit_width:
assert np.isclose(
output_deconv, output_resize_conv, atol=1 / 255.0, rtol=1.
output_deconv, output_resize_conv, atol=1 / 255.0, rtol=1.0
).all(), "Error: expected output does not match the produced output."


Expand All @@ -108,7 +108,7 @@ def create_nn_resize_conv_model(
ifm_dim = input_dim
ofm_dim = ifm_dim * upscale_factor
ofm_ch = out_channels
scales = np.array([1., 1., upscale_factor, upscale_factor], dtype=np.float32)
scales = np.array([1.0, 1.0, upscale_factor, upscale_factor], dtype=np.float32)

resize = oh.make_node(
"Resize",
Expand Down

0 comments on commit e8d0c22

Please sign in to comment.