Poplar and PopLibs
OperationDefUtil.hpp
Go to the documentation of this file.
1
// Copyright (c) 2021 Graphcore Ltd. All rights reserved.
8
#ifndef popops_OperationDefUtil_hpp
9
#define popops_OperationDefUtil_hpp
10
11
#include <
popops/Operation.hpp
>
12
#include <
poputil/VertexTemplates.hpp
>
13
#include <
poputil/exceptions.hpp
>
14
15
namespace
poputil
{
16
17
inline
const
char
*asString(
const
popops::Operation
&op) {
18
switch
(op) {
19
case
popops::Operation::ADD:
20
return
"Add"
;
21
case
popops::Operation::MUL:
22
return
"Mul"
;
23
case
popops::Operation::MIN:
24
return
"Min"
;
25
case
popops::Operation::MAX:
26
return
"Max"
;
27
case
popops::Operation::LOGICAL_AND
:
28
return
"Logical And"
;
29
case
popops::Operation::LOGICAL_OR
:
30
return
"Logical Or"
;
31
case
popops::Operation::SQUARE_ADD
:
32
return
"Square Add"
;
33
case
popops::Operation::LOG_ADD
:
34
return
"Log Add"
;
35
}
36
throw
poputil::poplibs_error
(
"Unsupported operation type"
);
37
}
38
40
template
<>
struct
VertexTemplateToString<
popops
::
Operation
> {
41
static
std::string to_string(
const
popops::Operation
&op) {
42
switch
(op) {
43
case
popops::Operation::ADD:
44
return
"popops::Operation::ADD"
;
45
case
popops::Operation::MUL:
46
return
"popops::Operation::MUL"
;
47
case
popops::Operation::MIN:
48
return
"popops::Operation::MIN"
;
49
case
popops::Operation::MAX:
50
return
"popops::Operation::MAX"
;
51
case
popops::Operation::LOGICAL_AND
:
52
return
"popops::Operation::LOGICAL_AND"
;
53
case
popops::Operation::LOGICAL_OR
:
54
return
"popops::Operation::LOGICAL_OR"
;
55
case
popops::Operation::SQUARE_ADD
:
56
return
"popops::Operation::SQUARE_ADD"
;
57
case
popops::Operation::LOG_ADD
:
58
return
"popops::Operation::LOG_ADD"
;
59
}
60
throw
poputil::poplibs_error
(
"Unsupported operation type"
);
61
}
62
};
63
64
}
// end namespace poputil
65
#endif
// popops_OperationDefUtil_hpp
Operation.hpp
Read/write types of operations used in a reduce.
VertexTemplates.hpp
Generate a string describing a vertex type.
popops
Common functions, such as elementwise and reductions.
Definition:
AllTrue.hpp:15
popops::Operation
Operation
Type of operation to use in a reduction.
Definition:
OperationDef.hpp:15
popops::Operation::LOGICAL_OR
@ LOGICAL_OR
Only supports boolean operands.
popops::Operation::LOG_ADD
@ LOG_ADD
Reduce using acc = a+log(1+exp(b-a))
popops::Operation::SQUARE_ADD
@ SQUARE_ADD
Squares each element before applying ADD reduction.
popops::Operation::LOGICAL_AND
@ LOGICAL_AND
Only supports boolean operands.
poputil
General utility functions for building graphs.
Definition:
GfloatExprUtil.hpp:23
exceptions.hpp
Define a PopLibs exception.
poputil::poplibs_error
Class for PopLibs exceptions.
Definition:
exceptions.hpp:17
include
popops
OperationDefUtil.hpp
Generated by
1.9.3