diff --git a/metal/paddle-mobile-metallib/paddle-mobile-metallib.xcodeproj/project.pbxproj b/metal/paddle-mobile-metallib/paddle-mobile-metallib.xcodeproj/project.pbxproj index 007fd5e42982539dd9872cce4f2cead5727fde8d..9eef77e7f12b7a15a0f43ecfb3b105f95cadfb8f 100644 --- a/metal/paddle-mobile-metallib/paddle-mobile-metallib.xcodeproj/project.pbxproj +++ b/metal/paddle-mobile-metallib/paddle-mobile-metallib.xcodeproj/project.pbxproj @@ -352,6 +352,7 @@ buildSettings = { CODE_SIGN_STYLE = Automatic; MTL_ENABLE_DEBUG_INFO = NO; + MTL_LANGUAGE_REVISION = iOSMetal10; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -362,6 +363,7 @@ buildSettings = { CODE_SIGN_STYLE = Automatic; MTL_ENABLE_DEBUG_INFO = NO; + MTL_LANGUAGE_REVISION = iOSMetal10; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; diff --git a/metal/paddle-mobile/paddle-mobile.xcodeproj/project.pbxproj b/metal/paddle-mobile/paddle-mobile.xcodeproj/project.pbxproj index 14cfcb3a92158fa9d98d2d2574ccc23eaa3f5477..4b3dd397deaec378415417c0bbf822182b1fce36 100644 --- a/metal/paddle-mobile/paddle-mobile.xcodeproj/project.pbxproj +++ b/metal/paddle-mobile/paddle-mobile.xcodeproj/project.pbxproj @@ -17,9 +17,9 @@ 4AA1EA942146661500D0F791 /* ShapeKernel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA1EA932146661500D0F791 /* ShapeKernel.swift */; }; 4AA1EA982146666500D0F791 /* FlattenOp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA1EA972146666500D0F791 /* FlattenOp.swift */; }; 4AA1EAA2214912CD00D0F791 /* FlattenKernel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA1EAA1214912CC00D0F791 /* FlattenKernel.swift */; }; - C28FE02F21BA68C00054EFAC /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C28FE02C21BA68C00054EFAC /* Metal.framework */; }; - C28FE03021BA68C00054EFAC /* MetalPerformanceShaders.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C28FE02D21BA68C00054EFAC /* MetalPerformanceShaders.framework */; }; - C28FE03121BA68C00054EFAC /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C28FE02E21BA68C00054EFAC /* MetalKit.framework */; }; + C28FE02F21BA68C00054EFAC /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C28FE02C21BA68C00054EFAC /* Metal.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; + C28FE03021BA68C00054EFAC /* MetalPerformanceShaders.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C28FE02D21BA68C00054EFAC /* MetalPerformanceShaders.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; + C28FE03121BA68C00054EFAC /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C28FE02E21BA68C00054EFAC /* MetalKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; D3831F70E7E0B565B9AC22DA /* Pods_paddle_mobile.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD2E06330A1E7129C918DB46 /* Pods_paddle_mobile.framework */; }; FC039B6F20E11C3C0081E9F8 /* paddle_mobile.h in Headers */ = {isa = PBXBuildFile; fileRef = FC039B6D20E11C3C0081E9F8 /* paddle_mobile.h */; settings = {ATTRIBUTES = (Public, ); }; }; FC039B9720E11C9A0081E9F8 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC039B9420E11C9A0081E9F8 /* Extensions.swift */; }; diff --git a/metal/paddle-mobile/paddle-mobile/Src/Common/Types.swift b/metal/paddle-mobile/paddle-mobile/Src/Common/Types.swift index 21a9f4385d7205c02414634e042c1e958d1ab120..2267d173ef17545f412274c0cf82dc14ec268e5c 100644 --- a/metal/paddle-mobile/paddle-mobile/Src/Common/Types.swift +++ b/metal/paddle-mobile/paddle-mobile/Src/Common/Types.swift @@ -22,8 +22,6 @@ public protocol SummableMultipliable: Equatable { } public protocol PrecisionProtocol: SummableMultipliable{ - init(inFloat: Float32) - init(inFloat16: Float16) init(_ inP: P) static var bitSize: UInt { get } static func initializeValue() -> Self @@ -42,11 +40,12 @@ extension Float16: PrecisionProtocol { } public init

(_ inP: P) where P : PrecisionProtocol { - if P.bitSize == Float32.bitSize { - self = Float16(inFloat: inP as! Float32) - } else if P.bitSize == Float16.bitSize { - self = inP as! Float16 - } else { + switch P.precisionType { + case .Float32: + fatalError() + case .Float16: + self = inP as! Int16 + default: fatalError() } } @@ -55,12 +54,6 @@ extension Float16: PrecisionProtocol { return 16 } - public init(inFloat16: Float16) { - self = inFloat16 - } - public init(inFloat: Float32) { - self = Int16(inFloat) - } } extension Float32: PrecisionProtocol { @@ -74,23 +67,16 @@ extension Float32: PrecisionProtocol { } public init

(_ inP: P) where P : PrecisionProtocol { - if P.bitSize == Float32.bitSize { + switch P.precisionType { + case .Float32: self = inP as! Float32 - } else if P.bitSize == Float16.bitSize { - self = Float32.init(inP as! Float16) - } else { + case .Float16: + self = Float32.init(Int32.init(inP as! Int16)) + default: fatalError() } } - public init(inFloat: Float32) { - self = inFloat - } - - public init(inFloat16: Float16) { - self = Float32.init(inFloat16) - } - public static var bitSize: UInt { return 32 } diff --git a/metal/paddle-mobile/paddle-mobile/Src/Framework/Loader.swift b/metal/paddle-mobile/paddle-mobile/Src/Framework/Loader.swift index c437d284ccff5fd76d4bda26bc011083a8aeb998..afd75e82d19d431e72f25f2a379fa35328dd98a3 100644 --- a/metal/paddle-mobile/paddle-mobile/Src/Framework/Loader.swift +++ b/metal/paddle-mobile/paddle-mobile/Src/Framework/Loader.swift @@ -161,8 +161,9 @@ public class Loader: Loaderable{ let programDesc = ProgramOptimize

.init().optimize(originProgramDesc: originProgramDesc) // let programDesc = PMProgramDesc.init(protoProgram: protoProgram) - - print(programDesc) + if GlobalConfig.shared.debug { + print(programDesc) + } guard programDesc.blocks.count > 0 else { throw PaddleMobileError.loaderError(message: "count of blocks must greater than 0") diff --git a/metal/paddle-mobile/paddle-mobile/Src/Framework/Texture.swift b/metal/paddle-mobile/paddle-mobile/Src/Framework/Texture.swift index 72195a22ea5fdde4f8c813c5c4863a9b9850e7f2..9c60909e60dd9619c64bec2d1db40bad3710a1d8 100644 --- a/metal/paddle-mobile/paddle-mobile/Src/Framework/Texture.swift +++ b/metal/paddle-mobile/paddle-mobile/Src/Framework/Texture.swift @@ -165,7 +165,9 @@ public class Texture: Tensorial { // 初始化时 dim padToFourDim 模型中的维度(一般来说 nchw),前面补全0 init(device: MTLDevice, inDim: Dim) { - print(" in dim > \(inDim)") + if GlobalConfig.shared.debug { + print(" in dim > \(inDim)") + } var fourDim: Dim if inDim.cout() == 4 { fourDim = inDim diff --git a/metal/paddle-mobile/paddle-mobile/Src/Program/ProgramOptimize.swift b/metal/paddle-mobile/paddle-mobile/Src/Program/ProgramOptimize.swift index aaf1da12382072efacfbb2dd91755b8d4f36f639..8637f7683cb5bca514e1d5c3f73a80ec0f016de2 100644 --- a/metal/paddle-mobile/paddle-mobile/Src/Program/ProgramOptimize.swift +++ b/metal/paddle-mobile/paddle-mobile/Src/Program/ProgramOptimize.swift @@ -203,7 +203,9 @@ class ProgramOptimize { var typeMapNodes: [String : [(node: Node, output: [String : Node])]] = [:] let block = originProgramDesc.blocks[0] for opDesc in block.ops { - print(opDesc.type) + if GlobalConfig.shared.debug { + print(opDesc.type) + } guard let opInputKeys = opInfos[opDesc.type]?.inputs, let outputKeys = opInfos[opDesc.type]?.outputs else { fatalError() }