<commit_before># RUN: %PYTHON %s 2>&1 | FileCheck %s

# This file contains small benchmarks with reasonably-sized problem/tiling sizes
# and codegen options.

from numpy.testing._private.utils import KnownFailureException
from ..core.experts import *
from ..core.harness import *
from ..core.transforms import *
from ..core.transform import *

from ..contraction.definitions import *

fun_name = 'reduction_1d_on_tensors'
op_name = 'linalg.generic'

################################################################################
### Compilation strategies.
################################################################################

all_names = [
  "Reduction1dExpert"
]
def all_experts(problem_sizes: List[int]):
  return [
      TileAndDecompose(
          fun_name=fun_name,
          op_name=op_name,
          tile_sizes=[32])\
      .then(Vectorize(fun_name, op_name))\
      .then(Bufferize())\
      .then(LowerVectors(multi_reduction_lowering='innerreduction'))\
      .then(LowerToLLVM())\
      .print_ir(after_all=False),
  ]


################################################################################
### Problem instantiations.
################################################################################

keys = ['m']


# CHECK-NOT: FAILURE
def main():
  # Specify default configuration and parse command line.
  args = test_argparser(
    "reduction 1d benchmark",
    default_n_iters=100,
    default_problem_sizes_list=[
      [128],
      [104],
      [256],
      [1000],
      [8000],
    ],
    default_expert_list=all_names,
    default_dynamic_at_compile_time_list=[],
    default_spec_list=[])

  def numpy_kernel(args, sizes, types):
    A, B = args
    B.fill(0.)
    np.sum(A, out=B)

  def pytorch_kernel(args, sizes, types):
    A, B = args
    B.fill_(0.)
    torch.sum(A, out=B)

  for problem_sizes in args.problem_sizes_list:
    test_harness(lambda s, t: EinsumProblem('m->', 1.0), [[np.float32] * 2],
          test_sizes(keys, [problem_sizes]),
          test_experts(all_experts(problem_sizes), all_names, args.expert_list),
          n_iters=args.n_iters,
          dump_data_to_file=args.dump_data)
<commit_msg>Fix remaining type of flop count parameter.<commit_after># RUN: %PYTHON %s 2>&1 | FileCheck %s

# This file contains small benchmarks with reasonably-sized problem/tiling sizes
# and codegen options.

from numpy.testing._private.utils import KnownFailureException
from ..core.experts import *
from ..core.harness import *
from ..core.transforms import *
from ..core.transform import *

from ..contraction.definitions import *

fun_name = 'reduction_1d_on_tensors'
op_name = 'linalg.generic'

################################################################################
### Compilation strategies.
################################################################################

all_names = [
  "Reduction1dExpert"
]
def all_experts(problem_sizes: List[int]):
  return [
      TileAndDecompose(
          fun_name=fun_name,
          op_name=op_name,
          tile_sizes=[32])\
      .then(Vectorize(fun_name, op_name))\
      .then(Bufferize())\
      .then(LowerVectors(multi_reduction_lowering='innerreduction'))\
      .then(LowerToLLVM())\
      .print_ir(after_all=False),
  ]


################################################################################
### Problem instantiations.
################################################################################

keys = ['m']


# CHECK-NOT: FAILURE
def main():
  # Specify default configuration and parse command line.
  args = test_argparser(
    "reduction 1d benchmark",
    default_n_iters=100,
    default_problem_sizes_list=[
      [128],
      [104],
      [256],
      [1000],
      [8000],
    ],
    default_expert_list=all_names,
    default_dynamic_at_compile_time_list=[],
    default_spec_list=[])

  def numpy_kernel(args, sizes, types):
    A, B = args
    B.fill(0.)
    np.sum(A, out=B)

  def pytorch_kernel(args, sizes, types):
    A, B = args
    B.fill_(0.)
    torch.sum(A, out=B)

  for problem_sizes in args.problem_sizes_list:
    test_harness(lambda s, t: EinsumProblem('m->', 1), [[np.float32] * 2],
          test_sizes(keys, [problem_sizes]),
          test_experts(all_experts(problem_sizes), all_names, args.expert_list),
          n_iters=args.n_iters,
          dump_data_to_file=args.dump_data)

{'fraction_non_alphanumeric': 0.25274725274725274, 'fraction_numerical': 0.015338827838827838, 'mean_word_length': 4.0625724217844725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7651986', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1329, 'n_words': 262}