ArmNN
 26.07
IOptimizedNetwork Class Reference

#include <INetwork.hpp>

Public Member Functions

Status PrintGraph ()
 
Status SerializeToDot (std::ostream &stream) const
 
arm::pipe::ProfilingGuid GetGuid () const
 
size_t GetNumInputs () const
 
size_t GetNumOutputs () const
 
void ExecuteStrategy (IStrategy &strategy) const
 
 IOptimizedNetwork (const IOptimizedNetwork &other, const ModelOptions &modelOptions)
 Creates a copy of the IOptimizedNetwork. More...
 
 IOptimizedNetwork (std::unique_ptr< Graph > graph)
 
 IOptimizedNetwork (std::unique_ptr< OptimizedNetworkImpl > impl)
 
 ~IOptimizedNetwork ()
 
const std::shared_ptr< IProfiler > & GetProfiler () const
 

Static Public Member Functions

static void Destroy (IOptimizedNetwork *network)
 

Protected Member Functions

 IOptimizedNetwork (std::unique_ptr< Graph > graph, const ModelOptions &modelOptions)
 

Protected Attributes

std::unique_ptr< OptimizedNetworkImplpOptimizedNetworkImpl
 

Friends

class LoadedNetwork
 
GraphGetGraphForTesting (IOptimizedNetwork *optNetPtr)
 
ModelOptionsGetModelOptionsForTesting (IOptimizedNetwork *optNetPtr)
 
IOptimizedNetworkPtr Optimize (const INetwork &inNetwork, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptionsOpaque &options, Optional< std::vector< std::string > & > messages)
 Create an optimized version of the network. More...
 
IOptimizedNetworkPtr Optimize (const Graph &inGraph, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptionsOpaque &options, Optional< std::vector< std::string > & > messages)
 Create an optimized version of the network. More...
 

Detailed Description

Definition at line 902 of file INetwork.hpp.

Constructor & Destructor Documentation

◆ IOptimizedNetwork() [1/4]

IOptimizedNetwork ( const IOptimizedNetwork other,
const ModelOptions modelOptions 
)

Creates a copy of the IOptimizedNetwork.

The IOptimizedNetwork will not be reoptimized, the provided ModelOptions will only be used when creating a LoadedNetwork.

Definition at line 693 of file Network.cpp.

694  : pOptimizedNetworkImpl(new OptimizedNetworkImpl(*other.pOptimizedNetworkImpl.get(), modelOptions)) {}
std::unique_ptr< OptimizedNetworkImpl > pOptimizedNetworkImpl
Definition: INetwork.hpp:944

◆ IOptimizedNetwork() [2/4]

IOptimizedNetwork ( std::unique_ptr< Graph graph)

Definition at line 696 of file Network.cpp.

697  : pOptimizedNetworkImpl(new OptimizedNetworkImpl(std::move(graph))) {}

◆ IOptimizedNetwork() [3/4]

IOptimizedNetwork ( std::unique_ptr< OptimizedNetworkImpl impl)

Definition at line 699 of file Network.cpp.

700  : pOptimizedNetworkImpl(std::move(impl)) {}

◆ ~IOptimizedNetwork()

~IOptimizedNetwork ( )
default

◆ IOptimizedNetwork() [4/4]

IOptimizedNetwork ( std::unique_ptr< Graph graph,
const ModelOptions modelOptions 
)
protected

Definition at line 702 of file Network.cpp.

703  : pOptimizedNetworkImpl(new OptimizedNetworkImpl(std::move(graph), modelOptions)) {}

Member Function Documentation

◆ Destroy()

void Destroy ( IOptimizedNetwork network)
static

Definition at line 707 of file Network.cpp.

708 {
709  delete network;
710 }

◆ ExecuteStrategy()

void ExecuteStrategy ( IStrategy strategy) const

Definition at line 3284 of file Network.cpp.

3285 {
3286  pOptimizedNetworkImpl->ExecuteStrategy(strategy);
3287 }

References IOptimizedNetwork::pOptimizedNetworkImpl.

◆ GetGuid()

arm::pipe::ProfilingGuid GetGuid ( ) const

Definition at line 727 of file Network.cpp.

728 {
729  return pOptimizedNetworkImpl->GetGuid();
730 }

References IOptimizedNetwork::pOptimizedNetworkImpl.

◆ GetNumInputs()

size_t GetNumInputs ( ) const

Definition at line 732 of file Network.cpp.

733 {
734  return pOptimizedNetworkImpl->GetNumInputs();
735 }

References IOptimizedNetwork::pOptimizedNetworkImpl.

◆ GetNumOutputs()

size_t GetNumOutputs ( ) const

Definition at line 737 of file Network.cpp.

738 {
739  return pOptimizedNetworkImpl->GetNumOutputs();
740 }

References IOptimizedNetwork::pOptimizedNetworkImpl.

◆ GetProfiler()

const std::shared_ptr< IProfiler > & GetProfiler ( ) const

Definition at line 722 of file Network.cpp.

723 {
724  return pOptimizedNetworkImpl->GetGraph().GetProfiler();
725 }

References IOptimizedNetwork::pOptimizedNetworkImpl.

◆ PrintGraph()

Status PrintGraph ( )

Definition at line 712 of file Network.cpp.

713 {
714  return pOptimizedNetworkImpl->PrintGraph();
715 }

References IOptimizedNetwork::pOptimizedNetworkImpl.

◆ SerializeToDot()

Status SerializeToDot ( std::ostream &  stream) const

Definition at line 717 of file Network.cpp.

718 {
719  return pOptimizedNetworkImpl->SerializeToDot(stream);
720 }

References IOptimizedNetwork::pOptimizedNetworkImpl.

Friends And Related Function Documentation

◆ GetGraphForTesting

Graph& GetGraphForTesting ( IOptimizedNetwork optNetPtr)
friend

Definition at line 49 of file TestUtils.cpp.

50 {
51  return optNet->pOptimizedNetworkImpl->GetGraph();
52 }

◆ GetModelOptionsForTesting

ModelOptions& GetModelOptionsForTesting ( IOptimizedNetwork optNetPtr)
friend

Definition at line 54 of file TestUtils.cpp.

55 {
56  return optNet->pOptimizedNetworkImpl->GetModelOptions();
57 }

◆ LoadedNetwork

friend class LoadedNetwork
friend

Definition at line 927 of file INetwork.hpp.

◆ Optimize [1/2]

IOptimizedNetworkPtr Optimize ( const Graph inGraph,
const std::vector< BackendId > &  backendPreferences,
const IDeviceSpec deviceSpec,
const OptimizerOptionsOpaque options,
Optional< std::vector< std::string > & >  messages = EmptyOptional() 
)
friend

Create an optimized version of the network.

Parameters
inGraphGraph to be optimized.
backendPreferencesThe choice of the backend ordered by user preferences.
deviceSpecDeviceSpec object as queried from the runtime. See IRuntime::GetDeviceSpec()
messagesIf there are failures or warnings a string describing same will be added to the vector
optionsOptimizerOptions object with optimizer configuration options
Returns
An IOptimizedNetworkPtr interface to the optimized network, throws an exception derived from armnn::Exception if process fails.

Definition at line 2027 of file Network.cpp.

2032 {
2033  ARMNN_LOG(debug) << options.ToString();
2034 
2035  // Enable profiling
2036  auto profiler = inGraph.GetProfiler();
2038  profiler->EnableProfiling(options.GetProfilingEnabled());
2039 
2041  if (backendPreferences.empty())
2042  {
2043  throw InvalidArgumentException("Invoked Optimize with no backends specified");
2044  }
2045 
2046  if (options.GetReduceFp32ToBf16())
2047  {
2048  throw InvalidArgumentException("BFloat16 optimization is currently ignored. In order to use Bf16 optimization "
2049  "Please use the FastMathEnabled backend option for CpuAcc or GpuAcc.");
2050  }
2051 
2052  if (options.GetReduceFp32ToFp16() && options.GetReduceFp32ToBf16())
2053  {
2054  throw InvalidArgumentException("BFloat16 and Float16 optimization cannot be enabled at the same time.");
2055  }
2056 
2057  // Ensure TensorInfo is set on all output slots of ConstantLayers in the graph
2058  inGraph.VerifyConstantLayerSetTensorInfo();
2059 
2060  std::unique_ptr<Graph> graph = std::make_unique<Graph>(inGraph);
2061 
2062  // We need to pass on the information about whether import and export is enabled to the LoadNetwork phase.
2063  // The mechanism to do that is to add model options to the optimized network.
2064  armnn::BackendOptions importExport("Global",
2065  {{"ImportEnabled", options.GetImportEnabled()},
2066  {"ExportEnabled", options.GetExportEnabled()}});
2067  ModelOptions optimizedOptions(options.GetModelOptions());
2068  optimizedOptions.push_back(importExport);
2069 
2070  auto optNet = IOptimizedNetworkPtr(new IOptimizedNetwork(std::move(graph), optimizedOptions),
2072 
2073  IOptimizedNetwork* optNetObjPtr = optNet.get();
2074 
2075  // Get the optimized graph
2076  Graph& optGraph = optNetObjPtr->pOptimizedNetworkImpl->GetGraph();
2077 
2078  if(options.GetShapeInferenceMethod() == ShapeInferenceMethod::InferAndValidate)
2079  {
2080  // Infer the tensor infos for all output slots. Throws an exception on failure
2081  optGraph.InferTensorInfos();
2082  }
2083 
2084  using namespace optimizations;
2085  // Substitute Max + Min with Bounded Relu before AddBroadcastReshapeLayer optimisation,
2086  // as Bounded ReLu needs the constants to be 1D size 1
2088 
2089  // Perform BroadcastToOptimizationLayer before AddBroadcastReshapeLayer optimisation
2091 
2093 
2094  if(options.GetShapeInferenceMethod() == ShapeInferenceMethod::ValidateOnly)
2095  {
2096  // Validate the tensor infos for all output slots. Throws an exception on failure
2097  optGraph.InferTensorInfos();
2098  }
2099 
2100  if (std::count(backendPreferences.begin(), backendPreferences.end(), armnn::Compute::CpuAcc) > 0)
2101  {
2102  ApplySme2ShapePolicy(optGraph, options.GetReduceFp32ToFp16(), optimizedOptions);
2103  optNetObjPtr->pOptimizedNetworkImpl->GetModelOptions() = optimizedOptions;
2104  }
2105 
2106  // Initialize backend settings
2107  BackendSettings backendSettings(backendPreferences, deviceSpec);
2108  auto availablePreferredBackends = backendSettings.GetAvailablePreferredBackends();
2109  if (availablePreferredBackends.empty())
2110  {
2111  std::stringstream failureMsg;
2112  failureMsg << "None of the preferred backends " << backendPreferences
2113  << " are supported. Current platform provides " << backendSettings.m_SupportedBackends;
2114  ReportError(failureMsg.str(), messages);
2115  throw InvalidArgumentException(failureMsg.str());
2116  }
2117 
2118  // Create a map to temporarily hold initialized backend objects
2119  TensorHandleFactoryRegistry tensorHandleFactoryRegistry;
2120  BackendsMap backends = CreateSupportedBackends(tensorHandleFactoryRegistry, backendSettings);
2121  bool hasFp16 = CheckFp16Support(backends, availablePreferredBackends);
2122 
2123  bool reduceFp32ToFp16 = options.GetReduceFp32ToFp16();
2124  // If fp16 is supported on the backend and fastmath has been enabled and the model is a TfLite converted Fp16
2125  // model: enable turbo mode optimizations
2126  if (hasFp16 && CheckFastMathSupport(availablePreferredBackends, optimizedOptions) && IsTfLiteTurboModel(optGraph))
2127  {
2129  reduceFp32ToFp16 = true;
2130  }
2131  else
2132  {
2134  }
2135 
2136  // Group Constant Layer optimizations together where possible.
2137  // This is important as:
2138  // FusePermuteIntoConstantLayer must happen before FoldPadIntoDepthwiseConvolution2d and
2139  // FuseBatchNormIntoDepthwiseConvolution2D.
2141  // Perform optimisation passes
2147  MovePermuteUp(),
2148  MoveTransposeUp(),
2149  PermuteAsReshape(),
2159 
2160  const std::vector<BackendId> mappedGpuBackends = BackendRegistryInstance().GetMappedGpuBackends();
2161 
2162  // All or nothing Gpu backends cannot be used as fallback
2163  for (auto backend : mappedGpuBackends)
2164  {
2165  if (std::count(backendPreferences.begin(), backendPreferences.end(), backend)
2166  && (backendPreferences[0] != backend) &&
2167  (backendPreferences[0] != armnn::BackendId("GpuAcc")))
2168  {
2169  std::stringstream failureMsg;
2170  failureMsg << backend << " backend cannot be specified as fallback.";
2171  ReportError(failureMsg.str(), messages);
2172  throw InvalidArgumentException(failureMsg.str());
2173  }
2174  }
2175 
2176  std::vector<BackendId> amendedBackendPreferences = backendPreferences;
2177  std::unordered_set<BackendId> supportedBackends = armnn::BackendRegistryInstance().GetBackendIds();
2178  if (amendedBackendPreferences[0] == armnn::BackendId("GpuAcc"))
2179  {
2180  // Add mapped Gpu backends if not already there and GpuAcc is first backend requested
2181  for (auto backend : mappedGpuBackends)
2182  {
2183  if (!std::count(amendedBackendPreferences.begin(), amendedBackendPreferences.end(), backend))
2184  {
2185  amendedBackendPreferences.insert(amendedBackendPreferences.begin(), backend);
2186  }
2187  }
2188  }
2189 
2190  if (reduceFp32ToFp16 && hasFp16)
2191  {
2192  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_ReduceFp32ToFp16");
2195  }
2196  // Assign an available backend to each layer
2197  Graph::Iterator firstLayer = optGraph.begin();
2198  Graph::Iterator lastLayer = optGraph.end();
2199  OptimizationResult assignBackendsResult = AssignBackends(optNetObjPtr->pOptimizedNetworkImpl.get(),
2200  backendSettings,
2201  firstLayer,
2202  lastLayer,
2203  messages);
2204  if (assignBackendsResult.m_Error)
2205  {
2206  // Failed to assign a backend to each layer
2207  throw InvalidArgumentException("Failed to assign a backend to each layer");
2208  }
2209 
2212 
2213  // Apply the backend-specific optimizations
2214  OptimizationResult backendOptimizationResult = ApplyBackendOptimizations(optNetObjPtr->pOptimizedNetworkImpl.get(),
2215  backendSettings,
2216  backends,
2217  optimizedOptions,
2218  messages);
2219  if (backendOptimizationResult.m_Error)
2220  {
2221  // Failed to apply the backend-specific optimizations
2222  throw InvalidArgumentException("Failed to apply the backend-specific optimizations");
2223  }
2224 
2225  // Convert constants
2226  {
2227  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_ConvertConstants");
2230  }
2231 
2232  // This must occur after all topological changes to the graph and any redirection of variables
2233  // If the debug flag is set, then insert a DebugLayer after each layer
2234  // Doing this after applying the backend optimizations as they might have changed some layers
2235  if (options.GetDebugEnabled() && !options.GetDebugToFileEnabled())
2236  {
2238  }
2239  else if (options.GetDebugToFileEnabled())
2240  {
2241  // Setup the output file path
2242  try
2243  {
2244 #if !defined(ARMNN_DISABLE_FILESYSTEM)
2245  auto result = armnnUtils::Filesystem::CreateDirectory("/ArmNNIntermediateLayerOutputs");
2246  ARMNN_LOG(info) << "Intermediate tensors will be written to: " << result;
2247 #endif
2249  }
2250  catch (const armnn::RuntimeException& e)
2251  {
2252  // If we cannot create the output directory then we'll issue a warning and continue.
2253  ARMNN_LOG(warning) << "Unable to print intermediate layer outputs : " << e.what();
2254  }
2255  }
2256 
2257  // Calculate the compatibility strategies for tensor handles
2258  OptimizationResult strategyResult = SelectTensorHandleStrategy(optGraph,
2259  backends,
2260  tensorHandleFactoryRegistry,
2261  options.GetImportEnabled(),
2262  options.GetExportEnabled(),
2263  messages);
2264 
2265  if (strategyResult.m_Error)
2266  {
2267  // Failed to apply the backend-specific optimizations
2269  }
2270 
2271  // Based on the tensor handle strategy determined above, insert copy layers where required.
2272  {
2273  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_AddCompatibilityLayers");
2274  optGraph.AddCompatibilityLayers(backends, tensorHandleFactoryRegistry);
2275  }
2276 
2277  return optNet;
2278 }
#define ARMNN_LOG(severity)
Definition: Logging.hpp:212
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
BackendIdSet GetBackendIds() const
BackendIdVector GetMappedGpuBackends()
virtual const char * what() const noexcept override
Definition: Exceptions.cpp:32
LayerList::const_iterator Iterator
Definition: Graph.hpp:53
IOptimizedNetwork(const IOptimizedNetwork &other, const ModelOptions &modelOptions)
Creates a copy of the IOptimizedNetwork.
Definition: Network.cpp:693
static void Destroy(IOptimizedNetwork *network)
Definition: Network.cpp:707
static void Pass(Graph &graph, const Optimizations &optimizations)
Definition: Optimizer.cpp:16
void RegisterProfiler(IProfiler *profiler)
Definition: Profiling.cpp:609
static ProfilerManager & GetInstance()
Definition: Profiling.cpp:602
ConvertConstants< Float16ToFloat32, IsFloat32Layer > ConvertConstantsHalfToFloat
OptimizeForConnection< PermuteLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteLayer > > PermuteAndBatchToSpaceAsDepthToSpace
OptimizeForConnection< ConvertFp16ToFp32Layer, ConvertFp32ToFp16Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp16
ConvertConstants< Float32ToFloat16, IsFloat16Layer > ConvertConstantsFloatToHalf
OptimizeForConnection< Layer, ReshapeLayer, SquashEqualSiblingsImpl< ReshapeLayer > > SquashEqualReshapeSiblings
OptimizeForConnection< TransposeLayer, TransposeLayer, OptimizeInversePermutesImpl< TransposeLayer > > OptimizeInverseTransposes
OptimizeForConnection< ConstantLayer, DequantizeLayer, TurboConvertConstDequantisationLayersToConstLayersImpl > TurboConvertConstDequantisationLayersToConstLayers
OptimizeForConnection< ConstantLayer, DequantizeLayer, ConvertConstDequantisationLayersToConstLayersImpl > ConvertConstDequantisationLayersToConstLayers
OptimizeForType< Layer, AddBroadcastReshapeLayerImpl > AddBroadcastReshapeLayer
OptimizeForExclusiveConnection< DepthwiseConvolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< DepthwiseConvolution2dLayer, armnn::DataType::Float32 > > FuseBatchNormIntoDepthwiseConvolution2DFloat32
OptimizeForConnection< Layer, TransposeLayer, MoveTransposeUpImpl > MoveTransposeUp
OptimizeForConnection< Layer, PermuteLayer, SquashEqualSiblingsImpl< PermuteLayer > > SquashEqualPermuteSiblings
OptimizeForConnection< ReshapeLayer, ReshapeLayer, OptimizeConsecutiveReshapesImpl > OptimizeConsecutiveReshapes
OptimizeForType< Layer, ConvertFp32NetworkToFp16Impl > Fp32NetworkToFp16Converter
OptimizeForExclusiveConnection< Convolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< Convolution2dLayer, armnn::DataType::Float16 > > FuseBatchNormIntoConvolution2DFloat16
OptimizeForConnection< TransposeLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl< TransposeLayer > > TransposeAndBatchToSpaceAsDepthToSpace
OptimizeForType< Layer, AddDebugToFileImpl > InsertDebugToFileLayer
Definition: AddDebug.hpp:54
OptimizeForConnection< PermuteLayer, PermuteLayer, OptimizeInversePermutesImpl< PermuteLayer > > OptimizeInversePermutes
OptimizeForExclusiveConnection< Convolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< Convolution2dLayer, armnn::DataType::Float32 > > FuseBatchNormIntoConvolution2DFloat32
OptimizeForType< Layer, AddDebugImpl > InsertDebugLayer
Definition: AddDebug.hpp:53
OptimizeForConnection< Layer, PermuteLayer, MovePermuteUpImpl > MovePermuteUp
OptimizeForExclusiveConnection< DepthwiseConvolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< DepthwiseConvolution2dLayer, armnn::DataType::Float16 > > FuseBatchNormIntoDepthwiseConvolution2DFloat16
OptimizeForConnection< Layer, TransposeLayer, SquashEqualSiblingsImpl< TransposeLayer > > SquashEqualTransposeSiblings
OptimizeForExclusiveConnection< ElementwiseBinaryLayer, ElementwiseBinaryLayer, MaxMinIntoBoundedReluImpl > MaxMinIntoBoundedRelu
OptimizeForType< BroadcastToLayer, DeleteBroadcastToImpl > BroadcastToOptimizationLayer
OptimizeForType< TransposeLayer, TransposeAsReshapeImpl > TransposeAsReshape
OptimizeForConnection< ConstantLayer, PermuteLayer, ConvertConstPermuteLayersToConstLayers > FusePermuteIntoConstLayer
OptimizeForType< PermuteLayer, PermuteAsReshapeImpl > PermuteAsReshape
OptimizeForConnection< ConvertFp32ToFp16Layer, ConvertFp16ToFp32Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp32
BackendsMap CreateSupportedBackends(TensorHandleFactoryRegistry &handleFactoryRegistry, BackendSettings &backendSettings)
Definition: Network.cpp:1355
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > & > errorMessages)
Definition: Network.cpp:763
bool IsTfLiteTurboModel(const Graph &optGraph)
Definition: Network.cpp:1977
std::vector< BackendOptions > ModelOptions
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
Definition: INetwork.hpp:340
void ApplySme2ShapePolicy(const Graph &graph, bool reduceFp32ToFp16, ModelOptions &modelOptions)
OptimizationResult AssignBackends(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, Graph::Iterator &firstLayer, Graph::Iterator &lastLayer, Optional< std::vector< std::string > & > errMessages)
Definition: Network.cpp:1212
bool CheckFastMathSupport(const std::vector< BackendId > &availablePreferredBackends, const ModelOptions &modelOptions)
Definition: Network.cpp:1949
std::map< BackendId, std::unique_ptr< class IBackendInternal > > BackendsMap
Definition: Network.hpp:285
bool CheckFp16Support(BackendsMap &backends, const std::vector< BackendId > &availablePreferredBackends)
Definition: Network.cpp:1046
Optimizer::Optimizations MakeOptimizations(Args &&... args)
Definition: Optimizer.hpp:43
BackendRegistry & BackendRegistryInstance()
OptimizationResult ApplyBackendOptimizations(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, BackendsMap &backends, const ModelOptions &modelOptions, Optional< std::vector< std::string > & > errMessages)
Definition: Network.cpp:1373
OptimizationResult SelectTensorHandleStrategy(Graph &optGraph, BackendsMap &backends, TensorHandleFactoryRegistry &registry, bool importEnabled, bool exportEnabled, Optional< std::vector< std::string > & > errMessages)
Definition: Network.cpp:1878
@ InferAndValidate
Infer missing output shapes and validate all output shapes.
@ ValidateOnly
Validate all output shapes.
@ CpuAcc
CPU Execution: NEON: ArmCompute.
std::string CreateDirectory(std::string sPath)
Returns full path to temporary folder.
Definition: Filesystem.cpp:47
Struct for the users to pass backend specific options.

◆ Optimize [2/2]

IOptimizedNetworkPtr Optimize ( const INetwork inNetwork,
const std::vector< BackendId > &  backendPreferences,
const IDeviceSpec deviceSpec,
const OptimizerOptionsOpaque options = OptimizerOptionsOpaque(),
Optional< std::vector< std::string > & >  messages = EmptyOptional() 
)
friend

Create an optimized version of the network.

Parameters
networkINetwork description of the network to be optimized.
backendPreferencesThe choice of the backend ordered by user preferences.
deviceSpecDeviceSpec object as queried from the runtime. See IRuntime::GetDeviceSpec()
messagesIf there are failures or warnings a string describing same will be added to the vector
optionsOptimizerOptions object with optimizer configuration options
Returns
An IOptimizedNetworkPtr interface to the optimized network, throws an exception derived from armnn::Exception if process fails.

Definition at line 2294 of file Network.cpp.

2299 {
2300  return Optimize(inNetwork.pNetworkImpl->GetGraph(),
2301  backendPreferences,
2302  deviceSpec,
2303  options,
2304  messages);
2305 }
friend IOptimizedNetworkPtr Optimize(const INetwork &inNetwork, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptionsOpaque &options, Optional< std::vector< std::string > & > messages)
Create an optimized version of the network.
Definition: Network.cpp:2294

Member Data Documentation

◆ pOptimizedNetworkImpl


The documentation for this class was generated from the following files: