/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import Foundation fileprivate var singletons : [String : Any] = [:] class OpCreator { static var shared : OpCreator

{ let key = String(describing: P.self) if let singleton = singletons[key] { return singleton as! OpCreator

} else { let newSingleton = OpCreator

() singletons[key] = newSingleton return newSingleton } } func creat(device: MTLDevice, opDesc: OpDesc, scope: Scope) throws -> Runable & InferShaperable { guard let opCreator = opCreators[opDesc.type] else { throw PaddleMobileError.opError(message: "there is no " + opDesc.type + " yet") } do { return try opCreator(device, opDesc, scope) } catch let error { throw error } } let opCreators: [String : (MTLDevice, OpDesc, Scope) throws -> Runable & InferShaperable] = [gConvType : ConvOp

.creat, gBatchNormType : BatchNormOp

.creat, gReluType : ReluOp

.creat, gElementwiseAddType : ElementwiseAddOp

.creat, gFeedType : FeedOp

.creat, gFetchType : FetchOp

.creat, gConvAddBatchNormReluType : ConvAddBatchNormReluOp

.creat, gPooType : PoolOp

.creat, gSoftmaxType : SoftmaxOp

.creat, gReshapeType : ReshapeOp

.creat, gConvAddType : ConvAddOp

.creat, gDepthConvType : DepthConvOp

.creat, gConcatType : ConcatOp

.creat, gBoxcoderType : BoxcoderOp

.creat, gConvBnReluType : ConvBNReluOp

.creat, gDwConvBnReluType : DwConvBNReluOp

.creat, gMulticlassNMSType : MulticlassNMSOp

.creat, gTransposeType : TransposeOp

.creat, gPriorBoxType : PriorBoxOp

.creat, gPreluType : PreluOp

.creat, gConv2dTransposeType : ConvTransposeOp

.creat, gResizeBilinearType : ResizeBilinearOp

.creat] private init(){} }