blob: 1d264def578cce322ede2a0d86fe787b11b9c434 [file] [log] [blame]
Aron Virginas-Tar1a0f6912019-08-23 15:18:44 +01001//
Keith Davis3201eea2019-10-24 17:30:41 +01002// Copyright © 2019 Arm Ltd. All rights reserved.
Aron Virginas-Tar1a0f6912019-08-23 15:18:44 +01003// SPDX-License-Identifier: MIT
4//
5
6#include "ProfilingConnectionFactory.hpp"
Keith Davis3201eea2019-10-24 17:30:41 +01007
8#include "FileOnlyProfilingConnection.hpp"
Keith Davisb10e0812019-10-17 09:52:50 +01009#include "ProfilingConnectionDumpToFileDecorator.hpp"
Keith Davis3201eea2019-10-24 17:30:41 +010010#include "SocketProfilingConnection.hpp"
Aron Virginas-Tar1a0f6912019-08-23 15:18:44 +010011
12namespace armnn
13{
14
15namespace profiling
16{
17
18std::unique_ptr<IProfilingConnection> ProfilingConnectionFactory::GetProfilingConnection(
19 const Runtime::CreationOptions::ExternalProfilingOptions& options) const
20{
Isabella Gottardia0687ee2020-03-11 18:04:20 +000021 // 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
Keith Davis3201eea2019-10-24 17:30:41 +010027 // 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 if ((!options.m_IncomingCaptureFile.empty() || !options.m_OutgoingCaptureFile.empty()) && !options.m_FileOnly)
Keith Davisb10e0812019-10-17 09:52:50 +010034 {
Keith Davis3201eea2019-10-24 17:30:41 +010035 // This is type 2.
Keith Davisb10e0812019-10-17 09:52:50 +010036 return std::make_unique<ProfilingConnectionDumpToFileDecorator>(std::make_unique<SocketProfilingConnection>(),
Keith Davis3201eea2019-10-24 17:30:41 +010037 options);
38 }
39 else if ((!options.m_IncomingCaptureFile.empty() || !options.m_OutgoingCaptureFile.empty()) && options.m_FileOnly)
40 {
41 // This is type 3.
42 return std::make_unique<ProfilingConnectionDumpToFileDecorator>(
43 std::make_unique<FileOnlyProfilingConnection>(options), options);
Keith Davisb10e0812019-10-17 09:52:50 +010044 }
45 else
46 {
Keith Davis3201eea2019-10-24 17:30:41 +010047 // This is type 1.
Keith Davisb10e0812019-10-17 09:52:50 +010048 return std::make_unique<SocketProfilingConnection>();
49 }
Aron Virginas-Tar1a0f6912019-08-23 15:18:44 +010050}
51
Keith Davis3201eea2019-10-24 17:30:41 +010052} // namespace profiling
Aron Virginas-Tar1a0f6912019-08-23 15:18:44 +010053
Keith Davis3201eea2019-10-24 17:30:41 +010054} // namespace armnn