einbench
收藏资源简介:
einbench是一个用于基准测试和验证einsum实现的随机成对张量收缩生成器。它包含两个数据集:1. contractions_benchmark.txt:约1000个随机收缩,操作数范围从约10^0到10^9,其中一半包含批次索引,另一半是矩阵乘法等效形式;2. contractions_verify.txt:约1000个操作数较低(最多约10^6)的随机收缩,用于验证实现正确性,包含各种边缘情况,如平凡求和、迹或对角索引。
EinBench is a random pairwise tensor contraction generator for benchmarking and validating einsum implementations. It consists of two datasets: 1. contractions_benchmark.txt: Approximately 1000 random contractions, with operand magnitudes ranging from ~10^0 to ~10^9. Half of them include batch indices, while the other half are equivalent to matrix multiplication operations; 2. contractions_verify.txt: Approximately 1000 random contractions with smaller operands (up to ~10^6), designed to validate implementation correctness. It covers various edge cases, such as trivial summations, traces, or diagonal indices.
einbench数据集概述
数据集简介
einbench是一个随机成对张量收缩生成器,用于基准测试和验证einsum实现。该数据集包含两个主要部分。
数据集组成
1. contractions_benchmark.txt
- 包含约1000个随机收缩运算
- 运算数量范围:约10^0到10^9
- 特征:一半包含批量索引,一半不包含(相当于矩阵乘法)
2. contractions_verify.txt
- 包含约1000个随机收缩运算
- 运算数量上限:约10^6
- 专门用于验证实现的正确性
- 包含各种边缘情况:平凡求和、迹运算、对角索引等
生成方法
两个数据集均使用同一代码生成,主要函数为random_pairwise_contraction,该函数通过以下步骤生成随机收缩:
- 选择收缩中使用的不同索引数量(1到log2(cost)之间)
- 在索引间随机分配总计算成本以定义其大小
- 调整大小直到实际成本≤目标成本
- 随机分配每个索引类型(出现在左侧、右侧和/或输出中)
- 按要求禁止标量或纯外积
- 随机排列每个项上的索引
- 返回einsum输入和输出字符串及索引大小字典
功能参数
生成器支持多种参数配置,包括:
- 目标计算成本控制
- 索引类型概率分布
- 允许的运算类型(标量、外积、批量、求和、迹运算等)
- 索引数量分布控制




