telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | #include "Network.hpp" |
| 6 | #include "Graph.hpp" |
| 7 | #include "Layer.hpp" |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 8 | #include "DeviceSpec.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 9 | #include "Optimizer.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 10 | #include "optimizations/All.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 11 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 12 | #include <backendsCommon/CpuTensorHandle.hpp> |
| 13 | #include <backendsCommon/WorkloadFactory.hpp> |
David Beck | 263e349 | 2018-11-09 14:46:40 +0000 | [diff] [blame] | 14 | #include <backendsCommon/BackendRegistry.hpp> |
| 15 | #include <backendsCommon/IBackendInternal.hpp> |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 16 | |
| 17 | #include <armnn/Exceptions.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 18 | #include <armnn/Utils.hpp> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 19 | #include <armnn/TypesUtils.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 20 | |
| 21 | #include <fcntl.h> |
| 22 | #include <algorithm> |
| 23 | #include <fstream> |
| 24 | #include <memory> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 25 | #include <vector> |
| 26 | #include <algorithm> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 27 | |
| 28 | #include <boost/assert.hpp> |
| 29 | #include <boost/format.hpp> |
| 30 | #include <boost/log/trivial.hpp> |
| 31 | #include <boost/numeric/conversion/converter_policies.hpp> |
| 32 | #include <boost/cast.hpp> |
| 33 | |
| 34 | namespace armnn |
| 35 | { |
| 36 | |
| 37 | armnn::INetwork* INetwork::CreateRaw() |
| 38 | { |
| 39 | return new Network(); |
| 40 | } |
| 41 | |
| 42 | armnn::INetworkPtr INetwork::Create() |
| 43 | { |
| 44 | return INetworkPtr(CreateRaw(), &INetwork::Destroy); |
| 45 | } |
| 46 | |
| 47 | void INetwork::Destroy(INetwork* network) |
| 48 | { |
| 49 | delete boost::polymorphic_downcast<Network*>(network); |
| 50 | } |
| 51 | |
| 52 | Status Network::PrintGraph() |
| 53 | { |
| 54 | m_Graph->Print(); |
| 55 | return Status::Success; |
| 56 | } |
| 57 | |
| 58 | void IOptimizedNetwork::Destroy(IOptimizedNetwork* network) |
| 59 | { |
| 60 | delete boost::polymorphic_downcast<OptimizedNetwork*>(network); |
| 61 | } |
| 62 | |
| 63 | Status OptimizedNetwork::PrintGraph() |
| 64 | { |
| 65 | m_Graph->Print(); |
| 66 | return Status::Success; |
| 67 | } |
| 68 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 69 | Status OptimizedNetwork::SerializeToDot(std::ostream& stream) const |
| 70 | { |
| 71 | return m_Graph->SerializeToDot(stream); |
| 72 | } |
| 73 | |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 74 | bool CheckScaleSetOnQuantizedType(Layer* layer, Optional<std::vector<std::string>&> errMessages) |
| 75 | { |
| 76 | bool noErrors = true; |
| 77 | unsigned int numOutputs = layer->GetNumOutputSlots(); |
| 78 | for (unsigned int i = 0; i < numOutputs; i++) { |
| 79 | const OutputSlot &outputSlot = layer->GetOutputSlot(i); |
| 80 | const TensorInfo &info = outputSlot.GetTensorInfo(); |
| 81 | if (DataType::QuantisedAsymm8 == info.GetDataType()) { |
| 82 | if (0.f == info.GetQuantizationScale()) { |
| 83 | noErrors = false; |
| 84 | std::stringstream ss; |
| 85 | ss << "ERROR: output " << i << " of layer " << GetLayerTypeAsCString(layer->GetType()) |
| 86 | << " (" << layer->GetNameStr() << ") is of type" |
| 87 | << " Quantized 8 bit but its scale parameter has not been set"; |
| 88 | BOOST_LOG_TRIVIAL(warning) << ss.str() ; |
| 89 | if (errMessages) { |
| 90 | errMessages.value().push_back(ss.str()); |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | return noErrors; |
| 96 | } |
| 97 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 98 | IOptimizedNetworkPtr Optimize(const INetwork& inNetwork, |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 99 | const std::vector<BackendId>& backendPreferences, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 100 | const IDeviceSpec& deviceSpec, |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 101 | const OptimizerOptions& options, |
| 102 | Optional<std::vector<std::string>&> errMessages) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 103 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 104 | if (backendPreferences.empty()) { |
| 105 | throw armnn::InvalidArgumentException("Invoked Optimize with no backends specified"); |
| 106 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 107 | const Network& network = *boost::polymorphic_downcast<const Network*>(&inNetwork); |
| 108 | std::unique_ptr<Graph> graph = std::make_unique<Graph>(network.GetGraph()); |
| 109 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 110 | auto optNet = IOptimizedNetworkPtr(new OptimizedNetwork(std::move(graph)), &IOptimizedNetwork::Destroy); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 111 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 112 | OptimizedNetwork* optNetObjPtr = boost::polymorphic_downcast<OptimizedNetwork*>(optNet.get()); |
| 113 | |
| 114 | // Perform optimisation passes |
| 115 | using namespace optimizations; |
| 116 | Optimizer::Pass(optNetObjPtr->GetGraph(), MakeOptimizations(SquashEqualPermuteSiblings(), |
| 117 | SquashEqualReshapeSiblings(), |
| 118 | OptimizeInversePermutes(), |
| 119 | MovePermuteUp(), |
| 120 | PermuteAsReshape(), |
| 121 | OptimizeConsecutiveReshapes())); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 122 | |
| 123 | // Infer the tensor infos for all output slots. Throws an exception on failure. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 124 | optNetObjPtr->GetGraph().InferTensorInfos(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 125 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 126 | // if Fp32 to Fp16 optimization is set convert Fp32 network to Fp16 |
| 127 | if (options.m_ReduceFp32ToFp16) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 128 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 129 | Optimizer::Pass(optNetObjPtr->GetGraph(), MakeOptimizations(Fp32NetworkToFp16Converter())); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 130 | } |
| 131 | |
keidav01 | 738c2e6 | 2018-12-11 16:14:20 +0000 | [diff] [blame] | 132 | // if debug optimization is set, then print out data after each layer |
| 133 | if (options.m_Debug) |
| 134 | { |
| 135 | Optimizer::Pass(optNetObjPtr->GetGraph(), MakeOptimizations(InsertDebugLayer())); |
| 136 | } |
| 137 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 138 | // We know that DeviceSpec should be the only implementation of IDeviceSpec. |
| 139 | const DeviceSpec& spec = *boost::polymorphic_downcast<const DeviceSpec*>(&deviceSpec); |
David Beck | 056be3c | 2018-10-22 13:16:00 +0100 | [diff] [blame] | 140 | auto const& supportedBackends = spec.GetSupportedBackends(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 141 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 142 | // determine which of the preferred backends we have available for use |
| 143 | // and whether we have specified CpuRef as one of those backends. |
| 144 | bool cpuRefUsed = false; |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 145 | std::vector<BackendId> availablePreferredBackends; |
| 146 | for (const auto& backend : backendPreferences) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 147 | { |
| 148 | // Check if the backend is in the available backend devices. |
David Beck | 056be3c | 2018-10-22 13:16:00 +0100 | [diff] [blame] | 149 | if (supportedBackends.count(backend) > 0) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 150 | { |
| 151 | availablePreferredBackends.push_back(backend); |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 152 | if (backend == armnn::Compute::CpuRef) { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 153 | cpuRefUsed = true; |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | if (availablePreferredBackends.empty()) { |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 158 | std::stringstream failureMsg; |
| 159 | failureMsg << "ERROR: None of the preferred backends " << backendPreferences |
David Beck | 056be3c | 2018-10-22 13:16:00 +0100 | [diff] [blame] | 160 | << " are supported. Current platform provides " << supportedBackends; |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 161 | BOOST_LOG_TRIVIAL(warning) << failureMsg.str(); |
| 162 | if (errMessages) { |
| 163 | errMessages.value().push_back(failureMsg.str()); |
| 164 | } |
| 165 | return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | auto ReturnWithError = [&](Layer* layer) |
| 169 | { |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 170 | std::stringstream failureMsg; |
| 171 | failureMsg << "ERROR: Layer of type " << GetLayerTypeAsCString(layer->GetType()) |
| 172 | << " is not supported on any preferred backend " << backendPreferences; |
| 173 | BOOST_LOG_TRIVIAL(warning) << failureMsg.str(); |
| 174 | if (errMessages) { |
| 175 | errMessages.value().push_back(failureMsg.str()); |
| 176 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 177 | return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy); |
| 178 | }; |
| 179 | |
David Beck | 263e349 | 2018-11-09 14:46:40 +0000 | [diff] [blame] | 180 | // The backends that we choose to run layers on |
| 181 | std::unordered_set<BackendId> chosenBackends; |
| 182 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 183 | // Assign a compute device for all nodes |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 184 | bool bErrorFound = false; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 185 | for (auto&& layer : optNetObjPtr->GetGraph()) |
| 186 | { |
| 187 | DataType dataType = layer->GetDataType(); |
| 188 | std::string reasonIfUnsupported; |
| 189 | bool found = false; |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 190 | if (!CheckScaleSetOnQuantizedType(layer, errMessages)) |
| 191 | { |
| 192 | // don't bomb immediately, find all the quantized outputs |
| 193 | // which haven't had a scale set and report them all back. |
| 194 | bErrorFound = true; |
| 195 | } |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 196 | for (const auto& backend : availablePreferredBackends) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 197 | { |
| 198 | // need to set the compute device on the layer |
| 199 | // before we can check if it is supported |
David Beck | 33f0ae0 | 2018-10-18 15:13:56 +0100 | [diff] [blame] | 200 | layer->SetBackendId(backend); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 201 | if (!IWorkloadFactory::IsLayerSupported(*layer, dataType, reasonIfUnsupported)) |
| 202 | { |
| 203 | if (dataType == DataType::Float16) |
| 204 | { |
| 205 | if (IWorkloadFactory::IsLayerSupported(*layer, DataType::Float32, reasonIfUnsupported) |
| 206 | && layer->GetType() != LayerType::ConvertFp32ToFp16 |
| 207 | && layer->GetType() != LayerType::ConvertFp16ToFp32) |
| 208 | { |
| 209 | // Insert FP16 -> FP32 conversion layer before current layer |
| 210 | std::vector<ConvertFp16ToFp32Layer*> convertFp16ToFp32Layers = |
| 211 | InsertConvertFp16ToFp32LayersBefore(optNetObjPtr->GetGraph(), *layer); |
| 212 | |
| 213 | // Insert FP32 -> FP16 conversion layer after current layer |
| 214 | std::vector<ConvertFp32ToFp16Layer*> convertFp32ToFp16Layers = |
| 215 | InsertConvertFp32ToFp16LayersAfter(optNetObjPtr->GetGraph(), *layer); |
| 216 | |
| 217 | // Assign a supported backend to the newly introduced conversion layers |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 218 | auto AssignFirstSupportedBackend = [&](Layer* layer, BackendId preferredBackend) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 219 | { |
| 220 | bool supportedBackendFound = false; |
| 221 | std::string reasonIfUnsupported; |
| 222 | |
| 223 | // Try preferred backend first |
David Beck | 33f0ae0 | 2018-10-18 15:13:56 +0100 | [diff] [blame] | 224 | layer->SetBackendId(preferredBackend); |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 225 | if (IWorkloadFactory::IsLayerSupported(*layer, |
| 226 | EmptyOptional(), |
| 227 | reasonIfUnsupported)) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 228 | { |
| 229 | supportedBackendFound = true; |
| 230 | } |
| 231 | else |
| 232 | { |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 233 | for (const auto& backend : availablePreferredBackends) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 234 | { |
| 235 | // Skip preferred backend (we already determined that it is not supported) |
| 236 | if (backend == preferredBackend) |
| 237 | { |
| 238 | continue; |
| 239 | } |
| 240 | |
David Beck | 33f0ae0 | 2018-10-18 15:13:56 +0100 | [diff] [blame] | 241 | layer->SetBackendId(backend); |
David Beck | 29c75de | 2018-10-23 13:35:58 +0100 | [diff] [blame] | 242 | if (IWorkloadFactory::IsLayerSupported(*layer, |
| 243 | EmptyOptional(), |
| 244 | reasonIfUnsupported)) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 245 | { |
| 246 | supportedBackendFound = true; |
| 247 | break; |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | return supportedBackendFound; |
| 253 | }; |
| 254 | |
| 255 | for (ConvertFp16ToFp32Layer* convertLayer : convertFp16ToFp32Layers) |
| 256 | { |
| 257 | if (!AssignFirstSupportedBackend(convertLayer, backend)) |
| 258 | { |
| 259 | return ReturnWithError(convertLayer); |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | for (ConvertFp32ToFp16Layer* convertLayer : convertFp32ToFp16Layers) |
| 264 | { |
| 265 | if (!AssignFirstSupportedBackend(convertLayer, backend)) |
| 266 | { |
| 267 | return ReturnWithError(convertLayer); |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | found = true; |
| 272 | break; |
| 273 | } |
| 274 | } |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 275 | std::stringstream warningMsg; |
| 276 | warningMsg << "WARNING: Layer of type " << GetLayerTypeAsCString(layer->GetType()) |
David Beck | 33f0ae0 | 2018-10-18 15:13:56 +0100 | [diff] [blame] | 277 | << " is not supported on requested backend " << layer->GetBackendId().Get() |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 278 | << " for data type " << GetDataTypeName(dataType) |
| 279 | << " (reason: " << reasonIfUnsupported |
| 280 | << "), falling back to the next backend."; |
jimfly01 | f6ba747 | 2018-12-04 10:09:52 +0000 | [diff] [blame] | 281 | std::string wMsg = warningMsg.str(); |
| 282 | BOOST_LOG_TRIVIAL(warning) << wMsg; |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 283 | if (errMessages) { |
jimfly01 | f6ba747 | 2018-12-04 10:09:52 +0000 | [diff] [blame] | 284 | errMessages.value().push_back(wMsg); |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 285 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 286 | } |
| 287 | else |
| 288 | { |
| 289 | found = true; |
David Beck | 263e349 | 2018-11-09 14:46:40 +0000 | [diff] [blame] | 290 | chosenBackends.insert(backend); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 291 | break; |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | // If the layer is unsupported by any devices, log and return a null network. |
| 296 | if (!found) { |
| 297 | // NOTE: if the layer is not an operation queue type AND we have not got CpuRef as a |
| 298 | // fallback we should set the compute device on the layer to CpuRef (these are not |
| 299 | // available as accelerated operations, or are only available under certain |
| 300 | // conditions, currently they comprise MemCopy, Constant, Permute) |
| 301 | armnn::LayerType layerType = layer->GetType(); |
| 302 | if (!cpuRefUsed && (layerType == armnn::LayerType::MemCopy || |
| 303 | layerType == armnn::LayerType::Constant || |
| 304 | layerType == armnn::LayerType::Permute)) |
| 305 | { |
David Beck | 33f0ae0 | 2018-10-18 15:13:56 +0100 | [diff] [blame] | 306 | layer->SetBackendId(armnn::Compute::CpuRef); |
David Beck | 263e349 | 2018-11-09 14:46:40 +0000 | [diff] [blame] | 307 | chosenBackends.insert(armnn::Compute::CpuRef); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 308 | } |
| 309 | else |
| 310 | { |
| 311 | return ReturnWithError(layer); |
| 312 | } |
| 313 | } |
| 314 | } |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 315 | if (bErrorFound) |
| 316 | { |
| 317 | return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy); |
| 318 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 319 | |
| 320 | Optimizer::Pass(optNetObjPtr->GetGraph(), MakeOptimizations(OptimizeInverseConversionsFp16(), |
| 321 | OptimizeInverseConversionsFp32())); |
| 322 | |
| 323 | optNetObjPtr->GetGraph().AddCopyLayers(); |
| 324 | |
| 325 | // Convert constants |
| 326 | Optimizer::Pass(optNetObjPtr->GetGraph(), MakeOptimizations(ConvertConstantsFloatToHalf())); |
| 327 | Optimizer::Pass(optNetObjPtr->GetGraph(), MakeOptimizations(ConvertConstantsHalfToFloat())); |
| 328 | |
David Beck | 263e349 | 2018-11-09 14:46:40 +0000 | [diff] [blame] | 329 | // Run backend specific optimizations |
| 330 | for (auto&& chosenBackend : chosenBackends) |
| 331 | { |
| 332 | auto factoryFun = BackendRegistryInstance().GetFactory(chosenBackend); |
| 333 | auto backendPtr = factoryFun(); |
| 334 | BOOST_ASSERT(backendPtr.get() != nullptr); |
| 335 | |
| 336 | auto backendSpecificOptimizations = backendPtr->GetOptimizations(); |
| 337 | if (!backendSpecificOptimizations.empty()) |
| 338 | { |
| 339 | Optimizer::Pass(optNetObjPtr->GetGraph(), backendSpecificOptimizations); |
| 340 | } |
| 341 | } |
| 342 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 343 | return optNet; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 344 | } |
| 345 | |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 346 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 347 | Network::Network() |
| 348 | : m_Graph(std::make_unique<Graph>()) |
| 349 | { |
| 350 | } |
| 351 | |
| 352 | Network::~Network() |
| 353 | { |
| 354 | } |
| 355 | |
| 356 | IConnectableLayer* Network::AddInputLayer(LayerBindingId id, const char* name) |
| 357 | { |
| 358 | return m_Graph->AddLayer<InputLayer>(id, name); |
| 359 | } |
| 360 | |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 361 | IConnectableLayer* Network::AddBatchToSpaceNdLayer(const BatchToSpaceNdDescriptor& batchToSpaceNdDescriptor, |
| 362 | const char* name) |
| 363 | { |
| 364 | return m_Graph->AddLayer<BatchToSpaceNdLayer>(batchToSpaceNdDescriptor, name); |
| 365 | } |
| 366 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 367 | IConnectableLayer* Network::AddFullyConnectedLayerImpl(const FullyConnectedDescriptor& fullyConnectedDescriptor, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 368 | const ConstTensor& weights, |
| 369 | const ConstTensor* biases, |
| 370 | const char* name) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 371 | { |
| 372 | if (fullyConnectedDescriptor.m_BiasEnabled && (biases == nullptr)) |
| 373 | { |
| 374 | throw InvalidArgumentException("AddFullyConnectedLayer: biases cannot be NULL"); |
| 375 | } |
| 376 | |
| 377 | const auto layer = m_Graph->AddLayer<FullyConnectedLayer>(fullyConnectedDescriptor, name); |
| 378 | |
| 379 | layer->m_Weight = std::make_unique<ScopedCpuTensorHandle>(weights); |
| 380 | |
| 381 | if (fullyConnectedDescriptor.m_BiasEnabled) |
| 382 | { |
| 383 | layer->m_Bias = std::make_unique<ScopedCpuTensorHandle>(*biases); |
| 384 | } |
| 385 | |
| 386 | return layer; |
| 387 | } |
| 388 | |
| 389 | IConnectableLayer* Network::AddFullyConnectedLayer(const FullyConnectedDescriptor& fullyConnectedDescriptor, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 390 | const ConstTensor& weights, |
| 391 | const char* name) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 392 | { |
| 393 | return AddFullyConnectedLayerImpl(fullyConnectedDescriptor, weights, nullptr, name); |
| 394 | } |
| 395 | |
| 396 | IConnectableLayer* Network::AddFullyConnectedLayer(const FullyConnectedDescriptor& fullyConnectedDescriptor, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 397 | const ConstTensor& weights, |
| 398 | const ConstTensor& biases, |
| 399 | const char* name) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 400 | { |
| 401 | return AddFullyConnectedLayerImpl(fullyConnectedDescriptor, weights, &biases, name); |
| 402 | } |
| 403 | |
| 404 | IConnectableLayer* Network::AddConvolution2dLayerImpl(const Convolution2dDescriptor& convolution2dDescriptor, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 405 | const ConstTensor& weights, |
| 406 | const ConstTensor* biases, |
| 407 | const char* name) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 408 | { |
| 409 | if (convolution2dDescriptor.m_BiasEnabled && (biases == nullptr)) |
| 410 | { |
| 411 | throw InvalidArgumentException("AddConvolution2dLayer: biases cannot be NULL"); |
| 412 | } |
| 413 | |
| 414 | const auto layer = m_Graph->AddLayer<Convolution2dLayer>(convolution2dDescriptor, name); |
| 415 | |
| 416 | layer->m_Weight = std::make_unique<ScopedCpuTensorHandle>(weights); |
| 417 | |
| 418 | if (convolution2dDescriptor.m_BiasEnabled) |
| 419 | { |
| 420 | layer->m_Bias = std::make_unique<ScopedCpuTensorHandle>(*biases); |
| 421 | } |
| 422 | |
| 423 | return layer; |
| 424 | } |
| 425 | |
| 426 | IConnectableLayer* Network::AddConvolution2dLayer(const Convolution2dDescriptor& convolution2dDescriptor, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 427 | const ConstTensor& weights, |
| 428 | const char* name) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 429 | { |
| 430 | return AddConvolution2dLayerImpl(convolution2dDescriptor, weights, nullptr, name); |
| 431 | } |
| 432 | IConnectableLayer* Network::AddConvolution2dLayer(const Convolution2dDescriptor& convolution2dDescriptor, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 433 | const ConstTensor& weights, |
| 434 | const ConstTensor& biases, |
| 435 | const char* name) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 436 | { |
| 437 | return AddConvolution2dLayerImpl(convolution2dDescriptor, weights, &biases, name); |
| 438 | } |
| 439 | |
| 440 | IConnectableLayer* Network::AddDepthwiseConvolution2dLayerImpl( |
| 441 | const DepthwiseConvolution2dDescriptor& convolution2dDescriptor, |
| 442 | const ConstTensor& weights, |
| 443 | const ConstTensor* biases, |
| 444 | const char* name) |
| 445 | { |
| 446 | if (convolution2dDescriptor.m_BiasEnabled && (biases == nullptr)) |
| 447 | { |
| 448 | throw InvalidArgumentException("AddDepthwiseConvolution2dLayer: biases cannot be NULL"); |
| 449 | } |
| 450 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 451 | const auto layer = m_Graph->AddLayer<DepthwiseConvolution2dLayer>(convolution2dDescriptor, |
| 452 | name); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 453 | |
| 454 | layer->m_Weight = std::make_unique<ScopedCpuTensorHandle>(weights); |
| 455 | |
| 456 | if (convolution2dDescriptor.m_BiasEnabled) |
| 457 | { |
| 458 | layer->m_Bias = std::make_unique<ScopedCpuTensorHandle>(*biases); |
| 459 | } |
| 460 | |
| 461 | return layer; |
| 462 | } |
| 463 | |
| 464 | IConnectableLayer* Network::AddDepthwiseConvolution2dLayer( |
| 465 | const DepthwiseConvolution2dDescriptor& convolution2dDescriptor, |
| 466 | const ConstTensor& weights, |
| 467 | const char* name) |
| 468 | { |
| 469 | return AddDepthwiseConvolution2dLayerImpl(convolution2dDescriptor, weights, nullptr, name); |
| 470 | } |
| 471 | IConnectableLayer* Network::AddDepthwiseConvolution2dLayer( |
| 472 | const DepthwiseConvolution2dDescriptor& convolution2dDescriptor, |
| 473 | const ConstTensor& weights, |
| 474 | const ConstTensor& biases, |
| 475 | const char* name) |
| 476 | { |
| 477 | return AddDepthwiseConvolution2dLayerImpl(convolution2dDescriptor, weights, &biases, name); |
| 478 | } |
| 479 | |
| 480 | IConnectableLayer* Network::AddPermuteLayer(const PermuteDescriptor& permuteDescriptor, |
| 481 | const char* name) |
| 482 | { |
| 483 | return m_Graph->AddLayer<PermuteLayer>(permuteDescriptor, name); |
| 484 | } |
| 485 | |
| 486 | IConnectableLayer* Network::AddPooling2dLayer(const Pooling2dDescriptor& pooling2dDescriptor, |
| 487 | const char* name) |
| 488 | { |
| 489 | return m_Graph->AddLayer<Pooling2dLayer>(pooling2dDescriptor, name); |
| 490 | } |
| 491 | |
| 492 | IConnectableLayer* Network::AddActivationLayer(const ActivationDescriptor& activationDescriptor, |
| 493 | const char* name) |
| 494 | { |
| 495 | return m_Graph->AddLayer<ActivationLayer>(activationDescriptor, name); |
| 496 | } |
| 497 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 498 | IConnectableLayer* Network::AddNormalizationLayer(const NormalizationDescriptor& |
| 499 | normalizationDescriptor, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 500 | const char* name) |
| 501 | { |
| 502 | return m_Graph->AddLayer<NormalizationLayer>(normalizationDescriptor, name); |
| 503 | } |
| 504 | |
| 505 | IConnectableLayer* Network::AddSoftmaxLayer(const SoftmaxDescriptor& softmaxDescriptor, |
| 506 | const char* name) |
| 507 | { |
| 508 | return m_Graph->AddLayer<SoftmaxLayer>(softmaxDescriptor, name); |
| 509 | } |
| 510 | |
| 511 | IConnectableLayer* Network::AddSplitterLayer(const ViewsDescriptor& splitterDescriptor, |
| 512 | const char* name) |
| 513 | { |
| 514 | return m_Graph->AddLayer<SplitterLayer>(splitterDescriptor, name); |
| 515 | } |
| 516 | |
Nattapat Chaimanowong | 5a4304a | 2018-11-28 10:44:37 +0000 | [diff] [blame] | 517 | IConnectableLayer* Network::AddMaximumLayer(const char* name) |
| 518 | { |
| 519 | return m_Graph->AddLayer<MaximumLayer>(name); |
| 520 | } |
| 521 | |
Éanna Ó Catháin | 20e5880 | 2018-12-04 10:29:06 +0000 | [diff] [blame] | 522 | IConnectableLayer* Network::AddMinimumLayer(const char* name) |
| 523 | { |
| 524 | return m_Graph->AddLayer<MinimumLayer>(name); |
| 525 | } |
| 526 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 527 | IConnectableLayer* Network::AddMergerLayer(const OriginsDescriptor& mergerDescriptor, |
| 528 | const char* name) |
| 529 | { |
| 530 | return m_Graph->AddLayer<MergerLayer>(mergerDescriptor, name); |
| 531 | } |
| 532 | |
| 533 | IConnectableLayer* Network::AddAdditionLayer(const char* name) |
| 534 | { |
| 535 | return m_Graph->AddLayer<AdditionLayer>(name); |
| 536 | } |
| 537 | |
| 538 | IConnectableLayer* Network::AddMultiplicationLayer(const char* name) |
| 539 | { |
| 540 | return m_Graph->AddLayer<MultiplicationLayer>(name); |
| 541 | } |
| 542 | |
| 543 | IConnectableLayer* Network::AddOutputLayer(LayerBindingId id, const char* name) |
| 544 | { |
| 545 | return m_Graph->AddLayer<OutputLayer>(id, name); |
| 546 | } |
| 547 | |
| 548 | IConnectableLayer* Network::AddBatchNormalizationLayer(const BatchNormalizationDescriptor& desc, |
| 549 | const ConstTensor& mean, |
| 550 | const ConstTensor& variance, |
| 551 | const ConstTensor& beta, |
| 552 | const ConstTensor& gamma, |
| 553 | const char* name) |
| 554 | { |
| 555 | const auto layer = m_Graph->AddLayer<BatchNormalizationLayer>(desc, name); |
| 556 | |
| 557 | layer->m_Mean = std::make_unique<ScopedCpuTensorHandle>(mean); |
| 558 | layer->m_Variance = std::make_unique<ScopedCpuTensorHandle>(variance); |
| 559 | layer->m_Beta = std::make_unique<ScopedCpuTensorHandle>(beta); |
| 560 | layer->m_Gamma = std::make_unique<ScopedCpuTensorHandle>(gamma); |
| 561 | |
| 562 | return layer; |
| 563 | } |
| 564 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 565 | IConnectableLayer* Network::AddResizeBilinearLayer(const ResizeBilinearDescriptor& |
| 566 | resizeDescriptor, const char* name) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 567 | { |
| 568 | return m_Graph->AddLayer<ResizeBilinearLayer>(resizeDescriptor,name); |
| 569 | } |
| 570 | |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 571 | IConnectableLayer* Network::AddL2NormalizationLayer(const L2NormalizationDescriptor& desc, |
| 572 | const char* name) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 573 | { |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 574 | return m_Graph->AddLayer<L2NormalizationLayer>(desc, name); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | IConnectableLayer* Network::AddConstantLayer(const ConstTensor& input, const char* name) |
| 578 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 579 | auto layer = m_Graph->AddLayer<ConstantLayer>(name); |
| 580 | |
| 581 | layer->m_LayerOutput = std::make_unique<ScopedCpuTensorHandle>(input); |
| 582 | |
| 583 | return layer; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 584 | } |
| 585 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 586 | IConnectableLayer* Network::AddReshapeLayer(const ReshapeDescriptor& reshapeDescriptor, |
| 587 | const char* name) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 588 | { |
| 589 | return m_Graph->AddLayer<ReshapeLayer>(reshapeDescriptor, name); |
| 590 | } |
| 591 | |
Nattapat Chaimanowong | 207ef9a | 2018-11-02 10:57:25 +0000 | [diff] [blame] | 592 | IConnectableLayer* Network::AddSpaceToBatchNdLayer(const SpaceToBatchNdDescriptor& spaceToBatchNdDescriptor, |
| 593 | const char* name) |
| 594 | { |
| 595 | return m_Graph->AddLayer<SpaceToBatchNdLayer>(spaceToBatchNdDescriptor, name); |
| 596 | } |
| 597 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 598 | IConnectableLayer* Network::AddFloorLayer(const char* name) |
| 599 | { |
| 600 | return m_Graph->AddLayer<FloorLayer>(name); |
| 601 | } |
| 602 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 603 | IConnectableLayer* Network::AddLstmLayer(const LstmDescriptor& descriptor, |
| 604 | const LstmInputParams& params, |
| 605 | const char* name) |
| 606 | { |
| 607 | const auto layer = m_Graph->AddLayer<LstmLayer>(descriptor, name); |
| 608 | |
| 609 | //Lstm Basic Parameters |
| 610 | layer->m_BasicParameters.m_InputToForgetWeights = |
| 611 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_InputToForgetWeights)); |
| 612 | layer->m_BasicParameters.m_InputToCellWeights = |
| 613 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_InputToCellWeights)); |
| 614 | layer->m_BasicParameters.m_InputToOutputWeights = |
| 615 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_InputToOutputWeights)); |
| 616 | layer->m_BasicParameters.m_RecurrentToForgetWeights = |
| 617 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_RecurrentToForgetWeights)); |
| 618 | layer->m_BasicParameters.m_RecurrentToCellWeights = |
| 619 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_RecurrentToCellWeights)); |
| 620 | layer->m_BasicParameters.m_RecurrentToOutputWeights = |
| 621 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_RecurrentToOutputWeights)); |
| 622 | layer->m_BasicParameters.m_ForgetGateBias = |
| 623 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_ForgetGateBias)); |
| 624 | layer->m_BasicParameters.m_CellBias = |
| 625 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_CellBias)); |
| 626 | layer->m_BasicParameters.m_OutputGateBias = |
| 627 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_OutputGateBias)); |
| 628 | |
| 629 | //Lstm Cifg parameters |
| 630 | if(!descriptor.m_CifgEnabled) |
| 631 | { |
| 632 | if(params.m_InputToInputWeights == nullptr) |
| 633 | { |
| 634 | throw InvalidArgumentException("AddLstmLayer: Input To Input Weights cannot be NULL"); |
| 635 | } |
| 636 | if(params.m_RecurrentToInputWeights == nullptr) |
| 637 | { |
| 638 | throw InvalidArgumentException( |
| 639 | "AddLstmLayer: Recurrent To Input Weights cannot be NULL"); |
| 640 | } |
| 641 | if(params.m_InputGateBias == nullptr) |
| 642 | { |
| 643 | throw InvalidArgumentException("AddLstmLayer: Input Gate Bias cannot be NULL"); |
| 644 | } |
| 645 | layer->m_CifgParameters.m_InputToInputWeights = |
| 646 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_InputToInputWeights)); |
| 647 | layer->m_CifgParameters.m_RecurrentToInputWeights = |
| 648 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_RecurrentToInputWeights)); |
| 649 | // In the VTS tests, cell-to-input weights may be null, even if the other CIFG params are not. |
| 650 | if(params.m_CellToInputWeights != nullptr) |
| 651 | { |
| 652 | layer->m_CifgParameters.m_CellToInputWeights = |
| 653 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_CellToInputWeights)); |
| 654 | } |
| 655 | layer->m_CifgParameters.m_InputGateBias = |
| 656 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_InputGateBias)); |
| 657 | } |
| 658 | |
| 659 | //Lstm projection parameters |
| 660 | if(descriptor.m_ProjectionEnabled) |
| 661 | { |
| 662 | if(params.m_ProjectionWeights == nullptr) |
| 663 | { |
| 664 | throw InvalidArgumentException("AddLstmLayer: Projection Weights cannot be NULL"); |
| 665 | } |
| 666 | layer->m_ProjectionParameters.m_ProjectionWeights = |
| 667 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_ProjectionWeights)); |
| 668 | if(params.m_ProjectionBias != nullptr) |
| 669 | { |
| 670 | layer->m_ProjectionParameters.m_ProjectionBias = |
| 671 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_ProjectionBias)); |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | //Lstm Peephole params |
| 676 | if(descriptor.m_PeepholeEnabled) |
| 677 | { |
| 678 | if(params.m_CellToForgetWeights == nullptr) |
| 679 | { |
| 680 | throw InvalidArgumentException("AddLstmLayer: Cell To Forget Weights cannot be NULL"); |
| 681 | } |
| 682 | if(params.m_CellToOutputWeights == nullptr) |
| 683 | { |
| 684 | throw InvalidArgumentException("AddLstmLayer: Cell To Output Weights cannot be NULL"); |
| 685 | } |
| 686 | layer->m_PeepholeParameters.m_CellToForgetWeights = |
| 687 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_CellToForgetWeights)); |
| 688 | layer->m_PeepholeParameters.m_CellToOutputWeights = |
| 689 | std::make_unique<ScopedCpuTensorHandle>(*(params.m_CellToOutputWeights)); |
| 690 | } |
| 691 | return layer; |
| 692 | } |
| 693 | |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 694 | IConnectableLayer* Network::AddDivisionLayer(const char* name) |
| 695 | { |
| 696 | return m_Graph->AddLayer<DivisionLayer>(name); |
| 697 | } |
| 698 | |
David Beck | 1952622 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 699 | IConnectableLayer* Network::AddSubtractionLayer(const char* name) |
| 700 | { |
| 701 | return m_Graph->AddLayer<SubtractionLayer>(name); |
| 702 | } |
| 703 | |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 704 | IConnectableLayer* Network::AddMeanLayer(const MeanDescriptor& meanDescriptor, const char* name) |
| 705 | { |
| 706 | return m_Graph->AddLayer<MeanLayer>(meanDescriptor,name); |
| 707 | } |
| 708 | |
Mohamed Nour Abouelseoud | 5662c20 | 2018-09-24 13:30:09 +0100 | [diff] [blame] | 709 | IConnectableLayer* Network::AddPadLayer(const PadDescriptor& padDescriptor, const char* name) |
| 710 | { |
| 711 | return m_Graph->AddLayer<PadLayer>(padDescriptor,name); |
| 712 | } |
| 713 | |
Conor Kennedy | 430b5d8 | 2018-11-14 15:28:28 +0000 | [diff] [blame] | 714 | IConnectableLayer* Network::AddStridedSliceLayer(const StridedSliceDescriptor& stridedSliceDescriptor, |
| 715 | const char* name) |
| 716 | { |
| 717 | return m_Graph->AddLayer<StridedSliceLayer>(stridedSliceDescriptor, name); |
| 718 | } |
| 719 | |
Matteo Martincigh | 59a950c | 2018-12-13 12:48:25 +0000 | [diff] [blame] | 720 | IConnectableLayer* Network::AddGreaterLayer(const char* name) |
| 721 | { |
| 722 | return m_Graph->AddLayer<GreaterLayer>(name); |
| 723 | } |
| 724 | |
FrancisMurtagh | 2099595 | 2018-12-17 12:11:36 +0000 | [diff] [blame^] | 725 | IConnectableLayer* Network::AddEqualLayer(const char* name) |
| 726 | { |
| 727 | return m_Graph->AddLayer<GreaterLayer>(name); |
| 728 | } |
| 729 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 730 | OptimizedNetwork::OptimizedNetwork(std::unique_ptr<Graph> graph) |
| 731 | : m_Graph(std::move(graph)) |
| 732 | { |
| 733 | } |
| 734 | |
| 735 | OptimizedNetwork::~OptimizedNetwork() |
| 736 | { |
| 737 | } |
| 738 | |
| 739 | } // namespace armnn |