MCPcopy Create free account
hub / github.com/ARM-software/armnn / CalculateEdgeStrategy

Function CalculateEdgeStrategy

src/armnn/Network.cpp:1786–1875  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1784}
1785
1786EdgeStrategy CalculateEdgeStrategy(BackendsMap& backends,
1787 ITensorHandleFactory::FactoryId srcFactoryId,
1788 const Layer& layer,
1789 const Layer& connectedLayer,
1790 TensorHandleFactoryRegistry& registry,
1791 bool importEnabled)
1792{
1793 auto toBackend = backends.find(connectedLayer.GetBackendId());
1794 if (toBackend == backends.end())
1795 {
1796 throw armnn::Exception("Backend id not found for the connected layer");
1797 }
1798
1799 auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1800
1801 // Legacy API check for backward compatibility
1802 if (srcFactoryId == ITensorHandleFactory::LegacyFactoryId || dstPrefs.empty())
1803 {
1804 if (layer.GetBackendId() != connectedLayer.GetBackendId())
1805 {
1806 return EdgeStrategy::CopyToTarget;
1807 }
1808 else
1809 {
1810 return EdgeStrategy::DirectCompatibility;
1811 }
1812 }
1813
1814 // TensorHandleFactory API present, so perform more sophisticated strategies.
1815 // Dst Output layers don't require copy because they use import or map/unmap
1816 if (connectedLayer.GetType() == LayerType::Output)
1817 {
1818 return EdgeStrategy::DirectCompatibility;
1819 }
1820
1821 // Search for direct match in prefs
1822 for (auto&& pref : dstPrefs)
1823 {
1824 if (pref == srcFactoryId)
1825 {
1826 return EdgeStrategy::DirectCompatibility;
1827 }
1828 }
1829
1830 // Search for export/import options
1831 ITensorHandleFactory* srcFactory = registry.GetFactory(srcFactoryId);
1832 if (srcFactory->GetExportFlags() != 0 && importEnabled)
1833 {
1834 for (auto&& pref : dstPrefs)
1835 {
1836 ITensorHandleFactory* dstFactory = registry.GetFactory(pref);
1837
1838 // Handles cases when a destPref is not listed in TensorHandleFactoryRegistry
1839 if (!dstFactory) {
1840 continue;
1841 }
1842 if ((dstFactory->GetImportFlags() & srcFactory->GetExportFlags()) != 0)
1843 {

Callers 1

Calls 12

emptyMethod · 0.80
ExceptionClass · 0.50
GetBackendIdMethod · 0.45
endMethod · 0.45
getMethod · 0.45
GetTypeMethod · 0.45
GetFactoryMethod · 0.45
GetExportFlagsMethod · 0.45
GetImportFlagsMethod · 0.45
GetCapabilitiesMethod · 0.45
SupportsMapUnmapMethod · 0.45

Tested by

no test coverage detected