diff --git a/metal/paddle-mobile/paddle-mobile/Common/MetalExtension.swift b/metal/paddle-mobile/paddle-mobile/Common/MetalExtension.swift index 16eda20526f86625df564834868f30bef3fdd202..0504250c401659adb34746da70bb2b8c9114a721 100644 --- a/metal/paddle-mobile/paddle-mobile/Common/MetalExtension.swift +++ b/metal/paddle-mobile/paddle-mobile/Common/MetalExtension.swift @@ -1,10 +1,16 @@ -// -// MetalExtension.swift -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/2. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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 diff --git a/metal/paddle-mobile/paddle-mobile/Executor.swift b/metal/paddle-mobile/paddle-mobile/Executor.swift index 72fa3bda7f3c36c9c39db76866a4ceb7b8977e18..7b93b13349a9b30b37cb67a910118beb8a1564a7 100644 --- a/metal/paddle-mobile/paddle-mobile/Executor.swift +++ b/metal/paddle-mobile/paddle-mobile/Executor.swift @@ -55,17 +55,8 @@ public class Executor { device = inDevice queue = inQueue for block in inProgram.programDesc.blocks { - for i in 0..<7 { - let op = block.ops[i] - do { - let op = try OpCreator

.shared.creat(device: inDevice, opDesc: op, scope: inProgram.scope) - op.inferShape() - ops.append(op) - } catch let error { - throw error - } - } -// for op in block.ops { +// for i in 0..<2 { +// let op = block.ops[i] // do { // let op = try OpCreator

.shared.creat(device: inDevice, opDesc: op, scope: inProgram.scope) // op.inferShape() @@ -74,6 +65,15 @@ public class Executor { // throw error // } // } + for op in block.ops { + do { + let op = try OpCreator

.shared.creat(device: inDevice, opDesc: op, scope: inProgram.scope) + op.inferShape() + ops.append(op) + } catch let error { + throw error + } + } } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/ConvAddBatchNormReluOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/ConvAddBatchNormReluOp.swift index 5b887e82a5d7840266ce2929cd6f9cdc22678fcf..649c5e801f0ed9b71d09cd927f98d3f557d6ac70 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/ConvAddBatchNormReluOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/ConvAddBatchNormReluOp.swift @@ -1,10 +1,16 @@ -// -// ConvAddBatchNormReluOp.swift -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/8. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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 @@ -14,7 +20,7 @@ class ConvAddBatchNormReluParam: OpParam { do { filter = try ConvAddBatchNormReluParam.inputFilter(paraInputs: opDesc.paraInputs, from: inScope) input = try ConvAddBatchNormReluParam.input(inputs: opDesc.inputs, from: inScope) - output = try ConvAddBatchNormReluParam.output(outputs: opDesc.outputs, from: inScope) + output = try ConvAddBatchNormReluParam.outputOut(outputs: opDesc.outputs, from: inScope) stride = try ConvAddBatchNormReluParam.getAttr(key: "strides", attrs: opDesc.attrs) paddings = try ConvAddBatchNormReluParam.getAttr(key: "paddings", attrs: opDesc.attrs) dilations = try ConvAddBatchNormReluParam.getAttr(key: "dilations", attrs: opDesc.attrs) @@ -99,4 +105,9 @@ class ConvAddBatchNormReluOp: Operator String { return gConvAddBatchNormReluType } + + func delogOutput() { + + } + } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/ConvAddOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/ConvAddOp.swift index 3feaded60f47322cc5691bcc3a595812e27bab16..40069f6550ea00e986926f40c5fc2a2d4bf22a83 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/ConvAddOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/ConvAddOp.swift @@ -1,10 +1,16 @@ -// -// ConvAddBatchNormReluOp.swift -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/8. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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 @@ -14,7 +20,7 @@ class ConvAddParam: OpParam { do { filter = try ConvAddParam.inputFilter(paraInputs: opDesc.paraInputs, from: inScope) input = try ConvAddParam.input(inputs: opDesc.inputs, from: inScope) - output = try ConvAddParam.output(outputs: opDesc.outputs, from: inScope) + output = try ConvAddParam.outputOut(outputs: opDesc.outputs, from: inScope) stride = try ConvAddParam.getAttr(key: "strides", attrs: opDesc.attrs) paddings = try ConvAddParam.getAttr(key: "paddings", attrs: opDesc.attrs) dilations = try ConvAddParam.getAttr(key: "dilations", attrs: opDesc.attrs) diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BatchNormKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BatchNormKernel.swift index 020cdba1ad8a78620477dca1b396d5a006f80229..4c36543abe5e66aafd5ba1c4ce0ec7610fe14369 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BatchNormKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/BatchNormKernel.swift @@ -1,10 +1,16 @@ -// -// BatchNormKernel.swift -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/5. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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 diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddBatchNormReluKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddBatchNormReluKernel.swift index 63961f026bdfa6116495bc2c5fd327a3b351ec3b..28ac80258be687ae9bc7e158072a0317a16e8641 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddBatchNormReluKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddBatchNormReluKernel.swift @@ -1,10 +1,16 @@ -// -// ConvKernel.swift -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/5. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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 @@ -64,4 +70,6 @@ class ConvAddBatchNormReluKernel: Kernel, Computable { encoder.dispatch(computePipline: pipline, outTexture: param.output.metalTexture) encoder.endEncoding() } + + } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift index 442be96f79c803d7d2779f0cda0b1725ca3f0b91..9ce39e91fd366ffa7bceb7c265a10c5c12bad60b 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift @@ -1,10 +1,16 @@ -// -// ConvKernel.swift -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/5. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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 diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvKernel.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvKernel.metal index ed3bf031ebe82084dba742f85bed6e70a0b77731..19fb25804a977a574bb1dfb4f932942b14b6897b 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvKernel.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvKernel.metal @@ -1,10 +1,16 @@ -// -// ConvKernel.metal -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/7. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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. */ #include using namespace metal; diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvKernel.swift index 0234a3209e3c9125c8c60bf68abe9c2d9564d9d8..f6215c16154a376bb0527de888ad5dd8b24f3555 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvKernel.swift @@ -1,10 +1,16 @@ -// -// ConvKernel.swift -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/5. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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 diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ElementwiseAddKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ElementwiseAddKernel.swift index a1b8abc336f30477cf5436fbf0d0142d9a001511..361e77950841f2fa2b54884a2fbf394714f10902 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ElementwiseAddKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ElementwiseAddKernel.swift @@ -1,10 +1,16 @@ -// -// ElementwiseAddKernel.swift -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/5. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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 diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/Texture2DTo2DArrayKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/Texture2DTo2DArrayKernel.swift index 94321b91e9904575181ad6a5d588e951ca60e21c..3bf912c87336f834ecaf4933a0ef56dda2ac6ed3 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/Texture2DTo2DArrayKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/Texture2DTo2DArrayKernel.swift @@ -1,10 +1,16 @@ -// -// Texture2DTo2DArrayKernel.swift -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/6. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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 diff --git a/metal/paddle-mobile/paddle-mobile/Operators/PoolOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/PoolOp.swift index 594aca05ada31db8a4b18a12bac0530accb8932b..63677a61b0d3c5edf7f39b1d089528b3702cc8ae 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/PoolOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/PoolOp.swift @@ -1,10 +1,16 @@ -// -// PoolOp.swift -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/9. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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 diff --git a/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift index b783c6f0516d11e69bf41bc28e69170faf8e259d..47ba93c3e8ad900e644bb92a3b37d79813b23278 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift @@ -1,10 +1,16 @@ -// -// PoolOp.swift -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/9. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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 diff --git a/metal/paddle-mobile/paddle-mobile/Operators/SoftmaxOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/SoftmaxOp.swift index e925b81655cc4f03326a54c089581fbf72eceb60..17cb746952a4cd58cba53fec48be3affc9c22223 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/SoftmaxOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/SoftmaxOp.swift @@ -1,10 +1,16 @@ -// -// PoolOp.swift -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/9. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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 diff --git a/metal/paddle-mobile/paddle-mobile/Program/OpDesc.swift b/metal/paddle-mobile/paddle-mobile/Program/OpDesc.swift index 11ca4e849215754f853a445f8e2528292f085522..73f81152316ad6812f705979b9c2358ee03eb3c8 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/OpDesc.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/OpDesc.swift @@ -17,7 +17,7 @@ import Foundation struct OpDesc { let inputs: [String : [String]] var paraInputs: [String : [String]] - let outputs: [String : [String]] + var outputs: [String : [String]] let unusedOutputs: [String : [String]] var attrs: [String : Attr] = [:] var type: String diff --git a/metal/paddle-mobile/paddle-mobile/Program/ProgramOptimize.swift b/metal/paddle-mobile/paddle-mobile/Program/ProgramOptimize.swift index dc813537cb41a45a1f3cbe0d924407ad0e9e4bb1..d819cdad533e444c327e95baff7bf87e902d6bff 100644 --- a/metal/paddle-mobile/paddle-mobile/Program/ProgramOptimize.swift +++ b/metal/paddle-mobile/paddle-mobile/Program/ProgramOptimize.swift @@ -1,10 +1,16 @@ -// -// ProgramOptimize.swift -// paddle-mobile -// -// Created by liuRuiLong on 2018/7/8. -// Copyright © 2018年 orange. All rights reserved. -// +/* 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 @@ -56,6 +62,7 @@ class Node { let change = fusion.change() let inOutputs = outputs outputs.removeAll() + opDesc?.outputs.removeAll() for i in 0.. { _ = inputNode --> node } } - } } @@ -193,7 +201,6 @@ class ProgramOptimize { nodes.remove(element: removeNode) } } - } } } diff --git a/metal/paddle-mobile/paddle-mobile/framework/Tensor.swift b/metal/paddle-mobile/paddle-mobile/framework/Tensor.swift index b4733b3aad55aac080d82b166d6461f07beebe58..50e22bf7a89b73c968a529441b603faa99462e30 100644 --- a/metal/paddle-mobile/paddle-mobile/framework/Tensor.swift +++ b/metal/paddle-mobile/paddle-mobile/framework/Tensor.swift @@ -148,18 +148,25 @@ class Tensor: Tensorial { extension Tensor { var debugDescription: String { var str = "" - str += "Dim: \(dim) \n value:[ " - if data.size < 20 { - for d in 0...stride { +// str += " \(buffer.contents().assumingMemoryBound(to: P.self)[i])" +// } return str + +// var str = "" +// str += "Dim: \(dim) \n value:[ " +// if data.size < 20 { +// for d in 0..