<commit_before># -*- coding: utf-8 -*-
"""NumPy support.
"""

import argparse
from timeit import default_timer as timer
import numpy as np


class Benchmark():
    def __init__(self, params, remaining_args=None):
        self.params = params
        parser = argparse.ArgumentParser(description='Benchmark GEMM operations')
        #parser.add_argument('--size', default=None)
        #args = parser.parse_args(remaining_args)
        #params["mode"] = args.mode
        #params["path_out"] = os.path.join(params["path_out"], params["mode"])

        # TODO: read size from args
        # TODO: add float type as arg

    def run(self):
        params = self.params
        if params["problem"]["name"] != "gemm":
            raise Exception("only gemm problem is defined for numpy")
        if "nb_gpus" in params:
            if params["nb_gpus"] > 0:
                raise Exception("Numpy framework does not work with GPU back-end")

        if isinstance(params["problem"]["size"], int):
            M = N = K = params["problem"]["size"]
        else:
            M, N, K = params["problem"]["size"]
        a = np.random.random((M, N))
        b = np.random.random((N, K))
        c = np.random.random((M, K))

        nb_epoch = 2

        time_start = timer()
        for _ in range(nb_epoch):
            c = a @ b + c
        time_end = timer()
        gflop = (2.0 * M * N * K) / (1024 ** 3)
        #print(f"GFlop: {gflop:.5f}")
        elapsed_time = (time_end - time_start) / nb_epoch
        #print(f"time: {elapsed_time:.5f}")
        #print(f"GFlop/sec: {gflop / elapsed_time:.5f}")

        params["time"] = elapsed_time
        params["GFLOP"] = gflop
        params["GFLOP/sec"] = gflop / elapsed_time
        return params
<commit_msg>add precision to log path<commit_after># -*- coding: utf-8 -*-
"""NumPy support.
"""

import argparse
from timeit import default_timer as timer
import numpy as np
import os


class Benchmark():
    def __init__(self, params, remaining_args=None):
        self.params = params
        parser = argparse.ArgumentParser(description='Benchmark GEMM operations')
        #parser.add_argument('--size', default=None)
        #args = parser.parse_args(remaining_args)
        params["problem"]["precision"] = "FP32"
        params["path_out"] = os.path.join(params["path_out"], params["problem"]["precision"])

        # TODO: read size from args
        # TODO: add float type as arg

    def run(self):
        params = self.params
        if params["problem"]["name"] != "gemm":
            raise Exception("only gemm problem is defined for numpy")
        if "nb_gpus" in params:
            if params["nb_gpus"] > 0:
                raise Exception("Numpy framework does not work with GPU back-end")

        if isinstance(params["problem"]["size"], int):
            M = N = K = params["problem"]["size"]
        else:
            M, N, K = params["problem"]["size"]
        dtype = np.float32
        a = np.random.random((M, N)).astype(dtype)
        b = np.random.random((N, K)).astype(dtype)
        c = np.random.random((M, K)).astype(dtype)

        nb_epoch = 2

        time_start = timer()
        for _ in range(nb_epoch):
            c = a @ b # + c
        time_end = timer()
        gflop = (2.0 * M * N * K) / (1024 ** 3)
        #print(f"GFlop: {gflop:.5f}")
        elapsed_time = (time_end - time_start) / nb_epoch
        #print(f"time: {elapsed_time:.5f}")
        #print(f"GFlop/sec: {gflop / elapsed_time:.5f}")

        params["time"] = elapsed_time
        params["GFLOP"] = gflop
        params["GFLOP/sec"] = gflop / elapsed_time
        return params

{'fraction_non_alphanumeric': 0.14620044052863437, 'fraction_numerical': 0.008259911894273128, 'mean_word_length': 2.2907608695652173, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1054962', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1158, 'n_words': 290}