Skip to content

Commit

Permalink
Added softmax dispatch helpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandroarmas committed May 18, 2022
1 parent b1495a1 commit a0f6b99
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions include/m_algorithms_utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,50 +41,62 @@ namespace Matrix {
*/
struct Stringify {
constexpr std::string_view operator()(
const Unary::ReLU& _) {
const Unary::ReLU&) {
return "ReLU"; }
constexpr std::string_view operator()(
const Binary::HadamardProduct::Std& _) {
const Unary::SoftMax&) {
return "Softmax"; }
constexpr std::string_view operator()(
const Binary::HadamardProduct::Std&) {
return "HadamardProduct"; }
constexpr std::string_view operator()(
const Binary::Multiplication::ParallelDNC& _) {
const Binary::Multiplication::ParallelDNC&) {
return "MatrixMultiply"; }
constexpr std::string_view operator()(
const Binary::Multiplication::Naive& _) {
const Binary::Multiplication::Naive&) {
return "MatrixMultiply"; }
constexpr std::string_view operator()(
const Binary::Multiplication::Square& _) {
const Binary::Multiplication::Square&) {
return "MatrixMultiply"; }
constexpr std::string_view operator()(
const Binary::Addition::Std& _) {
const Binary::Addition::Std&) {
return "Addition"; }
constexpr std::string_view operator()(
const Binary::OuterProduct::Naive& _) {
const Binary::OuterProduct::Naive&) {
return "OuterProduct"; }
constexpr std::string_view operator()(
const Metric::CrossEntropy&) {
return "CrossEntropy"; }
};

struct Codify {
constexpr Code operator()(
const Unary::ReLU& _)
const Unary::ReLU&)
{ return Code::ReLU; }
constexpr Code operator()(
const Binary::HadamardProduct::Std& _)
const Unary::SoftMax&)
{ return Code::SoftMax; }
constexpr Code operator()(
const Binary::HadamardProduct::Std&)
{ return Code::HADAMARD; }
constexpr Code operator()(
const Binary::Multiplication::ParallelDNC& _)
const Binary::Multiplication::ParallelDNC&)
{ return Code::MULTIPLY; }
constexpr Code operator()(
const Binary::Multiplication::Naive& _)
const Binary::Multiplication::Naive&)
{ return Code::MULTIPLY; }
constexpr Code operator()(
const Binary::Multiplication::Square& _)
const Binary::Multiplication::Square&)
{ return Code::MULTIPLY; }
constexpr Code operator()(
const Binary::Addition::Std& _)
const Binary::Addition::Std&)
{ return Code::PLUS; }
constexpr Code operator()(
const Binary::OuterProduct::Naive& _)
const Binary::OuterProduct::Naive&)
{ return Code::OUTER_PRODUCT; }
constexpr Code operator()(
const Metric::CrossEntropy&) {
return Code::CROSS_ENTROPY; }
};


Expand Down

0 comments on commit a0f6b99

Please sign in to comment.