Commit 93255d43 authored by Adam Rogowiec's avatar Adam Rogowiec

Remove static qualifier for clip function.

parent ad30a5bd
......@@ -242,7 +242,7 @@ NodeVector op::LSTMCell::decompose_op() const
auto c_t = split_gates.at(3);
// f(Xt*(Wi^T) + Ht-1*(Ri^T) + Pi (.) Ct-1 + Wbi + Rbi)
i_t = m_activation_f(clip(add(i_t, mul(p_i, m_C_t)), get_clip()));
i_t = m_activation_f(clip(add(i_t, mul(p_i, m_C_t))));
if (m_input_forget)
{
// Couple input with forget gate: 1 - i_t
......@@ -255,14 +255,14 @@ NodeVector op::LSTMCell::decompose_op() const
else
{
// f(Xt*(Wf^T) + Ht-1*(Rf^T) + Pf (.) Ct-1 + Wbf + Rbf)
f_t = m_activation_f(clip(add(f_t, mul(p_f, m_C_t)), get_clip()));
f_t = m_activation_f(clip(add(f_t, mul(p_f, m_C_t))));
}
// ft (.) Ct-1 + it (.) ct
auto C = add(mul(f_t, m_C_t), mul(i_t, m_activation_g(clip(c_t, get_clip()))));
auto C = add(mul(f_t, m_C_t), mul(i_t, m_activation_g(clip(c_t))));
// f(Xt*(Wo^T) + Ht-1*(Ro^T) + Po (.) Ct + Wbo + Rbo)
o_t = m_activation_f(clip(add(o_t, mul(p_o, C)), get_clip()));
o_t = m_activation_f(clip(add(o_t, mul(p_o, C))));
// ot (.) h(Ct)
auto H = mul(o_t, m_activation_h(clip(C, get_clip())));
auto H = mul(o_t, m_activation_h(clip(C)));
return {H, C};
}
......
......@@ -182,7 +182,7 @@ NodeVector op::RNNCell::decompose_op() const
auto i_t = add(Xt_W, add(Ht_R, m_bias));
// f(Xt*(Wi^T) + Ht-1*(Ri^T) + Wbi + Rbi)
i_t = m_activation_f(clip(i_t, get_clip()));
i_t = m_activation_f(clip(i_t));
return {i_t};
}
......
......@@ -86,15 +86,15 @@ shared_ptr<Node> op::RNNCellBase::mul(const shared_ptr<Node>& lhs, const shared_
return {make_shared<op::Multiply>(args.at(0), args.at(1))};
}
shared_ptr<Node> op::RNNCellBase::clip(const shared_ptr<Node>& data, const float threshold)
shared_ptr<Node> op::RNNCellBase::clip(const shared_ptr<Node>& data) const
{
if (threshold == 0.f)
if (m_clip == 0.f)
{
return data;
}
float min_val = -threshold;
float max_val = threshold;
float min_val = -m_clip;
float max_val = m_clip;
size_t size = shape_size(data->get_shape());
const shared_ptr<Node> min_val_node = op::Constant::create(
data->get_element_type(), data->get_shape(), vector<float>(size, min_val));
......
......@@ -101,13 +101,11 @@ namespace ngraph
///
/// \brief Creates node with element-wise clip operation with numpy broadcasting.
///
/// \param[in] lhs The left hand side argument node.
/// \param[in] rhs The right hand side argument node.
/// \param[in] data The input tensor for clipping.
///
/// \return Node with element-wise clip operation.
///
static std::shared_ptr<Node> clip(const std::shared_ptr<Node>& data,
const float threshold);
std::shared_ptr<Node> clip(const std::shared_ptr<Node>& data) const;
private:
std::size_t m_hidden_size = 0.f;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment