Aron Virginas-Tar | 1a0f691 | 2019-08-23 15:18:44 +0100 | [diff] [blame] | 1 | // |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 2 | // Copyright © 2019 Arm Ltd. All rights reserved. |
Aron Virginas-Tar | 1a0f691 | 2019-08-23 15:18:44 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ProfilingConnectionFactory.hpp" |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 7 | |
| 8 | #include "FileOnlyProfilingConnection.hpp" |
Keith Davis | b10e081 | 2019-10-17 09:52:50 +0100 | [diff] [blame] | 9 | #include "ProfilingConnectionDumpToFileDecorator.hpp" |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 10 | #include "SocketProfilingConnection.hpp" |
Aron Virginas-Tar | 1a0f691 | 2019-08-23 15:18:44 +0100 | [diff] [blame] | 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 | { |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 21 | // We can create 3 different types of IProfilingConnection. |
| 22 | // 1: If no relevant options are specified then a SocketProfilingConnection is returned. |
| 23 | // 2: If both incoming and outgoing capture files are specified then a SocketProfilingConnection decorated by a |
| 24 | // ProfilingConnectionDumpToFileDecorator is returned. |
| 25 | // 3: If both incoming and outgoing capture files are specified and "file only" then a FileOnlyProfilingConnection |
| 26 | // decorated by a ProfilingConnectionDumpToFileDecorator is returned. |
| 27 | if ((!options.m_IncomingCaptureFile.empty() || !options.m_OutgoingCaptureFile.empty()) && !options.m_FileOnly) |
Keith Davis | b10e081 | 2019-10-17 09:52:50 +0100 | [diff] [blame] | 28 | { |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 29 | // This is type 2. |
Keith Davis | b10e081 | 2019-10-17 09:52:50 +0100 | [diff] [blame] | 30 | return std::make_unique<ProfilingConnectionDumpToFileDecorator>(std::make_unique<SocketProfilingConnection>(), |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 31 | options); |
| 32 | } |
| 33 | else if ((!options.m_IncomingCaptureFile.empty() || !options.m_OutgoingCaptureFile.empty()) && options.m_FileOnly) |
| 34 | { |
| 35 | // This is type 3. |
| 36 | return std::make_unique<ProfilingConnectionDumpToFileDecorator>( |
| 37 | std::make_unique<FileOnlyProfilingConnection>(options), options); |
Keith Davis | b10e081 | 2019-10-17 09:52:50 +0100 | [diff] [blame] | 38 | } |
| 39 | else |
| 40 | { |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 41 | // This is type 1. |
Keith Davis | b10e081 | 2019-10-17 09:52:50 +0100 | [diff] [blame] | 42 | return std::make_unique<SocketProfilingConnection>(); |
| 43 | } |
Aron Virginas-Tar | 1a0f691 | 2019-08-23 15:18:44 +0100 | [diff] [blame] | 44 | } |
| 45 | |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 46 | } // namespace profiling |
Aron Virginas-Tar | 1a0f691 | 2019-08-23 15:18:44 +0100 | [diff] [blame] | 47 | |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 48 | } // namespace armnn |