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 776c7d992c0e28844375dad6210921a91fefc6af..b4e8dae35f692c91c765d0e77c0d7841b48a2414 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj +++ b/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj @@ -32,7 +32,7 @@ FCEBEC2C20E1391F00C0B14D /* paddle_mobile.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FCEBEC2B20E1391F00C0B14D /* paddle_mobile.framework */; }; FCEBEC2D20E1391F00C0B14D /* paddle_mobile.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FCEBEC2B20E1391F00C0B14D /* paddle_mobile.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; FCEEE7D4210627A000444BEC /* banana.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = FCEEE7D3210627A000444BEC /* banana.jpeg */; }; - FCF437E8214B6DDB00943429 /* Multi-Predict-ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCF437E7214B6DDB00943429 /* Multi-Predict-ViewController.swift */; }; + FCF437E8214B6DDB00943429 /* MultiPredictViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCF437E7214B6DDB00943429 /* MultiPredictViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -80,7 +80,7 @@ FCDFD41A211D91C7005AB38B /* synset.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = synset.txt; sourceTree = ""; }; FCEBEC2B20E1391F00C0B14D /* paddle_mobile.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = paddle_mobile.framework; sourceTree = BUILT_PRODUCTS_DIR; }; FCEEE7D3210627A000444BEC /* banana.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = banana.jpeg; sourceTree = ""; }; - FCF437E7214B6DDB00943429 /* Multi-Predict-ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Multi-Predict-ViewController.swift"; sourceTree = ""; }; + FCF437E7214B6DDB00943429 /* MultiPredictViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiPredictViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -147,7 +147,7 @@ FC039B8A20E11C560081E9F8 /* LaunchScreen.storyboard */, FC039B8D20E11C560081E9F8 /* Info.plist */, FC27991121343A39000B6BAD /* paddle-mobile-demo-Bridging-Header.h */, - FCF437E7214B6DDB00943429 /* Multi-Predict-ViewController.swift */, + FCF437E7214B6DDB00943429 /* MultiPredictViewController.swift */, ); path = "paddle-mobile-demo"; sourceTree = ""; @@ -361,7 +361,7 @@ FC039B8420E11C550081E9F8 /* ViewController.swift in Sources */, FC803BCE214D27930094B8E5 /* VideoCapture.swift in Sources */, FC013928210204A3008100E3 /* PreProcessKernel.metal in Sources */, - FCF437E8214B6DDB00943429 /* Multi-Predict-ViewController.swift in Sources */, + FCF437E8214B6DDB00943429 /* MultiPredictViewController.swift in Sources */, FCBCCC552122EF5500D94F7E /* MetalHelper.swift in Sources */, FC803BCD214D27930094B8E5 /* FPSCounter.swift in Sources */, FC039B8220E11C550081E9F8 /* AppDelegate.swift in Sources */, diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/xcuserdata/liuruilong.xcuserdatad/xcschemes/paddle-mobile-demo.xcscheme b/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/xcuserdata/liuruilong.xcuserdatad/xcschemes/paddle-mobile-demo.xcscheme index de579675e07b8ffb8869464bebe203b591fa7778..46c65bd36a9ab7027b1cb7a81533dcd553ccb62e 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/xcuserdata/liuruilong.xcuserdatad/xcschemes/paddle-mobile-demo.xcscheme +++ b/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/xcuserdata/liuruilong.xcuserdatad/xcschemes/paddle-mobile-demo.xcscheme @@ -42,7 +42,7 @@ - + @@ -50,7 +50,7 @@ - - + diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/Multi-Predict-ViewController.swift b/metal/paddle-mobile-demo/paddle-mobile-demo/MultiPredictViewController.swift similarity index 96% rename from metal/paddle-mobile-demo/paddle-mobile-demo/Multi-Predict-ViewController.swift rename to metal/paddle-mobile-demo/paddle-mobile-demo/MultiPredictViewController.swift index 6948340a1873f86bd3ac76e0097974a9454d4528..6224322e336b5efdef00010bb604406f564b54bd 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo/Multi-Predict-ViewController.swift +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/MultiPredictViewController.swift @@ -9,7 +9,7 @@ import UIKit import paddle_mobile -class Multi_Predict_ViewController: UIViewController { +class MultiPredictViewController: UIViewController { var runner1: Runner! var runner2: Runner! override func viewDidLoad() { diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift b/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift index b360701c51168fdbbf4b43bdf7884a647c164ae0..006bfa747021ce600960a2c7eff8cb25ab42a659 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift @@ -18,8 +18,8 @@ import CoreMedia import paddle_mobile import MetalPerformanceShaders -let platform: Platform = .GPU -let threadSupport = [1] +var platform: Platform = .GPU +let threadSupport: [(Platform, String)] = [(.GPU, "GPU"), (.CPU, "CPU")] //.mobilenet_ssd : Runner.init(inNet: MobileNet_ssd_hand.init(device: MetalHelper.shared.device), commandQueue: MetalHelper.shared.queue, inPlatform: platform), let modelHelperMap: [SupportModel : Runner] = [ @@ -28,6 +28,8 @@ let modelHelperMap: [SupportModel : Runner] = [ //, .genet : Genet.init() //let modelHelperMap: [SupportModel : Net] = [.mobilenet : MobileNet.init(), .mobilenet_ssd : MobileNet_ssd_hand.init()] +let netSupport: [SupportModel : Net] = [.genet : Genet.init(device: MetalHelper.shared.device), .mobilenet_ssd_ar : MobileNet_ssd_AR.init(device: MetalHelper.shared.device)] + enum SupportModel: String{ // case mobilenet = "mobilenet" // case mobilenet_ssd = "mobilenetssd" @@ -55,17 +57,28 @@ class ViewController: UIViewController { var modelType: SupportModel = SupportModel.supportedModels()[0] var toPredictTexture: MTLTexture? - var runner: Runner { - get { - return modelHelperMap[modelType] ?! " has no this type " - } - set { - } - } + var runner: Runner! var threadNum = 1 @IBAction func loadAct(_ sender: Any) { + runner = Runner.init(inNet: netSupport[modelType]!, commandQueue: MetalHelper.shared.queue, inPlatform: platform) + + if platform == .CPU { + if inputPointer == nil { + inputPointer = runner.preproccess(image: selectImage!.cgImage!) + + } + } else if platform == .GPU { + if self.toPredictTexture == nil { + runner.getTexture(image: selectImage!.cgImage!) {[weak self] (texture) in + self?.toPredictTexture = texture + } + } + } else { + fatalError( " unsupport " ) + } + if runner.load() { print(" load success ! ") } else { @@ -128,6 +141,7 @@ class ViewController: UIViewController { for _ in 0..<10 { runner.predict(inputPointer: inInputPointer) { (success, res) in + res?.releaseOutput() } } @@ -146,6 +160,7 @@ class ViewController: UIViewController { } } } + res?.releaseOutput() } } } @@ -168,15 +183,15 @@ class ViewController: UIViewController { selectImage = UIImage.init(named: "hand.jpg") selectImageView.image = selectImage - if platform == .CPU { - inputPointer = runner.preproccess(image: selectImage!.cgImage!) - } else if platform == .GPU { - runner.getTexture(image: selectImage!.cgImage!) {[weak self] (texture) in - self?.toPredictTexture = texture - } - } else { - fatalError( " unsupport " ) - } +// if platform == .CPU { +// inputPointer = runner.preproccess(image: selectImage!.cgImage!) +// } else if platform == .GPU { +// runner.getTexture(image: selectImage!.cgImage!) {[weak self] (texture) in +// self?.toPredictTexture = texture +// } +// } else { +// fatalError( " unsupport " ) +// } // videoCapture = VideoCapture.init(device: MetalHelper.shared.device, orientation: .portrait, position: .back) // videoCapture.fps = 30 @@ -219,7 +234,7 @@ extension ViewController: UIPickerViewDataSource, UIPickerViewDelegate{ if pickerView == modelPickerView { return SupportModel.supportedModels()[row].rawValue } else if pickerView == threadPickerView { - return "\(threadSupport[row])" + return threadSupport[row].1 } else { fatalError() } @@ -229,7 +244,8 @@ extension ViewController: UIPickerViewDataSource, UIPickerViewDelegate{ if pickerView == modelPickerView { self.modelType = SupportModel.supportedModels()[row] } else if pickerView == threadPickerView { - self.threadNum = threadSupport[row] + + platform = threadSupport[row].0 } else { fatalError() } diff --git a/metal/paddle-mobile/paddle-mobile.xcodeproj/xcuserdata/liuruilong.xcuserdatad/xcschemes/paddle-mobile.xcscheme b/metal/paddle-mobile/paddle-mobile.xcodeproj/xcuserdata/liuruilong.xcuserdatad/xcschemes/paddle-mobile.xcscheme index d36d4c485d931d1df4e2d285a67fe33a99414190..7c83f42ceca9f68af4f45064cb29c9e3a3512b8e 100644 --- a/metal/paddle-mobile/paddle-mobile.xcodeproj/xcuserdata/liuruilong.xcuserdatad/xcschemes/paddle-mobile.xcscheme +++ b/metal/paddle-mobile/paddle-mobile.xcodeproj/xcuserdata/liuruilong.xcuserdatad/xcschemes/paddle-mobile.xcscheme @@ -33,7 +33,7 @@ #import -@interface PaddleMobile : NSObject +@interface PaddleMobileCPUResult: NSObject + +@property (assign, nonatomic, readonly) float *output; + +@property (assign, nonatomic, readonly) int outputSize; + +-(void)releaseOutput; + +@end + +@interface PaddleMobileCPU : NSObject /* 创建对象 @@ -42,25 +52,8 @@ andModelParamsLen:(size_t)combinedParamsLen andCombinedParamsBuf:(const uint8_t *)combinedParamsBuf; - -/* - * 进行预测, means 和 scale 为训练模型时的预处理参数, 如训练时没有做这些预处理则直接使用 predict - */ -- (NSArray *)predict:(CGImageRef)image - dim:(NSArray *)dim - means:(NSArray *)means - scale:(float)scale; - /* - * 预测输入 - * */ -- (NSArray *)predictInput:(float *)input - dim:(NSArray *)dim - means:(NSArray *)means - scale:(float)scale; - -/* - * 对图像进行预处理 + * 对图像进行预处理, 需要外部开辟 output 内存, 外部释放 output 内存 * */ -(void)preprocess:(CGImageRef)image output:(float *)output @@ -68,6 +61,22 @@ scale:(float)scale dim:(NSArray *)dim; +/* + * 预测预处理后的数据, 返回结果使用结束需要调用其 realseOutput 函数进行释放 + * */ +- (PaddleMobileCPUResult *)predictInput:(float *)input + dim:(NSArray *)dim; + +/* + 进行预测, means 和 scale 为训练模型时的预处理参数, 如训练时没有做这些预处理则直接使用 predict +*/ +- (NSArray *)predict:(CGImageRef)image dim:(NSArray *)dim means:(NSArray *)means scale:(float)scale; + +/* + 进行预测, 默认 means 为 0, scale 为 1.0 +*/ +- (NSArray *)predict:(CGImageRef)image dim:(NSArray *)dim; + /* 清理内存 */ diff --git a/metal/paddle-mobile/paddle-mobile/CPU/libpaddle-mobile.a b/metal/paddle-mobile/paddle-mobile/CPU/libpaddle-mobile.a deleted file mode 100644 index 9185441567a1ff772ac12aaf7b1f4e8ff1e64cc3..0000000000000000000000000000000000000000 Binary files a/metal/paddle-mobile/paddle-mobile/CPU/libpaddle-mobile.a and /dev/null differ diff --git a/metal/paddle-mobile/paddle-mobile/MobilenetSSD_AR.swift b/metal/paddle-mobile/paddle-mobile/MobilenetSSD_AR.swift index c3878688b95e15e79276762b8aef1ee03b5c1af5..c4307f22c179f549dfa352364f6baa38ac92bd97 100644 --- a/metal/paddle-mobile/paddle-mobile/MobilenetSSD_AR.swift +++ b/metal/paddle-mobile/paddle-mobile/MobilenetSSD_AR.swift @@ -82,4 +82,60 @@ public class MobileNet_ssd_AR: Net{ // print(resultHolder.result![0]) return resultHolder } + + override func updateProgram(program: Program) { + for i in [56, 66, 76, 86, 93, 99] { + let opDesc = program.programDesc.blocks[0].ops[i] + let output = opDesc.outputs["Out"]!.first! + let v = program.scope[output]! + let originTexture = v as! Texture + originTexture.tensorDim = Dim.init(inDim: [originTexture.tensorDim[1] / 7, originTexture.tensorDim[0] * 7]) + + originTexture.dim = Dim.init(inDim: [1, 1, originTexture.dim[3] / 7, originTexture.dim[2] * 7]) + + originTexture.padToFourDim = Dim.init(inDim: [1, 1, originTexture.padToFourDim[3] / 7, originTexture.padToFourDim[2] * 7]) + + program.scope[output] = originTexture + + if i == 99 { + opDesc.attrs["axis"] = 0 + } else { + opDesc.attrs["shape"] = originTexture.tensorDim.dims.map { Int32($0) } + } + } + + for i in [58, 59, 88, 89, 95, 96, 68, 69, 78, 79] { + let opDesc = program.programDesc.blocks[0].ops[i] + let output = opDesc.outputs["Out"]!.first! + let v = program.scope[output]! + + + + let originTexture = v as! Texture + originTexture.tensorDim = Dim.init(inDim: [originTexture.tensorDim[1], originTexture.tensorDim[2]]) + opDesc.attrs["shape"] = originTexture.tensorDim.dims.map { Int32($0) } + } + + for i in [60, 101, 90, 97, 70, 80] { + let opDesc = program.programDesc.blocks[0].ops[i] + let output = opDesc.outputs["Out"]!.first! + let v = program.scope[output]! + let originTexture = v as! Texture + originTexture.tensorDim = Dim.init(inDim: [originTexture.tensorDim[1], originTexture.tensorDim[2]]) + opDesc.attrs["axis"] = (opDesc.attrs["axis"]! as! Int) - 1 + } + + for i in [102] { + let opDesc = program.programDesc.blocks[0].ops[i] + for output in opDesc.outputs["Out"]! { + let v = program.scope[output]! + let originTexture = v as! Texture + originTexture.tensorDim = Dim.init(inDim: [originTexture.tensorDim[1], originTexture.tensorDim[2]]) + } + opDesc.attrs["axis"] = (opDesc.attrs["axis"]! as! Int) - 1 + print(" split axis \(opDesc.attrs["axis"])") + } + // 99 + } + } diff --git a/metal/paddle-mobile/paddle-mobile/Net.swift b/metal/paddle-mobile/paddle-mobile/Net.swift index 99476c5dc11769ee259bdf1b49c6bf7cfc5578ce..ccc01778cb53eadc6ce346edbd1669a6af51a3b4 100644 --- a/metal/paddle-mobile/paddle-mobile/Net.swift +++ b/metal/paddle-mobile/paddle-mobile/Net.swift @@ -55,4 +55,8 @@ public class Net: NSObject { @objc public init(device: MTLDevice) { super.init() } + + func updateProgram(program: Program) { + + } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConcatKernel.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConcatKernel.metal index dd11938a30b76f01c21686382abb1f95051f4d2e..b7d17f2d25de544e4ce938c577e0d04f536da9af 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConcatKernel.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConcatKernel.metal @@ -125,7 +125,6 @@ struct ConcatParam { #undef R #undef V - #define V VNORMAL #define R 4 #define N 2 @@ -138,3 +137,35 @@ struct ConcatParam { #undef N #undef R #undef V + + +#define V VY + #define R 2 + #define N 2 + #define P float + #include "ConcatKernel.inc.metal" + #undef P + #define P half + #include "ConcatKernel.inc.metal" + #undef P + #undef N + #undef R +#undef V + + +#define V VY + #define R 2 + #define N 5 + #define P float + #include "ConcatKernel.inc.metal" + #undef P + #define P half + #include "ConcatKernel.inc.metal" + #undef P + #undef N + #undef R +#undef V + + + + diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Split.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Split.metal index 914ab6d925234947db38df739da4af2dd076083e..4c1e818d2bf5c7266169f406fbfaf8e322685dc4 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Split.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/Split.metal @@ -48,3 +48,17 @@ struct SplitParam { #undef R #undef V + +//// ssd-ar: (R=2, N=2, V=y) +#define V VY + #define R 2 + #define N 2 + #define P float + #include "Split.inc.metal" + #undef P + #define P half + #include "Split.inc.metal" + #undef P + #undef N + #undef R +#undef V diff --git a/metal/paddle-mobile/paddle-mobile/Operators/SplitOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/SplitOp.swift index b68d38e57340bb74b62f06db5b9e984da162dc1e..7d26d6a38c696089a346165ad08d5ba655cffd59 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/SplitOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/SplitOp.swift @@ -39,6 +39,7 @@ class SplitParam: OpParam { throw error } } + var axis: Int let input: Texture

var output: Texture

diff --git a/metal/paddle-mobile/paddle-mobile/PaddleMobile.swift b/metal/paddle-mobile/paddle-mobile/PaddleMobile.swift index 3e6b9f2e3d85ff235aa7a6f1c0cb13c519dc53b9..c725040f859ede4260b6d17c871355cbcdb93a0d 100644 --- a/metal/paddle-mobile/paddle-mobile/PaddleMobile.swift +++ b/metal/paddle-mobile/paddle-mobile/PaddleMobile.swift @@ -34,7 +34,7 @@ public class Runner: NSObject { public let net: Net let device: MTLDevice? let platform: Platform - var cpuPaddleMobile: PaddleMobile? + var cpuPaddleMobile: PaddleMobileCPU? let numel: Int let meansNumber: [NSNumber] @@ -54,7 +54,7 @@ public class Runner: NSObject { textureLoader = MTKTextureLoader.init(device: inDevice) } if platform == .CPU { - cpuPaddleMobile = PaddleMobile.init() + cpuPaddleMobile = PaddleMobileCPU.init() } numel = net.dim.n * net.dim.c * net.dim.h * net.dim.w meansNumber = net.means.map { NSNumber.init(value: $0) } @@ -76,6 +76,7 @@ public class Runner: NSObject { let loader = Loader.init() do { program = try loader.load(device: inDevice, modelPath: net.modelPath, paraPath: net.paramPath) + net.updateProgram(program: program!) executor = try Executor.init(inDevice: inDevice, inQueue: inQueue, inProgram: program!) } catch let error { print(error) @@ -87,12 +88,13 @@ public class Runner: NSObject { return true } - @objc public func predict(inputPointer: UnsafeMutablePointer, completion: @escaping ( _ success: Bool, _ resultArray: [Float32]) -> Void) { - guard let res = cpuPaddleMobile?.predictInput(inputPointer, dim: dimsNum, means: meansNumber, scale: net.scale) else { - completion(false, []) + @objc public func predict(inputPointer: UnsafeMutablePointer, completion: @escaping ( _ success: Bool, _ result: PaddleMobileCPUResult?) -> Void) { + + guard let res = cpuPaddleMobile?.predictInput(inputPointer, dim: dimsNum) else { + completion(false, nil) return } - completion(true, res.map { ($0 as! NSNumber).floatValue }) + completion(true, res) } /** diff --git a/metal/paddle-mobile/paddle-mobile/Program/BlockDesc.swift b/metal/paddle-mobile/paddle-mobile/Program/BlockDesc.swift index f1a94e4e2af39c3d79681e1b41a13149e3a290fa..98dd7ff39a71cadfe6cc33f3d468448ac5155242 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/BlockDesc.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/BlockDesc.swift @@ -14,7 +14,7 @@ import Foundation -struct BlockDesc { +class BlockDesc { let index: Int let parentIndex: Int let vars: [VarDesc] diff --git a/metal/paddle-mobile/paddle-mobile/Program/OpDesc.swift b/metal/paddle-mobile/paddle-mobile/Program/OpDesc.swift index 45f5d529503c7e985917a5e789b02b0bdbfc767e..44fc09a29db0deec67e7682b303b1d0947b47a51 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/OpDesc.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/OpDesc.swift @@ -14,7 +14,7 @@ import Foundation -struct OpDesc { +class OpDesc { let inputs: [String : [String]] var paraInputs: [String : [String]] var outputs: [String : [String]] diff --git a/metal/paddle-mobile/paddle-mobile/Program/Program.swift b/metal/paddle-mobile/paddle-mobile/Program/Program.swift index 1481677b198f802cd5f29a967513b2df2107bc47..be5d2a798ba2cd1fb8a3b19f781e26cd8b1adfcc 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/Program.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/Program.swift @@ -14,7 +14,7 @@ import Foundation -public struct Program { +public class Program { let paramPath: String let programDesc: ProgramDesc let scope: Scope diff --git a/metal/paddle-mobile/paddle-mobile/Program/ProgramDesc.swift b/metal/paddle-mobile/paddle-mobile/Program/ProgramDesc.swift index ef094a8a20790b4e0cf47eaea04bb7d4f7a2d046..ad472e5a7d1fe9db248e47f4417d7c61fb01eaa9 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/ProgramDesc.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/ProgramDesc.swift @@ -14,7 +14,7 @@ import Foundation -public struct ProgramDesc { +public class ProgramDesc { var blocks: [BlockDesc] = [] init(protoProgram: PaddleMobile_Framework_Proto_ProgramDesc) { for block in protoProgram.blocks { diff --git a/metal/paddle-mobile/paddle-mobile/Program/TensorDesc.swift b/metal/paddle-mobile/paddle-mobile/Program/TensorDesc.swift index d17f56cead5a40aede28c6bb76d77b6384aae552..1a72f5ef717063136c4708c881befd789a57219c 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/TensorDesc.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/TensorDesc.swift @@ -14,7 +14,7 @@ import Foundation -struct TensorDesc { +class TensorDesc { let dims: [Int] let dataType: VarTypeType let dataLayout: DataLayout = DataLayout.NCHW() diff --git a/metal/paddle-mobile/paddle-mobile/Program/VarDesc.swift b/metal/paddle-mobile/paddle-mobile/Program/VarDesc.swift index 58411828c0c94316da089fc1e2442c87bd154594..f29169598f69ec568bd9d08af8fa4738fe8f5eea 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/VarDesc.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/VarDesc.swift @@ -56,7 +56,7 @@ enum VarTypeType: Int { } } -struct VarDesc { +class VarDesc { let name: String let persistable: Bool let type: VarTypeType diff --git a/metal/paddle-mobile/paddle-mobile/framework/Executor.swift b/metal/paddle-mobile/paddle-mobile/framework/Executor.swift index 9890e106e21d3084569f27339d5d54c1ed01b462..db8a73be1fb0161a7da78c5f50ae5ab2c85f7a2b 100644 --- a/metal/paddle-mobile/paddle-mobile/framework/Executor.swift +++ b/metal/paddle-mobile/paddle-mobile/framework/Executor.swift @@ -76,11 +76,23 @@ public class Executor { program = inProgram device = inDevice queue = inQueue +// print("before for ") +//print(program.scope.vars["fea_pyramid1_mbox_conf_flat.Flatten.output.1.tmp_0"]) + + for block in inProgram.programDesc.blocks { //block.ops.count for i in 0...shared.creat(device: inDevice, opDesc: op, scope: inProgram.scope) ops.append(op) } catch let error {