docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
ozaki_contraction.h
Go to the documentation of this file.
1#pragma once
2
3#include <nlohmann/json_fwd.hpp>
4#include <string>
5#include <vector>
6
12
13namespace sdfg {
14namespace fp_math {
15
24
56private:
58 OzakiVariant variant_;
59 int splits_;
60 Rescaling rescaling_;
61
62public:
63 static constexpr int MAX_SLICES = 10;
64
66 static const std::vector<int64_t>& moduli();
67 static constexpr int MAX_MODULI = 20;
68
76 int splits = 0,
78 );
79
80 virtual std::string name() const override;
81
82 virtual bool
84
85 virtual void apply(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager) override;
86
87 virtual void to_json(nlohmann::json& j) const override;
88
90
92 return variant_;
93 }
94
96 return rescaling_;
97 }
98
100 int effective_splits() const;
101
103 static int modular_bits(int moduli, int64_t k);
104
106 int matmuls() const;
107};
108
109} // namespace fp_math
110} // namespace sdfg
Definition analysis.h:53
Note: Even though the class references unique_ptr, it will never delete an SDFG it has a reference to...
Definition structured_sdfg_builder.h:44
Base class for all library nodes in the dataflow graph.
Definition library_node.h:106
OzakiVariant variant() const
Definition ozaki_contraction.h:91
int effective_splits() const
The slices or moduli the transformation uses for node, resolving 0 to the default.
static int modular_bits(int moduli, int64_t k)
Bits each of A and B keeps per row or column in the modular variant with moduli and reduction k.
static constexpr int MAX_SLICES
Definition ozaki_contraction.h:63
static constexpr int MAX_MODULI
Definition ozaki_contraction.h:67
static OzakiContraction from_json(builder::StructuredSDFGBuilder &builder, const nlohmann::json &j)
virtual void to_json(nlohmann::json &j) const override
Serialize this transformation to JSON.
virtual void apply(builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
Apply this transformation to the SDFG.
OzakiContraction(data_flow::LibraryNode &node, OzakiVariant variant=OzakiVariant::Modular, int splits=0, Rescaling rescaling=Rescaling::Exponents)
virtual std::string name() const override
Get the name of this transformation.
virtual bool can_be_applied(builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
Check if this transformation can be safely applied.
static const std::vector< int64_t > & moduli()
Odd primes below 256, largest first; the first MAX_MODULI serve as the moduli of the modular variant.
Rescaling rescaling() const
Definition ozaki_contraction.h:95
int matmuls() const
Int8 matmuls the transformation computes.
Base class for all SDFG transformations.
Definition transformation.h:25
Library node definitions for calling functions beyond simple instructions.
Definition function_builder.h:10
Definition kernel_builder.h:18
Rescaling
How QuantizeContraction applies the scales of A's rows and B's columns to the Int32 products.
Definition quantize_contraction.h:15
@ Exponents
Through the scales' power-of-two exponents in one step, so that no intermediate overflows where the r...
Definition quantize_contraction.h:18
OzakiVariant
How the Ozaki scheme represents the operands in Int8.
Definition ozaki_contraction.h:17
@ Slicing
Ozaki-I: split each operand into 7-bit slices and sum the s(s+1)/2 leading products of slices.
Definition ozaki_contraction.h:19
@ Modular
Ozaki-II: scale the operands to integers, multiply their residues modulo coprime moduli and reconstru...
Definition ozaki_contraction.h:22
Definition analysis.h:7