\documentclass[]{standalone}
\input{config-gfx}

\begin{document}
\def\axisdefaultwidth{10cm}
\def\axisdefaultheight{6cm}
%% read data
\pgfplotstableread[col sep=comma, header=true, read completely=true]{outputs_memory_measurement.csv}\outputsTable
\begin{tikzpicture}
  \begin{loglogaxis}[
      scalingplot,
      grid=both,
      xlabel=Number of Input Elements (10 input features per element),
      ylabel=Main Memory Used,
      y unit=\si{\mebi\byte},
      % change y base=true,-> doesn't work with log
      % y filter/.code=\pgfmathparse{#1+2.07944154167}, %%that's log(8) % -11.736069016284438}, % thats log(8/10^6)
      % y SI prefix=mega,
      ymin=0.04,
      xmax=524288,
    ]
    \addplot[libtorch] table[y expr=\thisrow{subgridles-intel-open-libtorch}/8/2^20] {\outputsTable};\label{plot:libtorch}
    \addlegendentry{\torchcpp};
    \addplot[cpp-open] table[y expr=\thisrow{subgridles-intel-open-cpp}/8/2^20] {\outputsTable};\label{plot:opencpp}
    \addlegendentry{\opencpp};
    \addplot[fortran-open] table[y expr=\thisrow{subgridles-intel-open-fortran}/8/2^20] {\outputsTable};\label{plot:openfortran}
    \addlegendentry{\openfortran};
    \addplot[cpp-mkl] table[y expr=\thisrow{subgridles-intel-mkl-cpp}/8/2^20] {\outputsTable};\addlegendentry{\mklcpp};\label{plot:mklcpp}
    \addplot[fortran-mkl] table[y expr=\thisrow{subgridles-intel-mkl-fortran}/8/2^20] {\outputsTable};\addlegendentry{\mklfortran};\label{plot:mklfortran}
    % have a function plot for linear slope
    \addplot+ [linear,domain=1:1048576] {x*2.15e-4};
  \coordinate(legendpos) at (10000, 0.09);
\end{loglogaxis}
  \matrix[
    matrix of nodes,
    % anchor=west,
    draw,
    inner sep=0.2em,
    nodes={font=\footnotesize},
    fill=white,
  ]at(legendpos)
  {
    \ref{plot:pytorch} \ref{plot:libtorch} & without \dalotia{}         & [5pt]\\
    \ref{plot:opencpp} \ref{plot:openfortran} \ref{plot:mklcpp} \ref{plot:mklfortran} & with \dalotia{}           & [5pt]\\
    };
\end{tikzpicture}
\end{document}
