ArmNN
 20.08
ProfilingConnectionFactory.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
11 
12 namespace armnn
13 {
14 
15 namespace profiling
16 {
17 
18 std::unique_ptr<IProfilingConnection> ProfilingConnectionFactory::GetProfilingConnection(
19  const Runtime::CreationOptions::ExternalProfilingOptions& options) const
20 {
21  // Before proceed to create the IProfilingConnection, check if the file format is supported
22  if (!(options.m_FileFormat == "binary"))
23  {
24  throw armnn::UnimplementedException("Unsupported profiling file format, only binary is supported");
25  }
26 
27  // We can create 3 different types of IProfilingConnection.
28  // 1: If no relevant options are specified then a SocketProfilingConnection is returned.
29  // 2: If both incoming and outgoing capture files are specified then a SocketProfilingConnection decorated by a
30  // ProfilingConnectionDumpToFileDecorator is returned.
31  // 3: If both incoming and outgoing capture files are specified and "file only" then a FileOnlyProfilingConnection
32  // decorated by a ProfilingConnectionDumpToFileDecorator is returned.
33  // 4. There is now another option if m_FileOnly == true and there are ILocalPacketHandlers specified
34  // we can create a FileOnlyProfilingConnection without a file dump
35  if ((!options.m_IncomingCaptureFile.empty() || !options.m_OutgoingCaptureFile.empty()) && !options.m_FileOnly)
36  {
37  // This is type 2.
38  return std::make_unique<ProfilingConnectionDumpToFileDecorator>(std::make_unique<SocketProfilingConnection>(),
39  options);
40  }
41  else if ((!options.m_IncomingCaptureFile.empty() || !options.m_OutgoingCaptureFile.empty()) && options.m_FileOnly)
42  {
43  // This is type 3.
44  return std::make_unique<ProfilingConnectionDumpToFileDecorator>(
45  std::make_unique<FileOnlyProfilingConnection>(options), options);
46  }
47  else if (options.m_FileOnly && !options.m_LocalPacketHandlers.empty())
48  {
49  // This is the type 4.
50  return std::make_unique<FileOnlyProfilingConnection>(options);
51  }
52  else
53  {
54  // This is type 1.
55  return std::make_unique<SocketProfilingConnection>();
56  }
57 }
58 
59 } // namespace profiling
60 
61 } // namespace armnn
Copyright (c) 2020 ARM Limited.
IProfilingConnectionPtr GetProfilingConnection(const ExternalProfilingOptions &options) const override