Commit 2b2f3f35 authored by Jayaram Bobba's avatar Jayaram Bobba Committed by Scott Cyphers

Support constant folding for reshape and broadcast bf16 data (#2823)

* Support constant folding for reshape and broadcast bf16 data

* - Addressed PR feedback
- Adding extra paranthesis for icc
parent 94d39716
...@@ -124,7 +124,7 @@ namespace ngraph ...@@ -124,7 +124,7 @@ namespace ngraph
/// \return A dynamic dimension. /// \return A dynamic dimension.
static Dimension dynamic() { return Dimension(); } static Dimension dynamic() { return Dimension(); }
/// \brief Constant for the value used internally to represent a dynamic dimension. /// \brief Constant for the value used internally to represent a dynamic dimension.
static const size_t s_dynamic_val{std::numeric_limits<size_t>::max()}; static const size_t s_dynamic_val{(std::numeric_limits<size_t>::max())};
/// \brief Addition operator for Dimension. /// \brief Addition operator for Dimension.
/// \param dim Right operand for addition. /// \param dim Right operand for addition.
......
...@@ -234,6 +234,13 @@ void pass::ConstantFolding::construct_constant_reshape() ...@@ -234,6 +234,13 @@ void pass::ConstantFolding::construct_constant_reshape()
fold_constant_reshape<double>(constant_match, reshape_match, func)); fold_constant_reshape<double>(constant_match, reshape_match, func));
return true; return true;
} }
else if (type == element::bf16)
{
replace_node(
m.get_match_root(),
fold_constant_reshape<ngraph::bfloat16>(constant_match, reshape_match, func));
return true;
}
return false; return false;
}; };
...@@ -322,6 +329,13 @@ void pass::ConstantFolding::construct_constant_broadcast() ...@@ -322,6 +329,13 @@ void pass::ConstantFolding::construct_constant_broadcast()
fold_constant_broadcast<double>(constant_match, broadcast_match, func)); fold_constant_broadcast<double>(constant_match, broadcast_match, func));
return true; return true;
} }
else if (type == element::bf16)
{
replace_node(
m.get_match_root(),
fold_constant_broadcast<ngraph::bfloat16>(constant_match, broadcast_match, func));
return true;
}
return false; return false;
}; };
......
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