namespace InferenceEngine::NetPass¶
Overview¶
namespace NetPass {
// global functions
bool CombineRNNSeq(CNNNetwork& net);
bool CombineRNNSeq(TensorIterator::Body& net);
std::vector<CNNLayerPtr> TIBodySortTopologically(const TensorIterator::Body& body);
bool HasInternalSubnet(const CNNLayerPtr& layer);
details::CNNSubnet GetInternalSubnet(const CNNLayerPtr& layer);
bool UnrollTI(CNNNetwork& net);
bool UnrollRNN_if(CNNNetwork& net, std::function<bool(const RNNCellBase&)> pred);
TensorIterator::Body CopyTIBody(
const TensorIterator::Body& body,
std::string suffix = std::string()
);
bool UnrollRNN_if(
TensorIterator::Body& net,
std::function<bool(const RNNCellBase&)> pred
);
void ConvertPrecision(CNNNetwork& net, Precision from, Precision to);
void ConvertIOPrecision(CNNNetwork& net, Precision from, Precision to);
} // namespace NetPass
Detailed Documentation¶
Global Functions¶
bool CombineRNNSeq(CNNNetwork& net)
Try to detect LSTM Sequence pattern inside TI and convert it
Parameters:
net |
network to modify |
Returns:
true if all Tensor iterator was converted
std::vector<CNNLayerPtr> TIBodySortTopologically(const TensorIterator::Body& body)
Returns a vector of the topologically sorted layers from the passed TI layer body.
Parameters:
body |
TI body |
Returns:
vector of layer objects
bool HasInternalSubnet(const CNNLayerPtr& layer)
Check if provided layer contains internal attribute like subnet/subgraph
Parameters:
layer |
to check |
Returns:
true if layer has subnet
details::CNNSubnet GetInternalSubnet(const CNNLayerPtr& layer)
Extract internal subnet from layer
All internal layers are returned by reference. Any modification further subnet modification will has affect on original layer state.
Parameters:
layer |
to proceed |
Returns:
internal subnet
bool UnrollTI(CNNNetwork& net)
Unroll all present Tensor Iterators
Parameters:
net |
network to modify |
Returns:
true if all Tensor iterator was unrolled successfully
bool UnrollRNN_if(CNNNetwork& net, std::function<bool(const RNNCellBase&)> pred)
Unroll all RNN specific layers by predicate
Will be applied to all RNNSeq and RNNCell layers
Parameters:
net |
network to modify |
pred |
predicate to mark layer to unroll |
Returns:
true if all RNN layers was unrolled successfully
TensorIterator::Body CopyTIBody(
const TensorIterator::Body& body,
std::string suffix = std::string()
)
Construct a copy of provided subnet. Will change names by adding suffix if it was provided.
Parameters:
subnet |
to copy from |
suffix |
is optional attribute. Will be added into name of each layer/data object if provided |
Returns:
subnet copy. Each layer/data object is newly created. Const blob objects is inherited from original subnet.
void ConvertPrecision(CNNNetwork& net, Precision from, Precision to)
Precision conversion pass
Will perform conversion of all presented tensors with specified precision including const blobs and intermediate tensors. It doesn’t check layer semantic. It may break correctness of topology.
It also remove redundant convert layers if they will appear.
Parameters:
net |
is network to apply conversion |
from |
precision of tensors required conversion |
to |
resulting precision of tensors |