Program Listing for File options.hpp

Return to documentation for file (SeQuant/core/optimize/options.hpp)

#ifndef SEQUANT_CORE_OPTIMIZE_OPTIONS_HPP
#define SEQUANT_CORE_OPTIMIZE_OPTIONS_HPP

#include <SeQuant/core/batch_policy.hpp>

#include <cstddef>
#include <functional>

namespace sequant {

class Index;
class Tensor;

enum class ObjectiveFunction {
  DenseFLOPs,
  DenseSize,
  DensePeakSize,
  DensePeakSizeBatched
};

enum class ReorderSum { Reorder, NoReorder };

struct CSEOptions {
  bool subnet = false;
};

struct RooflineParams {
  double machine_balance = 0.0;
  double fast_mem_elems = 0.0;
  double block_tiles = 3.0;
  double block_prefactor = 1.0;
};

struct CostParams {
  std::function<bool(Tensor const&)> is_volatile_leaf = {};
  double volatile_weight = 1.0;
  double footprint_weight = 0.0;
  double peak_flops_tolerance = 0.10;
  RooflineParams roofline = {};
  double accumulation_factor = 0.0;
  bool prune_outer_products = true;
};

using index_to_extent_t = std::function<std::size_t(Index const&)>;

struct OptimizeOptions {
  ObjectiveFunction objective_function = ObjectiveFunction::DenseFLOPs;

  ReorderSum reorder = ReorderSum::Reorder;

  CSEOptions CSE = {};

  index_to_extent_t idx_to_extent = {};

  std::function<double(Index const&, std::size_t)> inner_pow = {};

  BatchPolicy batch_policy = {};

  double volatile_weight = 1.0;

  double peak_flops_tolerance = 0.10;

  double footprint_weight = 0.0;

  RooflineParams roofline = {};

  bool prune_outer_products = true;
};

}  // namespace sequant

#endif  // SEQUANT_CORE_OPTIMIZE_OPTIONS_HPP