Post-ops. More...
#include <dnnl.hpp>
Public Member Functions | |
post_ops () | |
Constructs an empty sequence of post-ops. | |
int | len () const |
Returns the number of post-ops entries. | |
primitive::kind | kind (int index) const |
Returns the primitive kind of post-op at entry with a certain index. More... | |
void | append_sum (float scale=1.) |
Appends an accumulation (sum) post-op. More... | |
void | get_params_sum (int index, float &scale) const |
Returns the parameters of an accumulation (sum) post-op. More... | |
void | append_eltwise (float scale, algorithm algorithm, float alpha, float beta) |
Appends an elementwise post-op. More... | |
void | get_params_eltwise (int index, float &scale, algorithm &algorithm, float &alpha, float &beta) const |
Returns parameters of an elementwise post-up. More... | |
![]() | |
bool | operator== (const handle< dnnl_post_ops_t, handle_traits< dnnl_post_ops_t > > &other) const |
Equality operator. More... | |
bool | operator!= (const handle &other) const |
Inequality operator. More... | |
handle ()=default | |
Constructs an empty handle object. More... | |
handle (const handle< dnnl_post_ops_t, handle_traits< dnnl_post_ops_t > > &)=default | |
Copy constructor. | |
handle (handle< dnnl_post_ops_t, handle_traits< dnnl_post_ops_t > > &&)=default | |
Move constructor. | |
handle (dnnl_post_ops_t t, bool weak=false) | |
Constructs a handle wrapper object from a C API handle. More... | |
handle< dnnl_post_ops_t, handle_traits< dnnl_post_ops_t > > & | operator= (const handle< dnnl_post_ops_t, handle_traits< dnnl_post_ops_t > > &)=default |
Assignment operator. | |
handle< dnnl_post_ops_t, handle_traits< dnnl_post_ops_t > > & | operator= (handle< dnnl_post_ops_t, handle_traits< dnnl_post_ops_t > > &&)=default |
Move assignment operator. | |
void | reset (dnnl_post_ops_t t, bool weak=false) |
Resets the handle wrapper objects to wrap a new C API handle. More... | |
dnnl_post_ops_t | get (bool allow_empty=false) const |
Returns the underlying C API handle. More... | |
operator dnnl_post_ops_t () const | |
Converts a handle to the underlying C API handle type. More... | |
operator bool () const | |
Checks whether the object is empty. More... | |
Post-ops.
Post-ops are computations executed after the main primitive computations and are attached to the primitive via primitive attributes.
|
inline |
Returns the primitive kind of post-op at entry with a certain index.
index | Index of the post-op to return the kind for. |
|
inline |
Appends an accumulation (sum) post-op.
Prior to accumulating the result, the previous value would be multiplied by a scaling factor scale
.
The kind of this post-op is dnnl::primitive::kind::sum.
This feature may improve performance for cases like residual learning blocks, where the result of convolution is accumulated to the previously computed activations. The parameter scale
may be used for the integer-based computations when the result and previous activations have different logical scaling factors.
In the simplest case when the accumulation is the only post-op, the computations would be:
dst[:] <- scale * dst[:] + op(...) // instead of dst[:] <- op(...)
scale | Scaling factor. |
|
inline |
Returns the parameters of an accumulation (sum) post-op.
index | Index of the sum post-op. |
scale | Scaling factor of the sum post-op. |
|
inline |
Appends an elementwise post-op.
The kind of this post-op is dnnl::primitive::kind::eltwise.
In the simplest case when the elementwise is the only post-op, the computations would be:
dst[:] <- scale * eltwise_op (op(...)) // instead of dst[:] <- op(...)
where eltwise_op is configured with the given parameters.
scale | Scaling factor. |
algorithm | Elementwise algorithm. |
alpha | Alpha parameter for the elementwise algorithm. |
beta | Beta parameter for the elementwise algorithm. |
|
inline |
Returns parameters of an elementwise post-up.
index | Index of the post-op. |
scale | Output scaling factor. |
algorithm | Output elementwise algorithm kind. |
alpha | Output alpha parameter for the elementwise algorithm. |
beta | Output beta parameter for the elementwise algorithm. |