RNN
Contents
RNN#
The RNN primitive computes a stack of unrolled recurrent cells, as depicted in Figure 1. \(\bias\), \(\srciter\) and \(\dstiter\) are optional parameters. If not provided, \(\bias\) and \(\srciter\) default to 0. Variable names follow the standard Conventions.
The RNN primitive supports four modes for evaluation direction:
left2right
will process the input data timestamps by increasing order,right2left
will process the input data timestamps by decreasing order,bidirectional_concat
will process all the stacked layers fromleft2right
and fromright2left
independently, and will concatenate the output in \(\dstlayer\) over the channel dimension,bidirectional_sum
will process all the stacked layers fromleft2right
and fromright2left
independently, and will sum the two outputs to \(\dstlayer\).
Even though the RNN primitive supports passing a different number of channels for \(\srclayer\), \(\srciter\), \(\dstlayer\), and \(\dstiter\), we always require the following conditions in order for the dimension to be consistent:
\(channels(\dstlayer) = channels(\dstiter)\),
when \(T > 1\), \(channels(\srciter) = channels(\dstiter)\),
when \(L > 1\), \(channels(\srclayer) = channels(\dstlayer)\),
when using the
bidirectional_concat
direction, \(channels(\dstlayer) = 2 * channels(\dstiter)\).
The general formula for the execution of a stack of unrolled recurrent cells depends on the current iteration of the previous layer (\(h_{t,l-1}\) and \(c_{t,l-1}\)) and the previous iteration of the current layer (\(h_{t-1, l}\)). Here is the exact equation for non-LSTM cells:
where \(t\), \(l\) are the indices of the timestamp and the layer of the cell being executed.
And here is the equation for LSTM cells:
where \(t\), \(l\) are the indices of the timestamp and the layer of the cell being executed.
Cell Functions#
The RNN API provides four cell functions:
Vanilla RNN, a single-gate recurrent cell,
LSTM, a four-gate long short-term memory cell,
GRU, a three-gate gated recurrent unit cell,
Linear-before-reset GRU, a three-gate recurrent unit cell with the linear layer before the reset gate.
Vanilla RNN#
A single-gate recurrent cell initialized with
dnnl::vanilla_rnn_forward::desc
or
dnnl::vanilla_rnn_forward::desc
as in the following example.
auto vanilla_rnn_desc = dnnl::vanilla_rnn_forward::desc(
aprop, activation, direction, src_layer_desc, src_iter_desc,
weights_layer_desc, weights_iter_desc, bias_desc,
dst_layer_desc, dst_iter_desc);
The Vanilla RNN cell should support the ReLU, Tanh and Sigmoid activation functions. The following equations defines the mathematical operation performed by the Vanilla RNN cell for the forward pass:
LSTM#
LSTM (or Vanilla LSTM)#
A four-gate long short-term memory recurrent cell initialized with
dnnl::lstm_forward::desc
or dnnl::lstm_backward::desc
as in the
following example.
auto lstm_desc = dnnl::lstm_forward::desc(
aprop, direction, src_layer_desc, src_iter_h_desc, src_iter_c_desc,
weights_layer_desc, weights_iter_desc, bias_desc, dst_layer_desc,
dst_iter_h_desc, dst_iter_c_desc);
Note that for all tensors with a dimension depending on the gates number, we implicitly require the order of these gates to be \(i\), \(f\), \(\tilde c\), and \(o\). The following equation gives the mathematical description of these gates and output for the forward pass:
where \(W_*\) are stored in \(\weightslayer\), \(U_*\) are stored in \(\weightsiter\) and \(B_*\) are stored in \(\bias\).
Note
In order for the dimensions to be consistent, we require \(channels(\srciterc) = channels(\dstiterc) = channels(\dstiter)\).
LSTM with Peephole#
A four-gate long short-term memory recurrent cell with peephole initialized
with dnnl::lstm_forward::desc
or dnnl::lstm_backward::desc
as in
the following example.
auto lstm_desc = dnnl::lstm_forward::desc(
aprop, direction, src_layer_desc, src_iter_h_desc, src_iter_c_desc,
weights_layer_desc, weights_iter_desc, weights_peephole_desc,
bias_desc, dst_layer_desc, dst_iter_h_desc, dst_iter_c_desc);
Similarly to vanilla LSTM, we implicitly require the order of these gates to be \(i\), \(f\), \(\tilde c\), and \(o\). For peephole weights, the gates order is:math:i, \(f\), \(o\). The following equation gives the mathematical description of these gates and output for the forward pass:
where \(P_*\) are stored in weights_peephole
, and the other parameters
are the same as in vanilla LSTM.
Note
If the weights_peephole_desc
passed to the operation descriptor
constructor is a zero memory descriptor, the primitive will behave the same
as in LSTM primitive without peephole.
LSTM with Projection#
A four-gate long short-term memory recurrent cell with projection initialized
with dnnl::lstm_forward::desc
or dnnl::lstm_backward::desc
as in
the following example.
auto lstm_desc = dnnl::lstm_forward::desc(
aprop, direction, src_layer_desc, src_iter_h_desc, src_iter_c_desc,
weights_layer_desc, weights_iter_desc, weights_peephole_desc,
weights_projection_desc, bias_desc, dst_layer_desc, dst_iter_h_desc,
dst_iter_c_desc);
Similarly to vanilla LSTM, we implicitly require the order of the gates to be i, \(f\), \(\tilde c\), and \(o\) for all tensors with a dimension depending on the gates. The following equation gives the mathematical description of these gates and output for the forward pass (for simplicity, LSTM without peephole is shown):
where \(R\) is stored in weights_projection
, and the other parameters
are the same as in vanilla LSTM.
Note
If the weights_projection_desc
passed to the operation descriptor
constructor is a zero memory descriptor, the primitive will behave the same
as in LSTM primitive without projection.
GRU#
A three-gate gated recurrent unit cell, initialized with
dnnl::gru_forward::desc
or dnnl::gru_backward::desc
as in the
following example.
auto gru_desc = dnnl::gru_forward::desc(
aprop, direction, src_layer_desc, src_iter_desc,
weights_layer_desc, weights_iter_desc, bias_desc,
dst_layer_desc, dst_iter_desc);
Note that for all tensors with a dimension depending on the gates number, we implicitly require the order of these gates to be:math:u, \(r\), and \(o\). The following equation gives the mathematical definition of these gates.
where \(W_*\) are in \(\weightslayer\), \(U_*\) are in \(\weightsiter\), and \(B_*\) are stored in \(\bias\).
Note
If you need to replace \(u_t\) by \((1-u_t)\) when computing \(h_t\), you can achieve this by multiplying \(W_u\), \(U_u\) and \(B_u\) by \(-1\). This is possible as \(u_t = \sigma(W_u \cdot h_{t,l-1} + U_u \cdot h_{t-1, l} + B_u)\), and \(1 – \sigma(a) = \sigma(-a)\).
Linear-Before-Reset GRU#
A three-gate gated recurrent unit cell with linear layer applied before the
reset gate, initialized with dnnl::lbr_gru_forward::desc
or
dnnl::lbr_gru_backward::desc
as in the following example.
auto lbr_gru_desc = dnnl::lbr_gru_forward::desc(
aprop, direction, src_layer_desc, src_iter_desc,
weights_layer_desc, weights_iter_desc, bias_desc,
dst_layer_desc, dst_iter_desc);
The following equation describes the mathematical behavior of the Linear-Before-Reset GRU cell.
Note that for all tensors with a dimension depending on the gates number, except the bias, we implicitly require the order of these gates to be \(u\), \(r\), and \(o\). For the \(\bias\) tensor, we implicitly require the order of the gates to be \(u\), \(r\), \(o\), and \(u'\).
Note
If you need to replace \(u_t\) by \((1-u_t)\) when computing \(h_t\), you can achieve this by multiplying \(W_u\), \(U_u\) and \(B_u\) by \(-1\). This is possible as \(u_t = \sigma(W_u \cdot h_{t,l-1} + U_u \cdot h_{t-1, l} + B_u)\), and \(1 – \sigma(a) = \sigma(-a)\).
Execution Arguments#
When executed, the inputs and outputs should be mapped to an execution argument index as specified by the following table.
Primitive input/output |
Execution argument index |
---|---|
\(\srclayer\) |
|
\(\srciter\) |
|
\(\srciterc\) |
|
\(\weightslayer\) |
|
\(\weightsiter\) |
|
\(\weightspeephole\) |
|
\(\weightsprojection\) |
|
\(\bias\) |
|
\(\dstlayer\) |
|
\(\dstiter\) |
|
\(\dstiterc\) |
|
\(\workspace\) |
|
\(\diffsrclayer\) |
|
\(\diffsrciter\) |
|
\(\diffsrciterc\) |
|
\(\diffweightslayer\) |
|
\(\diffweightsiter\) |
|
\(\diffweightspeephole\) |
|
\(\diffweightsprojection\) |
|
\(\diffbias\) |
|
\(\diffdstlayer\) |
|
\(\diffdstiter\) |
|
\(\diffdstiterc\) |
Operation Details#
N/A
Data Types Support#
The following table lists the combination of data types that should be supported by the RNN primitive for each input and output memory object.
Note
Here we abbreviate data types names for readability. For example, dnnl::memory::data_type::f32
is
abbreviated to f32
.
Propagation |
Cell Function |
Input Data |
Recurrent Data (1) |
Weights |
Bias |
Output Data |
Forward / Backward |
All |
|||||
Forward / Backward (2) |
All (3) |
|||||
Forward |
All (3) |
|||||
Forward inference |
Vanilla LSTM |
With LSTM and Peephole LSTM cells, the cell state data type is always f32.
In backward propagation, all
diff_*
tensors are in f32.Projection LSTM is not defined yet.
Data Representation#
In the oneDNN programming model, the RNN primitive is one of a few that
support the placeholder memory format #dnnl::memory::format_tag::any
(shortened to any
from now on) and can define data and weight memory
objects format based on the primitive parameters.
The following table summarizes the data layouts supported by the RNN primitive.
Input/Output Data |
Recurrent Data |
Layer and Iteration Weights |
Peephole Weights and Bias |
Projection LSTM Weights |
While an RNN primitive can be created with memory formats specified
explicitly, the performance is likely to be sub-optimal. When using any
it
is necessary to first create an RNN primitive descriptor and then query it for
the actual data and weight memory objects formats.
Note
The RNN primitive should support padded tensors and views. So even if two memory descriptors share the same data layout, they might still be different.
Post-ops and Attributes#
Currently post-ops and attributes are only used by the int8 variant of LSTM.
API#
-
enum class dnnl::rnn_flags : unsigned#
RNN cell flags.
Values:
-
enumerator undef#
Undefined RNN flags.
-
enumerator undef#
-
enum class dnnl::rnn_direction#
A direction of RNN primitive execution.
Values:
-
enumerator unidirectional_left2right#
Unidirectional execution of RNN primitive from left to right.
-
enumerator unidirectional_right2left#
Unidirectional execution of RNN primitive from right to left.
-
enumerator bidirectional_concat#
Bidirectional execution of RNN primitive with concatenation of the results.
-
enumerator bidirectional_sum#
Bidirectional execution of RNN primitive with summation of the results.
-
enumerator unidirectional#
-
enumerator unidirectional_left2right#
-
struct vanilla_rnn_forward : public dnnl::primitive#
Vanilla RNN forward propagation primitive.
Public Functions
-
vanilla_rnn_forward()#
Default constructor. Produces an empty object.
-
vanilla_rnn_forward(const primitive_desc &pd)#
Constructs a vanilla RNN forward propagation primitive.
- Parameters
pd – Primitive descriptor for a vanilla RNN forward propagation primitive.
-
struct desc#
Descriptor for a vanilla RNN forward propagation primitive.
Public Functions
-
desc(prop_kind aprop_kind, algorithm activation, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, rnn_flags flags = rnn_flags::undef, float alpha = 0.0f, float beta = 0.0f)#
Constructs a descriptor for a vanilla RNN forward propagation primitive.
The following arguments may point to a zero memory descriptor:
src_iter_desc
,bias_desc
,dst_iter_desc
.
This would then indicate that the RNN forward propagation primitive should not use them and should default to zero values instead.
Note
All memory descriptors except
src_iter_desc
can be initialized with an dnnl::memory::format_tag::any value offormat_tag
.- Parameters
aprop_kind – Propagation kind. Possible values are dnnl::prop_kind::forward_training, and dnnl::prop_kind::forward_inference.
activation – Activation kind. Possible values are dnnl::algorithm::eltwise_relu, dnnl::algorithm::eltwise_tanh, or dnnl::algorithm::eltwise_logistic.
direction – RNN direction. See dnnl::rnn_direction for more info.
src_layer_desc – Memory descriptor for the input vector.
src_iter_desc – Memory descriptor for the input recurrent hidden state vector.
weights_layer_desc – Memory descriptor for the weights applied to the layer input.
weights_iter_desc – Memory descriptor for the weights applied to the recurrent input.
bias_desc – Bias memory descriptor.
dst_layer_desc – Memory descriptor for the output vector.
dst_iter_desc – Memory descriptor for the output recurrent hidden state vector.
flags – Unused.
alpha – Negative slope if activation is dnnl::algorithm::eltwise_relu.
beta – Unused.
-
desc(prop_kind aprop_kind, algorithm activation, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, rnn_flags flags = rnn_flags::undef, float alpha = 0.0f, float beta = 0.0f)#
-
struct primitive_desc : public dnnl::rnn_primitive_desc_base#
Primitive descriptor for a vanilla RNN forward propagation primitive.
Public Functions
-
primitive_desc()#
Default constructor. Produces an empty object.
-
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty = false)#
Constructs a primitive descriptor for a vanilla RNN forward propagation primitive.
- Parameters
adesc – Descriptor for a vanilla RNN forward propagation primitive.
aengine – Engine to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty = false)#
Constructs a primitive descriptor for a vanilla RNN forward propagation primitive.
- Parameters
adesc – Descriptor for a vanilla RNN forward propagation primitive.
attr – Primitive attributes to use.
aengine – Engine to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
memory::desc src_layer_desc() const#
Returns source layer memory descriptor.
- Returns
Source layer memory descriptor.
-
memory::desc src_iter_desc() const#
Returns source iteration memory descriptor.
- Returns
Source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a source iteration parameter.
-
memory::desc weights_layer_desc() const#
Returns weights layer memory descriptor.
- Returns
Weights layer memory descriptor.
-
memory::desc weights_iter_desc() const#
Returns weights iteration memory descriptor.
- Returns
Weights iteration memory descriptor.
-
memory::desc bias_desc() const#
Returns bias memory descriptor.
- Returns
Bias memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a bias parameter.
-
memory::desc dst_layer_desc() const#
Returns destination layer memory descriptor.
- Returns
Destination layer memory descriptor.
-
primitive_desc()#
-
vanilla_rnn_forward()#
-
struct vanilla_rnn_backward : public dnnl::primitive#
Vanilla RNN backward propagation primitive.
Public Functions
-
vanilla_rnn_backward()#
Default constructor. Produces an empty object.
-
vanilla_rnn_backward(const primitive_desc &pd)#
Constructs a vanilla RNN backward propagation primitive.
- Parameters
pd – Primitive descriptor for a vanilla RNN backward propagation primitive.
-
struct desc#
Descriptor for a vanilla RNN backward propagation primitive.
Public Functions
-
desc(prop_kind aprop_kind, algorithm activation, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, rnn_flags flags = rnn_flags::undef, float alpha = 0.0f, float beta = 0.0f)#
Constructs a descriptor for a vanilla RNN backward propagation primitive.
The following arguments may point to a zero memory descriptor:
src_iter_desc
together withdiff_src_iter_desc
,bias_desc
together withdiff_bias_desc
,dst_iter_desc
together withdiff_dst_iter_desc
.
This would then indicate that the RNN backward propagation primitive should not use the respective data and should use zero values instead.
Note
All the memory descriptors may be initialized with the dnnl::memory::format_tag::any value of
format_tag
.- Parameters
aprop_kind – Propagation kind. Must be dnnl::prop_kind::backward.
activation – Activation kind. Possible values are dnnl::algorithm::eltwise_relu, dnnl::algorithm::eltwise_tanh, or dnnl::algorithm::eltwise_logistic.
direction – RNN direction. See dnnl::rnn_direction for more info.
src_layer_desc – Memory descriptor for the input vector.
src_iter_desc – Memory descriptor for the input recurrent hidden state vector.
weights_layer_desc – Memory descriptor for the weights applied to the layer input.
weights_iter_desc – Memory descriptor for the weights applied to the recurrent input.
bias_desc – Bias memory descriptor.
dst_layer_desc – Memory descriptor for the output vector.
dst_iter_desc – Memory descriptor for the output recurrent hidden state vector.
diff_src_layer_desc – Memory descriptor for the diff of input vector.
diff_src_iter_desc – Memory descriptor for the diff of input recurrent hidden state vector.
diff_weights_layer_desc – Memory descriptor for the diff of weights applied to the layer input.
diff_weights_iter_desc – Memory descriptor for the diff of weights applied to the recurrent input.
diff_bias_desc – Diff bias memory descriptor.
diff_dst_layer_desc – Memory descriptor for the diff of output vector.
diff_dst_iter_desc – Memory descriptor for the diff of output recurrent hidden state vector.
flags – Unused.
alpha – Negative slope if activation is dnnl::algorithm::eltwise_relu.
beta – Unused.
-
desc(prop_kind aprop_kind, algorithm activation, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, rnn_flags flags = rnn_flags::undef, float alpha = 0.0f, float beta = 0.0f)#
-
struct primitive_desc : public dnnl::rnn_primitive_desc_base#
Primitive descriptor for an RNN backward propagation primitive.
Public Functions
-
primitive_desc()#
Default constructor. Produces an empty object.
-
primitive_desc(const desc &adesc, const engine &aengine, const vanilla_rnn_forward::primitive_desc &hint_fwd_pd, bool allow_empty = false)#
Constructs a primitive descriptor for a vanilla RNN backward propagation primitive.
- Parameters
adesc – Descriptor for a vanilla RNN backward propagation primitive.
aengine – Engine to use.
hint_fwd_pd – Primitive descriptor for a vanilla RNN forward propagation primitive. It is used as a hint for deciding which memory format to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const vanilla_rnn_forward::primitive_desc &hint_fwd_pd, bool allow_empty = false)#
Constructs a primitive descriptor for a vanilla RNN backward propagation primitive.
- Parameters
adesc – Descriptor for a vanilla RNN backward propagation primitive.
attr – Primitive attributes to use.
aengine – Engine to use.
hint_fwd_pd – Primitive descriptor for a vanilla RNN forward propagation primitive. It is used as a hint for deciding which memory format to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
memory::desc src_layer_desc() const#
Returns source layer memory descriptor.
- Returns
Source layer memory descriptor.
-
memory::desc src_iter_desc() const#
Returns source iteration memory descriptor.
- Returns
Source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a source iteration parameter.
-
memory::desc weights_layer_desc() const#
Returns weights layer memory descriptor.
- Returns
Weights layer memory descriptor.
-
memory::desc weights_iter_desc() const#
Returns weights iteration memory descriptor.
- Returns
Weights iteration memory descriptor.
-
memory::desc bias_desc() const#
Returns bias memory descriptor.
- Returns
Bias memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a bias parameter.
-
memory::desc dst_layer_desc() const#
Returns destination layer memory descriptor.
- Returns
Destination layer memory descriptor.
-
memory::desc dst_iter_desc() const#
Returns destination iteration memory descriptor.
- Returns
Destination iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a destination iteration parameter.
-
memory::desc workspace_desc() const#
Returns the workspace memory descriptor.
- Returns
Workspace memory descriptor.
- Returns
A zero memory descriptor if the primitive does not require workspace parameter.
-
memory::desc diff_src_layer_desc() const#
Returns diff source layer memory descriptor.
- Returns
Diff source layer memory descriptor.
-
memory::desc diff_src_iter_desc() const#
Returns diff source iteration memory descriptor.
- Returns
Diff source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a diff source iteration parameter.
-
memory::desc diff_weights_layer_desc() const#
Returns diff weights layer memory descriptor.
- Returns
Diff weights layer memory descriptor.
-
memory::desc diff_weights_iter_desc() const#
Returns diff weights iteration memory descriptor.
- Returns
Diff weights iteration memory descriptor.
-
memory::desc diff_bias_desc() const#
Returns diff bias memory descriptor.
- Returns
Diff bias memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a diff bias parameter.
-
primitive_desc()#
-
vanilla_rnn_backward()#
-
struct lstm_forward : public dnnl::primitive#
LSTM forward propagation primitive.
Public Functions
-
lstm_forward()#
Default constructor. Produces an empty object.
-
lstm_forward(const primitive_desc &pd)#
Constructs an LSTM forward propagation primitive.
- Parameters
pd – Primitive descriptor for an LSTM forward propagation primitive.
-
struct desc#
Descriptor for an LSTM forward propagation primitive.
Public Functions
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &weights_peephole_desc, const memory::desc &weights_projection_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, rnn_flags flags = rnn_flags::undef)#
Constructs a descriptor for an LSTM (with or without peephole and with or without projection) forward propagation primitive.
The following arguments may point to a zero memory descriptor:
src_iter_desc
together withsrc_iter_c_desc
,weights_peephole_desc
,bias_desc
,dst_iter_desc
together withdst_iter_c_desc
.
This would then indicate that the LSTM forward propagation primitive should not use them and should default to zero values instead.
The
weights_projection_desc
may point to a zero memory descriptor. This would then indicate that the LSTM doesn’t have recurrent projection layer.Note
All memory descriptors can be initialized with an dnnl::memory::format_tag::any value of
format_tag
.- Parameters
aprop_kind – Propagation kind. Possible values are dnnl::prop_kind::forward_training, and dnnl::prop_kind::forward_inference.
direction – RNN direction. See dnnl::rnn_direction for more info.
src_layer_desc – Memory descriptor for the input vector.
src_iter_desc – Memory descriptor for the input recurrent hidden state vector.
src_iter_c_desc – Memory descriptor for the input recurrent cell state vector.
weights_layer_desc – Memory descriptor for the weights applied to the layer input.
weights_iter_desc – Memory descriptor for the weights applied to the recurrent input.
weights_peephole_desc – Memory descriptor for the weights applied to the cell states (according to the Peephole LSTM formula).
weights_projection_desc – Memory descriptor for the weights applied to the hidden states to get the recurrent projection (according to the Projection LSTM formula).
bias_desc – Bias memory descriptor.
dst_layer_desc – Memory descriptor for the output vector.
dst_iter_desc – Memory descriptor for the output recurrent hidden state vector.
dst_iter_c_desc – Memory descriptor for the output recurrent cell state vector.
flags – Unused.
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &weights_peephole_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, rnn_flags flags = rnn_flags::undef)#
Constructs a descriptor for an LSTM (with or without peephole) forward propagation primitive.
The following arguments may point to a zero memory descriptor:
src_iter_desc
together withsrc_iter_c_desc
,weights_peephole_desc
,bias_desc
,dst_iter_desc
together withdst_iter_c_desc
.
This would then indicate that the LSTM forward propagation primitive should not use them and should default to zero values instead.
Note
All memory descriptors can be initialized with an dnnl::memory::format_tag::any value of
format_tag
.- Parameters
aprop_kind – Propagation kind. Possible values are dnnl::prop_kind::forward_training, and dnnl::prop_kind::forward_inference.
direction – RNN direction. See dnnl::rnn_direction for more info.
src_layer_desc – Memory descriptor for the input vector.
src_iter_desc – Memory descriptor for the input recurrent hidden state vector.
src_iter_c_desc – Memory descriptor for the input recurrent cell state vector.
weights_layer_desc – Memory descriptor for the weights applied to the layer input.
weights_iter_desc – Memory descriptor for the weights applied to the recurrent input.
weights_peephole_desc – Memory descriptor for the weights applied to the cell states (according to the Peephole LSTM formula).
bias_desc – Bias memory descriptor.
dst_layer_desc – Memory descriptor for the output vector.
dst_iter_desc – Memory descriptor for the output recurrent hidden state vector.
dst_iter_c_desc – Memory descriptor for the output recurrent cell state vector.
flags – Unused.
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, rnn_flags flags = rnn_flags::undef)#
Constructs a descriptor for an LSTM forward propagation primitive.
The following arguments may point to a zero memory descriptor:
src_iter_desc
together withsrc_iter_c_desc
,bias_desc
,dst_iter_desc
together withdst_iter_c_desc
.
This would then indicate that the LSTM forward propagation primitive should not use them and should default to zero values instead.
Note
All memory descriptors can be initialized with an dnnl::memory::format_tag::any value of
format_tag
.- Parameters
aprop_kind – Propagation kind. Possible values are dnnl::prop_kind::forward_training, and dnnl::prop_kind::forward_inference.
direction – RNN direction. See dnnl::rnn_direction for more info.
src_layer_desc – Memory descriptor for the input vector.
src_iter_desc – Memory descriptor for the input recurrent hidden state vector.
src_iter_c_desc – Memory descriptor for the input recurrent cell state vector.
weights_layer_desc – Memory descriptor for the weights applied to the layer input.
weights_iter_desc – Memory descriptor for the weights applied to the recurrent input.
bias_desc – Bias memory descriptor.
dst_layer_desc – Memory descriptor for the output vector.
dst_iter_desc – Memory descriptor for the output recurrent hidden state vector.
dst_iter_c_desc – Memory descriptor for the output recurrent cell state vector.
flags – Unused.
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &weights_peephole_desc, const memory::desc &weights_projection_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, rnn_flags flags = rnn_flags::undef)#
-
struct primitive_desc : public dnnl::rnn_primitive_desc_base#
Primitive descriptor for an LSTM forward propagation primitive.
Public Functions
-
primitive_desc()#
Default constructor. Produces an empty object.
-
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty = false)#
Constructs a primitive descriptor for an LSTM forward propagation primitive.
- Parameters
adesc – Descriptor for an LSTM forward propagation primitive.
aengine – Engine to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty = false)#
Constructs a primitive descriptor for an LSTM forward propagation primitive.
- Parameters
adesc – Descriptor for an LSTM forward propagation primitive.
attr – Primitive attributes to use.
aengine – Engine to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
memory::desc src_layer_desc() const#
Returns source layer memory descriptor.
- Returns
Source layer memory descriptor.
-
memory::desc src_iter_desc() const#
Returns source iteration memory descriptor.
- Returns
Source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a source iteration parameter.
-
memory::desc src_iter_c_desc() const#
Returns source iteration memory descriptor.
- Returns
Source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a source iteration parameter.
-
memory::desc weights_layer_desc() const#
Returns weights layer memory descriptor.
- Returns
Weights layer memory descriptor.
-
memory::desc weights_iter_desc() const#
Returns weights iteration memory descriptor.
- Returns
Weights iteration memory descriptor.
-
memory::desc weights_peephole_desc() const#
Returns weights peephole memory descriptor.
- Returns
Weights peephole memory descriptor.
-
memory::desc weights_projection_desc() const#
Returns weights projection memory descriptor.
- Returns
Weights projection memory descriptor.
-
memory::desc bias_desc() const#
Returns bias memory descriptor.
- Returns
Bias memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a bias parameter.
-
memory::desc dst_layer_desc() const#
Returns destination layer memory descriptor.
- Returns
Destination layer memory descriptor.
-
memory::desc dst_iter_desc() const#
Returns destination iteration memory descriptor.
- Returns
Destination iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a destination iteration parameter.
-
primitive_desc()#
-
lstm_forward()#
-
struct lstm_backward : public dnnl::primitive#
LSTM backward propagation primitive.
Public Functions
-
lstm_backward()#
Default constructor. Produces an empty object.
-
lstm_backward(const primitive_desc &pd)#
Constructs an LSTM backward propagation primitive.
- Parameters
pd – Primitive descriptor for an LSTM backward propagation primitive.
-
struct desc#
Descriptor for an LSTM backward propagation primitive.
Public Functions
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &weights_peephole_desc, const memory::desc &weights_projection_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_src_iter_c_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_weights_peephole_desc, const memory::desc &diff_weights_projection_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, const memory::desc &diff_dst_iter_c_desc, rnn_flags flags = rnn_flags::undef)#
projection) descriptor for backward propagation using
prop_kind
,direction
, and memory descriptors.The following arguments may point to a zero memory descriptor:
src_iter_desc
together withsrc_iter_c_desc
,diff_src_iter_desc
, anddiff_src_iter_c_desc
,weights_peephole_desc
together withdiff_weights_peephole_desc
bias_desc
together withdiff_bias_desc
,dst_iter_desc
together withdst_iter_c_desc
,diff_dst_iter_desc
, anddiff_dst_iter_c_desc
.
This would then indicate that the LSTM backward propagation primitive should not use them and should default to zero values instead.
The
weights_projection_desc
together withdiff_weights_projection_desc
may point to a zero memory descriptor. This would then indicate that the LSTM doesn’t have recurrent projection layer.Note
All memory descriptors can be initialized with dnnl::memory::format_tag::any value of
format_tag
.- Parameters
aprop_kind – Propagation kind. Must be dnnl::prop_kind::backward.
direction – RNN direction. See dnnl::rnn_direction for more info.
src_layer_desc – Memory descriptor for the input vector.
src_iter_desc – Memory descriptor for the input recurrent hidden state vector.
src_iter_c_desc – Memory descriptor for the input recurrent cell state vector.
weights_layer_desc – Memory descriptor for the weights applied to the layer input.
weights_iter_desc – Memory descriptor for the weights applied to the recurrent input.
weights_peephole_desc – Memory descriptor for the weights applied to the cell states (according to the Peephole LSTM formula).
weights_projection_desc – Memory descriptor for the weights applied to the hidden states to get the recurrent projection (according to the Projection LSTM formula).
bias_desc – Bias memory descriptor.
dst_layer_desc – Memory descriptor for the output vector.
dst_iter_desc – Memory descriptor for the output recurrent hidden state vector.
dst_iter_c_desc – Memory descriptor for the output recurrent cell state vector.
diff_src_layer_desc – Memory descriptor for the diff of input vector.
diff_src_iter_desc – Memory descriptor for the diff of input recurrent hidden state vector.
diff_src_iter_c_desc – Memory descriptor for the diff of input recurrent cell state vector.
diff_weights_layer_desc – Memory descriptor for the diff of weights applied to the layer input.
diff_weights_iter_desc – Memory descriptor for the diff of weights applied to the recurrent input.
diff_weights_peephole_desc – Memory descriptor for the diff of weights applied to the cell states (according to the Peephole LSTM formula).
diff_weights_projection_desc – Memory descriptor for the diff of weights applied to the hidden states to get the recurrent projection (according to the Projection LSTM formula).
diff_bias_desc – Diff bias memory descriptor.
diff_dst_layer_desc – Memory descriptor for the diff of output vector.
diff_dst_iter_desc – Memory descriptor for the diff of output recurrent hidden state vector.
diff_dst_iter_c_desc – Memory descriptor for the diff of output recurrent cell state vector.
flags – Unused.
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &weights_peephole_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_src_iter_c_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_weights_peephole_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, const memory::desc &diff_dst_iter_c_desc, rnn_flags flags = rnn_flags::undef)#
Constructs an LSTM (with or without peephole) descriptor for backward propagation using
prop_kind
,direction
, and memory descriptors.The following arguments may point to a zero memory descriptor:
src_iter_desc
together withsrc_iter_c_desc
,diff_src_iter_desc
, anddiff_src_iter_c_desc
,weights_peephole_desc
together withdiff_weights_peephole_desc
bias_desc
together withdiff_bias_desc
,dst_iter_desc
together withdst_iter_c_desc
,diff_dst_iter_desc
, anddiff_dst_iter_c_desc
.
This would then indicate that the LSTM backward propagation primitive should not use them and should default to zero values instead.
Note
All memory descriptors may be initialized with dnnl::memory::format_tag::any value of
format_tag
.- Parameters
aprop_kind – Propagation kind. Must be dnnl::prop_kind::backward.
direction – RNN direction. See dnnl::rnn_direction for more info.
src_layer_desc – Memory descriptor for the input vector.
src_iter_desc – Memory descriptor for the input recurrent hidden state vector.
src_iter_c_desc – Memory descriptor for the input recurrent cell state vector.
weights_layer_desc – Memory descriptor for the weights applied to the layer input.
weights_iter_desc – Memory descriptor for the weights applied to the recurrent input.
weights_peephole_desc – Memory descriptor for the weights applied to the cell states (according to the Peephole LSTM formula).
bias_desc – Bias memory descriptor.
dst_layer_desc – Memory descriptor for the output vector.
dst_iter_desc – Memory descriptor for the output recurrent hidden state vector.
dst_iter_c_desc – Memory descriptor for the output recurrent cell state vector.
diff_src_layer_desc – Memory descriptor for the diff of input vector.
diff_src_iter_desc – Memory descriptor for the diff of input recurrent hidden state vector.
diff_src_iter_c_desc – Memory descriptor for the diff of input recurrent cell state vector.
diff_weights_layer_desc – Memory descriptor for the diff of weights applied to the layer input.
diff_weights_iter_desc – Memory descriptor for the diff of weights applied to the recurrent input.
diff_weights_peephole_desc – Memory descriptor for the diff of weights applied to the cell states (according to the Peephole LSTM formula).
diff_bias_desc – Diff bias memory descriptor.
diff_dst_layer_desc – Memory descriptor for the diff of output vector.
diff_dst_iter_desc – Memory descriptor for the diff of output recurrent hidden state vector.
diff_dst_iter_c_desc – Memory descriptor for the diff of output recurrent cell state vector.
flags – Unused.
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_src_iter_c_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, const memory::desc &diff_dst_iter_c_desc, rnn_flags flags = rnn_flags::undef)#
Constructs an LSTM descriptor for backward propagation using
prop_kind
,direction
, and memory descriptors.The following arguments may point to a zero memory descriptor:
src_iter_desc
together withsrc_iter_c_desc
,diff_src_iter_desc
, anddiff_src_iter_c_desc
,bias_desc
together withdiff_bias_desc
,dst_iter_desc
together withdst_iter_c_desc
,diff_dst_iter_desc
, anddiff_dst_iter_c_desc
.
This would then indicate that the LSTM backward propagation primitive should not use them and should default to zero values instead.
Note
All memory descriptors may be initialized with dnnl::memory::format_tag::any value of
format_tag
.- Parameters
aprop_kind – Propagation kind. Must be dnnl::prop_kind::backward.
direction – RNN direction. See dnnl::rnn_direction for more info.
src_layer_desc – Memory descriptor for the input vector.
src_iter_desc – Memory descriptor for the input recurrent hidden state vector.
src_iter_c_desc – Memory descriptor for the input recurrent cell state vector.
weights_layer_desc – Memory descriptor for the weights applied to the layer input.
weights_iter_desc – Memory descriptor for the weights applied to the recurrent input.
bias_desc – Bias memory descriptor.
dst_layer_desc – Memory descriptor for the output vector.
dst_iter_desc – Memory descriptor for the output recurrent hidden state vector.
dst_iter_c_desc – Memory descriptor for the output recurrent cell state vector.
diff_src_layer_desc – Memory descriptor for the diff of input vector.
diff_src_iter_desc – Memory descriptor for the diff of input recurrent hidden state vector.
diff_src_iter_c_desc – Memory descriptor for the diff of input recurrent cell state vector.
diff_weights_layer_desc – Memory descriptor for the diff of weights applied to the layer input.
diff_weights_iter_desc – Memory descriptor for the diff of weights applied to the recurrent input.
diff_bias_desc – Diff bias memory descriptor.
diff_dst_layer_desc – Memory descriptor for the diff of output vector.
diff_dst_iter_desc – Memory descriptor for the diff of output recurrent hidden state vector.
diff_dst_iter_c_desc – Memory descriptor for the diff of output recurrent cell state vector.
flags – Unused.
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &weights_peephole_desc, const memory::desc &weights_projection_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_src_iter_c_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_weights_peephole_desc, const memory::desc &diff_weights_projection_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, const memory::desc &diff_dst_iter_c_desc, rnn_flags flags = rnn_flags::undef)#
-
struct primitive_desc : public dnnl::rnn_primitive_desc_base#
Primitive descriptor for LSTM backward propagation.
Public Functions
-
primitive_desc()#
Default constructor. Produces an empty object.
-
primitive_desc(const desc &adesc, const engine &aengine, const lstm_forward::primitive_desc &hint_fwd_pd, bool allow_empty = false)#
Constructs a primitive descriptor for an LSTM backward propagation primitive.
- Parameters
adesc – Descriptor for LSTM backward propagation primitive.
aengine – Engine to use.
hint_fwd_pd – Primitive descriptor for an LSTM forward propagation primitive. It is used as a hint for deciding which memory format to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const lstm_forward::primitive_desc &hint_fwd_pd, bool allow_empty = false)#
Constructs a primitive descriptor for an LSTM backward propagation primitive.
- Parameters
adesc – Descriptor for an LSTM backward propagation primitive.
attr – Primitive attributes to use.
aengine – Engine to use.
hint_fwd_pd – Primitive descriptor for an LSTM forward propagation primitive. It is used as a hint for deciding which memory format to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
memory::desc src_layer_desc() const#
Returns source layer memory descriptor.
- Returns
Source layer memory descriptor.
-
memory::desc src_iter_desc() const#
Returns source iteration memory descriptor.
- Returns
Source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a source iteration parameter.
-
memory::desc src_iter_c_desc() const#
Returns source iteration memory descriptor.
- Returns
Source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a source iteration parameter.
-
memory::desc weights_layer_desc() const#
Returns weights layer memory descriptor.
- Returns
Weights layer memory descriptor.
-
memory::desc weights_iter_desc() const#
Returns weights iteration memory descriptor.
- Returns
Weights iteration memory descriptor.
-
memory::desc weights_peephole_desc() const#
Returns weights peephole memory descriptor.
- Returns
Weights peephole memory descriptor.
-
memory::desc weights_projection_desc() const#
Returns weights projection memory descriptor.
- Returns
Weights projection memory descriptor.
-
memory::desc bias_desc() const#
Returns bias memory descriptor.
- Returns
Bias memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a bias parameter.
-
memory::desc dst_layer_desc() const#
Returns destination layer memory descriptor.
- Returns
Destination layer memory descriptor.
-
memory::desc dst_iter_desc() const#
Returns destination iteration memory descriptor.
- Returns
Destination iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a destination iteration parameter.
-
memory::desc dst_iter_c_desc() const#
Returns source iteration memory descriptor.
- Returns
Source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a source iteration parameter.
-
memory::desc workspace_desc() const#
Returns the workspace memory descriptor.
- Returns
Workspace memory descriptor.
- Returns
A zero memory descriptor if the primitive does not require workspace parameter.
-
memory::desc diff_src_layer_desc() const#
Returns diff source layer memory descriptor.
- Returns
Diff source layer memory descriptor.
-
memory::desc diff_src_iter_desc() const#
Returns diff source iteration memory descriptor.
- Returns
Diff source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a diff source iteration parameter.
-
memory::desc diff_src_iter_c_desc() const#
Returns diff source recurrent cell state memory descriptor.
- Returns
Diff source recurrent cell state memory descriptor.
-
memory::desc diff_weights_layer_desc() const#
Returns diff weights layer memory descriptor.
- Returns
Diff weights layer memory descriptor.
-
memory::desc diff_weights_iter_desc() const#
Returns diff weights iteration memory descriptor.
- Returns
Diff weights iteration memory descriptor.
-
memory::desc diff_weights_peephole_desc() const#
Returns diff weights peephole memory descriptor.
- Returns
Diff weights peephole memory descriptor.
-
memory::desc diff_weights_projection_desc() const#
Returns diff weights projection memory descriptor.
- Returns
Diff weights projection memory descriptor.
-
memory::desc diff_bias_desc() const#
Returns diff bias memory descriptor.
- Returns
Diff bias memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a diff bias parameter.
-
memory::desc diff_dst_layer_desc() const#
Returns diff destination layer memory descriptor.
- Returns
Diff destination layer memory descriptor.
-
primitive_desc()#
-
lstm_backward()#
-
struct gru_forward : public dnnl::primitive#
GRU forward propagation primitive.
Public Functions
-
gru_forward()#
Default constructor. Produces an empty object.
-
gru_forward(const primitive_desc &pd)#
Constructs a GRU forward propagation primitive.
- Parameters
pd – Primitive descriptor for a GRU forward propagation primitive.
-
struct desc#
Descriptor for a GRU forward propagation primitive.
Public Functions
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, rnn_flags flags = rnn_flags::undef)#
Constructs a descriptor for a GRU forward propagation primitive.
The following arguments may point to a zero memory descriptor:
src_iter_desc
,bias_desc
,dst_iter_desc
.
This would then indicate that the GRU forward propagation primitive should not use them and should default to zero values instead.
Note
All memory descriptors except
src_iter_desc
may be initialized with an dnnl::memory::format_tag::any value offormat_tag
.- Parameters
aprop_kind – Propagation kind. Possible values are dnnl::prop_kind::forward_training, and dnnl::prop_kind::forward_inference.
direction – RNN direction. See dnnl::rnn_direction for more info.
src_layer_desc – Memory descriptor for the input vector.
src_iter_desc – Memory descriptor for the input recurrent hidden state vector.
weights_layer_desc – Memory descriptor for the weights applied to the layer input.
weights_iter_desc – Memory descriptor for the weights applied to the recurrent input.
bias_desc – Bias memory descriptor.
dst_layer_desc – Memory descriptor for the output vector.
dst_iter_desc – Memory descriptor for the output recurrent hidden state vector.
flags – Unused.
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, rnn_flags flags = rnn_flags::undef)#
-
struct primitive_desc : public dnnl::rnn_primitive_desc_base#
Primitive descriptor GRU forward propagation primitive.
Public Functions
-
primitive_desc()#
Default constructor. Produces an empty object.
-
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty = false)#
Constructs a primitive descriptor for a GRU forward propagation primitive.
- Parameters
adesc – Descriptor for a GRU forward propagation primitive.
aengine – Engine to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty = false)#
Constructs a primitive descriptor for a GRU forward propagation primitive.
- Parameters
adesc – Descriptor for a GRU forward propagation primitive.
attr – Primitive attributes to use.
aengine – Engine to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
memory::desc src_layer_desc() const#
Returns source layer memory descriptor.
- Returns
Source layer memory descriptor.
-
memory::desc src_iter_desc() const#
Returns source iteration memory descriptor.
- Returns
Source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a source iteration parameter.
-
memory::desc weights_layer_desc() const#
Returns weights layer memory descriptor.
- Returns
Weights layer memory descriptor.
-
memory::desc weights_iter_desc() const#
Returns weights iteration memory descriptor.
- Returns
Weights iteration memory descriptor.
-
memory::desc bias_desc() const#
Returns bias memory descriptor.
- Returns
Bias memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a bias parameter.
-
memory::desc dst_layer_desc() const#
Returns destination layer memory descriptor.
- Returns
Destination layer memory descriptor.
-
primitive_desc()#
-
gru_forward()#
-
struct gru_backward : public dnnl::primitive#
GRU backward propagation primitive.
Public Functions
-
gru_backward()#
Default constructor. Produces an empty object.
-
gru_backward(const primitive_desc &pd)#
Constructs a GRU backward propagation primitive.
- Parameters
pd – Primitive descriptor for a GRU backward propagation primitive.
-
struct desc#
Descriptor for a GRU backward propagation primitive.
Public Functions
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, rnn_flags flags = rnn_flags::undef)#
Constructs a descriptor for a GRU backward propagation primitive.
The following arguments may point to a zero memory descriptor:
src_iter_desc
together withdiff_src_iter_desc
,bias_desc
together withdiff_bias_desc
,dst_iter_desc
together withdiff_dst_iter_desc
.
This would then indicate that the GRU backward propagation primitive should not use them and should default to zero values instead.
Note
All memory descriptors may be initialized with dnnl::memory::format_tag::any value of
format_tag
.- Parameters
aprop_kind – Propagation kind. Must be dnnl::prop_kind::backward.
direction – RNN direction. See dnnl::rnn_direction for more info.
src_layer_desc – Memory descriptor for the input vector.
src_iter_desc – Memory descriptor for the input recurrent hidden state vector.
weights_layer_desc – Memory descriptor for the weights applied to the layer input.
weights_iter_desc – Memory descriptor for the weights applied to the recurrent input.
bias_desc – Bias memory descriptor.
dst_layer_desc – Memory descriptor for the output vector.
dst_iter_desc – Memory descriptor for the output recurrent hidden state vector.
diff_src_layer_desc – Memory descriptor for the diff of input vector.
diff_src_iter_desc – Memory descriptor for the diff of input recurrent hidden state vector.
diff_weights_layer_desc – Memory descriptor for the diff of weights applied to the layer input.
diff_weights_iter_desc – Memory descriptor for the diff of weights applied to the recurrent input.
diff_bias_desc – Diff bias memory descriptor.
diff_dst_layer_desc – Memory descriptor for the diff of output vector.
diff_dst_iter_desc – Memory descriptor for the diff of output recurrent hidden state vector.
flags – Unused.
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, rnn_flags flags = rnn_flags::undef)#
-
struct primitive_desc : public dnnl::rnn_primitive_desc_base#
Primitive descriptor for a GRU backward propagation primitive.
Public Functions
-
primitive_desc()#
Default constructor. Produces an empty object.
-
primitive_desc(const desc &adesc, const engine &aengine, const gru_forward::primitive_desc &hint_fwd_pd, bool allow_empty = false)#
Constructs a primitive descriptor for a GRU backward propagation primitive.
- Parameters
adesc – Descriptor for a GRU backward propagation primitive.
aengine – Engine to use.
hint_fwd_pd – Primitive descriptor for a GRU forward propagation primitive. It is used as a hint for deciding which memory format to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const gru_forward::primitive_desc &hint_fwd_pd, bool allow_empty = false)#
Constructs a primitive descriptor for a GRU backward propagation primitive.
- Parameters
adesc – Descriptor for a GRU backward propagation primitive.
attr – Primitive attributes to use.
aengine – Engine to use.
hint_fwd_pd – Primitive descriptor for a GRU forward propagation primitive. It is used as a hint for deciding which memory format to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
memory::desc src_layer_desc() const#
Returns source layer memory descriptor.
- Returns
Source layer memory descriptor.
-
memory::desc src_iter_desc() const#
Returns source iteration memory descriptor.
- Returns
Source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a source iteration parameter.
-
memory::desc weights_layer_desc() const#
Returns weights layer memory descriptor.
- Returns
Weights layer memory descriptor.
-
memory::desc weights_iter_desc() const#
Returns weights iteration memory descriptor.
- Returns
Weights iteration memory descriptor.
-
memory::desc bias_desc() const#
Returns bias memory descriptor.
- Returns
Bias memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a bias parameter.
-
memory::desc dst_layer_desc() const#
Returns destination layer memory descriptor.
- Returns
Destination layer memory descriptor.
-
memory::desc dst_iter_desc() const#
Returns destination iteration memory descriptor.
- Returns
Destination iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a destination iteration parameter.
-
memory::desc workspace_desc() const#
Returns the workspace memory descriptor.
- Returns
Workspace memory descriptor.
- Returns
A zero memory descriptor if the primitive does not require workspace parameter.
-
memory::desc diff_src_layer_desc() const#
Returns diff source layer memory descriptor.
- Returns
Diff source layer memory descriptor.
-
memory::desc diff_src_iter_desc() const#
Returns diff source iteration memory descriptor.
- Returns
Diff source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a diff source iteration parameter.
-
memory::desc diff_weights_layer_desc() const#
Returns diff weights layer memory descriptor.
- Returns
Diff weights layer memory descriptor.
-
memory::desc diff_weights_iter_desc() const#
Returns diff weights iteration memory descriptor.
- Returns
Diff weights iteration memory descriptor.
-
memory::desc diff_bias_desc() const#
Returns diff bias memory descriptor.
- Returns
Diff bias memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a diff bias parameter.
-
primitive_desc()#
-
gru_backward()#
-
struct lbr_gru_forward : public dnnl::primitive#
LBR GRU forward propagation primitive.
Public Functions
-
lbr_gru_forward()#
Default constructor. Produces an empty object.
-
lbr_gru_forward(const primitive_desc &pd)#
Constructs an LBR GRU forward propagation primitive.
- Parameters
pd – Primitive descriptor for an LBR GRU forward propagation primitive.
-
struct desc#
Descriptor for an LBR GRU forward propagation primitive.
Public Functions
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, rnn_flags flags = rnn_flags::undef)#
Constructs a descriptor for LBR GRU forward propagation primitive.
The following arguments may point to a zero memory descriptor:
src_iter_desc
,bias_desc
,dst_iter_desc
.
This would then indicate that the LBR GRU forward propagation primitive should not use them and should default to zero values instead.
Note
All memory descriptors except
src_iter_desc
may be initialized with an dnnl::memory::format_tag::any value offormat_tag
.- Parameters
aprop_kind – Propagation kind. Possible values are dnnl::prop_kind::forward_training, and dnnl::prop_kind::forward_inference.
direction – RNN direction. See dnnl::rnn_direction for more info.
src_layer_desc – Memory descriptor for the input vector.
src_iter_desc – Memory descriptor for the input recurrent hidden state vector.
weights_layer_desc – Memory descriptor for the weights applied to the layer input.
weights_iter_desc – Memory descriptor for the weights applied to the recurrent input.
bias_desc – Bias memory descriptor.
dst_layer_desc – Memory descriptor for the output vector.
dst_iter_desc – Memory descriptor for the output recurrent hidden state vector.
flags – Unused.
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, rnn_flags flags = rnn_flags::undef)#
-
struct primitive_desc : public dnnl::rnn_primitive_desc_base#
Primitive descriptor for an LBR GRU forward propagation primitive.
Public Functions
-
primitive_desc()#
Default constructor. Produces an empty object.
-
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty = false)#
Constructs a primitive descriptor for a LBR GRU forward propagation primitive.
- Parameters
adesc – Descriptor for a LBR GRU forward propagation primitive.
aengine – Engine to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty = false)#
Constructs a primitive descriptor for a LBR GRU forward propagation primitive.
- Parameters
adesc – Descriptor for a LBR GRU forward propagation primitive.
attr – Primitive attributes to use.
aengine – Engine to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
memory::desc src_layer_desc() const#
Returns source layer memory descriptor.
- Returns
Source layer memory descriptor.
-
memory::desc src_iter_desc() const#
Returns source iteration memory descriptor.
- Returns
Source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a source iteration parameter.
-
memory::desc weights_layer_desc() const#
Returns weights layer memory descriptor.
- Returns
Weights layer memory descriptor.
-
memory::desc weights_iter_desc() const#
Returns weights iteration memory descriptor.
- Returns
Weights iteration memory descriptor.
-
memory::desc bias_desc() const#
Returns bias memory descriptor.
- Returns
Bias memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a bias parameter.
-
memory::desc dst_layer_desc() const#
Returns destination layer memory descriptor.
- Returns
Destination layer memory descriptor.
-
primitive_desc()#
-
lbr_gru_forward()#
-
struct lbr_gru_backward : public dnnl::primitive#
LBR GRU backward propagation primitive.
Public Functions
-
lbr_gru_backward()#
Default constructor. Produces an empty object.
-
lbr_gru_backward(const primitive_desc &pd)#
Constructs an LBR GRU backward propagation primitive.
- Parameters
pd – Primitive descriptor for an LBR GRU backward propagation primitive.
-
struct desc#
Descriptor for a LBR GRU backward propagation primitive.
Public Functions
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, rnn_flags flags = rnn_flags::undef)#
Constructs a descriptor for LBR GRU backward propagation primitive.
The following arguments may point to a zero memory descriptor:
src_iter_desc
together withdiff_src_iter_desc
,bias_desc
together withdiff_bias_desc
,dst_iter_desc
together withdiff_dst_iter_desc
.
This would then indicate that the LBR GRU backward propagation primitive should not use them and should default to zero values instead.
Note
All memory descriptors may be initialized with dnnl::memory::format_tag::any value of
format_tag
.- Parameters
aprop_kind – Propagation kind. Must be dnnl::prop_kind::backward.
direction – RNN direction. See dnnl::rnn_direction for more info.
src_layer_desc – Memory descriptor for the input vector.
src_iter_desc – Memory descriptor for the input recurrent hidden state vector.
weights_layer_desc – Memory descriptor for the weights applied to the layer input.
weights_iter_desc – Memory descriptor for the weights applied to the recurrent input.
bias_desc – Bias memory descriptor.
dst_layer_desc – Memory descriptor for the output vector.
dst_iter_desc – Memory descriptor for the output recurrent hidden state vector.
diff_src_layer_desc – Memory descriptor for the diff of input vector.
diff_src_iter_desc – Memory descriptor for the diff of input recurrent hidden state vector.
diff_weights_layer_desc – Memory descriptor for the diff of weights applied to the layer input.
diff_weights_iter_desc – Memory descriptor for the diff of weights applied to the recurrent input.
diff_bias_desc – Diff bias memory descriptor.
diff_dst_layer_desc – Memory descriptor for the diff of output vector.
diff_dst_iter_desc – Memory descriptor for the diff of output recurrent hidden state vector.
flags – Unused.
-
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, rnn_flags flags = rnn_flags::undef)#
-
struct primitive_desc : public dnnl::rnn_primitive_desc_base#
Primitive descriptor for an LBR GRU backward propagation primitive.
Public Functions
-
primitive_desc() = default#
Default constructor. Produces an empty object.
-
primitive_desc(const desc &adesc, const engine &aengine, const lbr_gru_forward::primitive_desc &hint_fwd_pd, bool allow_empty = false)#
Constructs a primitive descriptor for an LBR GRU backward propagation primitive.
- Parameters
adesc – Descriptor for an LBR GRU backward propagation primitive.
aengine – Engine to use.
hint_fwd_pd – Primitive descriptor for an LBR GRU forward propagation primitive. It is used as a hint for deciding which memory format to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const lbr_gru_forward::primitive_desc &hint_fwd_pd, bool allow_empty = false)#
Constructs a primitive descriptor for an LBR GRU backward propagation primitive.
- Parameters
adesc – Descriptor for an LBR GRU backward propagation primitive.
attr – Primitive attributes to use.
aengine – Engine to use.
hint_fwd_pd – Primitive descriptor for an LBR GRU forward propagation primitive. It is used as a hint for deciding which memory format to use.
allow_empty – A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.
-
memory::desc src_layer_desc() const#
Returns source layer memory descriptor.
- Returns
Source layer memory descriptor.
-
memory::desc src_iter_desc() const#
Returns source iteration memory descriptor.
- Returns
Source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a source iteration parameter.
-
memory::desc weights_layer_desc() const#
Returns weights layer memory descriptor.
- Returns
Weights layer memory descriptor.
-
memory::desc weights_iter_desc() const#
Returns weights iteration memory descriptor.
- Returns
Weights iteration memory descriptor.
-
memory::desc bias_desc() const#
Returns bias memory descriptor.
- Returns
Bias memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a bias parameter.
-
memory::desc dst_layer_desc() const#
Returns destination layer memory descriptor.
- Returns
Destination layer memory descriptor.
-
memory::desc dst_iter_desc() const#
Returns destination iteration memory descriptor.
- Returns
Destination iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a destination iteration parameter.
-
memory::desc workspace_desc() const#
Returns the workspace memory descriptor.
- Returns
Workspace memory descriptor.
- Returns
A zero memory descriptor if the primitive does not require workspace parameter.
-
memory::desc diff_src_layer_desc() const#
Returns diff source layer memory descriptor.
- Returns
Diff source layer memory descriptor.
-
memory::desc diff_src_iter_desc() const#
Returns diff source iteration memory descriptor.
- Returns
Diff source iteration memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a diff source iteration parameter.
-
memory::desc diff_weights_layer_desc() const#
Returns diff weights layer memory descriptor.
- Returns
Diff weights layer memory descriptor.
-
memory::desc diff_weights_iter_desc() const#
Returns diff weights iteration memory descriptor.
- Returns
Diff weights iteration memory descriptor.
-
memory::desc diff_bias_desc() const#
Returns diff bias memory descriptor.
- Returns
Diff bias memory descriptor.
- Returns
A zero memory descriptor if the primitive does not have a diff bias parameter.
-
primitive_desc() = default#
-
lbr_gru_backward()#