diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj b/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj index 7584d49711a0ecebd4e67dedbd3836ac44002f30..9f80a84acc4f475730cf686bd018922ecb769f4e 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj +++ b/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj @@ -494,19 +494,19 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = A798K58VVL; + CODE_SIGN_IDENTITY = "iPhone Distribution"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = 6T9LLJKSM4; INFOPLIST_FILE = "paddle-mobile-demo/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.baidu.paddle-mobile"; + PRODUCT_BUNDLE_IDENTIFIER = com.baidu.mms.qa; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE = ""; - PROVISIONING_PROFILE_SPECIFIER = ""; + PROVISIONING_PROFILE = "ba9c4b24-7bd0-49c5-93cd-e3051e775d6c"; + PROVISIONING_PROFILE_SPECIFIER = Distribution_MMS; SWIFT_OBJC_BRIDGING_HEADER = "paddle-mobile-demo/paddle-mobile-demo-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 4.0; @@ -520,19 +520,19 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = A798K58VVL; + CODE_SIGN_IDENTITY = "iPhone Distribution"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = 6T9LLJKSM4; INFOPLIST_FILE = "paddle-mobile-demo/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.baidu.paddle-mobile"; + PRODUCT_BUNDLE_IDENTIFIER = com.baidu.mms.qa; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE = ""; - PROVISIONING_PROFILE_SPECIFIER = ""; + PROVISIONING_PROFILE = "ba9c4b24-7bd0-49c5-93cd-e3051e775d6c"; + PROVISIONING_PROFILE_SPECIFIER = Distribution_MMS; SWIFT_OBJC_BRIDGING_HEADER = "paddle-mobile-demo/paddle-mobile-demo-Bridging-Header.h"; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/Net/Genet.swift b/metal/paddle-mobile-demo/paddle-mobile-demo/Net/Genet.swift index 0ba8c2f293d5b3e91d15effaf199acac99c29537..8b1d2c4ce4eb51e3fc8ca578b72fd3fd776faa89 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo/Net/Genet.swift +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/Net/Genet.swift @@ -31,7 +31,7 @@ class Genet: Net { } func resultStr(res: [Float]) -> String { - return " 哈哈 还没好 genet !"; + return " \(Array(res.suffix(10))) ... " } var preprocessKernel: CusomKernel diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/Net/MobileNetSSD.swift b/metal/paddle-mobile-demo/paddle-mobile-demo/Net/MobileNetSSD.swift index 0be1a9ee15d656c3338b18cde32ecadb6277e990..1349a93a4724e1ada91ea4d63638d56a55fcdb25 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo/Net/MobileNetSSD.swift +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/Net/MobileNetSSD.swift @@ -48,12 +48,12 @@ class MobileNet_ssd_hand: Net{ } var scoreFormatArr: [Float32] = score.metalTexture.realNHWC(dim: (n: score.padToFourDim[0], h: score.padToFourDim[1], w: score.padToFourDim[2], c: score.padToFourDim[3])) - print("score: ") - print(scoreFormatArr.strideArray()) - +// print("score: ") +// print(scoreFormatArr.strideArray()) +// var bboxArr = bbox.metalTexture.float32Array() - print("bbox: ") - print(bboxArr.strideArray()) +// print("bbox: ") +// print(bboxArr.strideArray()) let nmsCompute = NMSCompute.init() nmsCompute.scoreThredshold = 0.01 diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift b/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift index ecffd6af6d86b37492c0718acab77a712b9a8f33..47708a70c9f3c69a42c5ab220180ad6a4f695556 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift @@ -19,17 +19,18 @@ import MetalPerformanceShaders let threadSupport = [1] -let modelHelperMap: [SupportModel : Net] = [ .mobilenet : MobileNet.init(), .mobilenet_ssd : MobileNet_ssd_hand.init(), .genet : Genet.init()] +//.mobilenet : MobileNet.init(), +let modelHelperMap: [SupportModel : Net] = [.mobilenet_ssd : MobileNet_ssd_hand.init(), .genet : Genet.init()] //, .genet : Genet.init() //let modelHelperMap: [SupportModel : Net] = [.mobilenet : MobileNet.init(), .mobilenet_ssd : MobileNet_ssd_hand.init()] enum SupportModel: String{ - case mobilenet = "mobilenet" +// case mobilenet = "mobilenet" case mobilenet_ssd = "mobilenetssd" case genet = "genet" static func supportedModels() -> [SupportModel] { - // - return [.mobilenet, .mobilenet_ssd ,.genet] + //.mobilenet, + return [.mobilenet_ssd ,.genet] } } @@ -79,7 +80,7 @@ class ViewController: UIViewController { return } do { - let max = 1 + let max = 50 let startDate = Date.init() for i in 0.. { // print(stridableInput) // let _: Flo? = input.logDesc(header: "input: ", stridable: true) - for i in 0..: OperatorProtocol where let scope: Scope var kernel: KerType required init(device: MTLDevice, opDesc: OpDesc, inScope: Scope) throws { - print("create op: \(opDesc.type)") +// print("create op: \(opDesc.type)") type = opDesc.type scope = inScope inputs = opDesc.inputs diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BatchNormKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BatchNormKernel.swift index bf0a2959fa9627f5cbe994dcd183f9ed7f04456c..80145e677beb3f37e92257a56dc4e3c7b337e787 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BatchNormKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BatchNormKernel.swift @@ -63,7 +63,6 @@ class BatchNormKernel: Kernel, Computable { guard let encoder = commandBuffer.makeComputeCommandEncoder() else { throw PaddleMobileError.predictError(message: " encoder is nil") } - print("BatchNorm compute") encoder.setTexture(param.input.metalTexture, index: 0) encoder.setTexture(param.output.metalTexture, index: 1) encoder.setBuffer(newScale, offset: 0, index: 0) diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift index d2b54d9be60694871b4d4e3ba4bd3852bc94e875..d5aa98d2606ceda5cbcf0f3f4c1fc0ed2adeed25 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift @@ -59,14 +59,14 @@ class ConvAddKernel: Kernel, Computable { let offsetX = (Int(param.dilations[0]) * (param.filter.width - 1) + 1)/2 - Int(param.paddings[0]) - print(" function: \(functionName)") - print("offset x: \(offsetX)") - print("offset y: \(offsetY)") +// print(" function: \(functionName)") +// print("offset x: \(offsetX)") +// print("offset y: \(offsetY)") let offsetZ = 0.0 let inMetalParam = MetalConvParam.init(offsetX: Int16(offsetX), offsetY: Int16(offsetY), offsetZ: Int16(offsetZ), strideX: UInt16(param.stride[0]), strideY: UInt16(param.stride[1]), dilationX: UInt16(param.dilations[0]), dilationY: UInt16(param.dilations[1])) - print("metal param: ") - print(inMetalParam) +// print("metal param: ") +// print(inMetalParam) metalParam = inMetalParam } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvBNReluKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvBNReluKernel.swift index bbf4eeaaf41e321f2c7c469011f1a243ef035107..e79f8f9be37c2575b28aef2e9169ab814c9587fe 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvBNReluKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvBNReluKernel.swift @@ -88,17 +88,16 @@ class ConvBNReluKernel: Kernel, Computable, Testable { let offsetX = param.filter.width/2 - Int(param.paddings[0]) let offsetY = param.filter.height/2 - Int(param.paddings[1]) - print(" param filter width: \(param.filter.width)") - print(" param filter height: \(param.filter.height)") - - print(" param paddings: \(param.paddings)") - - print("ConvBNReluKernel offset x: \(offsetX)") - print("ConvBNReluKernel offset y: \(offsetY)") +// print(" param filter width: \(param.filter.width)") +// print(" param filter height: \(param.filter.height)") +// +// print(" param paddings: \(param.paddings)") +// +// print("ConvBNReluKernel offset x: \(offsetX)") +// print("ConvBNReluKernel offset y: \(offsetY)") let offsetZ = 0.0 - print(" fuck ") metalParam = MetalConvParam.init(offsetX: Int16(offsetX), offsetY: Int16(offsetY), offsetZ: Int16(offsetZ), strideX: UInt16(param.stride[0]), strideY: UInt16(param.stride[1]), dilationX: UInt16(param.dilations[0]), dilationY: UInt16(param.dilations[1])) var invs: [P] = [] diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/SoftmaxKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/SoftmaxKernel.swift index 6fd34702980718c1211947184e7d68e12c16ab14..e0bcaeaa73f15cc4f43186c01c0394da6e447946 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/SoftmaxKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/SoftmaxKernel.swift @@ -43,7 +43,6 @@ class SoftmaxKernel: Kernel, Computable{ } encoder.setTexture(param.input.metalTexture, index: 0) encoder.setTexture(param.output.metalTexture, index: 1) - encoder.setBytes(&metalParam, length: MemoryLayout.size, index: 0) encoder.dispatch(computePipline: pipline, outTexture: param.output.metalTexture) encoder.endEncoding() diff --git a/metal/paddle-mobile/paddle-mobile/framework/Texture.swift b/metal/paddle-mobile/paddle-mobile/framework/Texture.swift index d3beb92a5fa30dfae5ddbbcd8bb7563b791771e4..c6e8842182116001ceaa89510389cca29f1f7d7e 100644 --- a/metal/paddle-mobile/paddle-mobile/framework/Texture.swift +++ b/metal/paddle-mobile/paddle-mobile/framework/Texture.swift @@ -50,7 +50,7 @@ public class Texture: Tensorial { guard padToFourDim.cout() == 4 else { fatalError("- not support -") } - return metalTexture.toTensor(dim: (n: padToFourDim[0], c: padToFourDim[1], h: padToFourDim[2], w: padToFourDim[3])) + return metalTexture.toTensor(dim: (n: dim[0], c: dim[3], h: dim[1], w: dim[2])) } func realNHWC() -> [Float32] {