Exemplo n.º 1
0
def benchmark_share_get_plot(b_data_share_get):
    """
    This function plots the graph for various protocols benchmarks for additive
    shared tensors

    Args:
        b_data_share_get (list): the sample data to approximate

    Returns:
        benchmark_share_get.png (png): plotted graph in graph/ast_benchmarks directory
    """
    # initializing workers
    worker = workers(hook())

    # available protocols
    protocols = ["snn", "fss"]

    # initializing graph plot
    fig, ax = plt.subplots()

    for protocol in protocols:

        # list for handling graph data
        x_data = []
        y_data = []

        for data in b_data_share_get:

            # getting value from b_data_share_get
            dtype, n_workers = data

            # temporary list for calculating average execution time and error
            temp_time_taken = []

            for i in range(10):
                start_time = timeit.default_timer()
                benchmark_share_get(worker, protocol, dtype, n_workers)
                time_taken = timeit.default_timer() - start_time
                temp_time_taken.append(time_taken)

            final_time_taken = sum(temp_time_taken) / len(temp_time_taken)
            final_time_taken *= 1000
            x_data.append(dtype + str(" / ") + str(n_workers))
            y_data.append(final_time_taken)

        ax.plot(x_data, y_data, label=protocol, linestyle="-")
        x_data.clear()
        y_data.clear()

    ax.set_xlabel("dtype / n_workers")
    ax.set_ylabel("Execution Time (ms)")
    ax.legend(bbox_to_anchor=(1, 1.22),
              loc="upper right",
              title="Protocols",
              fontsize="small")
    plt.tight_layout()
    plt.savefig("../graphs/ast_benchmarks/benchmark_share_get.png")
Exemplo n.º 2
0
    def run(cls, benchmark_data, save_path):
        """Benchmark specific operations and store the results as images.

        Args:
            benchmark_data (list): the sample data
            save_path (str): path where result images will be stored.
        """
        worker = workers(hook())
        cls._plot(benchmark_data, worker, save_path)
Exemplo n.º 3
0
def benchmark_batch_norm_plot(b_data_batch_norm):
    """
    This function plots the graph for various protocols benchmarks for
    batch_norm.

    Args:
        b_data_batch_norm (list): list of protocols to approximate

    Returns:
        benchmark_batch_norm.png (png): plotted graph in graph/ast_benchmarks directory
    """

    # initializing workers
    worker = workers(hook())

    # getting data (protocols)
    protocols = b_data_batch_norm

    # initializing graph plot
    fig, ax = plt.subplots()

    for protocol in protocols:

        # list for handling graph data
        x_data = []
        y_data = []

        for prec_frac in range(1, 5):
            temp_time_taken = []

            for i in range(10):
                start_time = timeit.default_timer()
                benchmark_batch_norm(worker, protocol, True, prec_frac)
                time_taken = timeit.default_timer() - start_time
                temp_time_taken.append(time_taken)

            final_time_taken = sum(temp_time_taken) / len(temp_time_taken)
            final_time_taken *= 1000
            y_data.append(final_time_taken)
            x_data.append(prec_frac)

        ax.plot(x_data, y_data, label=protocol, linestyle="-")
        x_data.clear()
        y_data.clear()

    # plotting of the data
    plt.title("benchmark_batch_norm")
    ax.set_xlabel("Precision Value")
    ax.set_ylabel("Execution Time (ms)")
    ax.legend(bbox_to_anchor=(1, 1.3),
              loc="upper right",
              title="Protocol",
              fontsize="small")
    plt.tight_layout()
    plt.savefig("../graphs/ast_benchmarks/benchmark_batch_norm.png")