diff --git a/metal/paddle-mobile/paddle-mobile/Common/Extensions.swift b/metal/paddle-mobile/paddle-mobile/Common/Extensions.swift index a625d72d1b43784e22101518063d5302815c65a1..ece6b1e82b700421e84bba566866beb9470855a0 100644 --- a/metal/paddle-mobile/paddle-mobile/Common/Extensions.swift +++ b/metal/paddle-mobile/paddle-mobile/Common/Extensions.swift @@ -98,14 +98,14 @@ extension Array where Element: Comparable{ } extension Array { - func strideArray(inCount: Int = 20) -> Array { + func strideArray(inCount: Int = 20) -> [(Int, Element)] { if count < inCount { - return self + return (0.. { queue = inQueue for block in inProgram.programDesc.blocks { //block.ops.count - for i in 0..<39 { + for i in 0..<91 { let op = block.ops[i] do { let op = try OpCreator

.shared.creat(device: inDevice, opDesc: op, scope: inProgram.scope) @@ -128,7 +128,7 @@ public class Executor { } // return - self.ops[38].delogOutput() + self.ops[90].delogOutput() // self.ops[91].delogOutput() // self.ops[92].delogOutput() // self.ops[93].delogOutput() diff --git a/metal/paddle-mobile/paddle-mobile/Operators/ConcatOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/ConcatOp.swift index 5f0004a726fdf11439d96628bb616826324c0a89..c78055896b4573dbbb715be0dd664b9a3e0a949f 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/ConcatOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/ConcatOp.swift @@ -62,6 +62,7 @@ class ConcatOp: Operator, ConcatParam

>, Run let outputArray = para.output.metalTexture.floatArray { (o: Float32) -> Float32 in return o } + print(outputArray.strideArray()) let device: MTLDevice = MTLCreateSystemDefaultDevice()! diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift index 033c0b7a1341ec86246b931ac0c250f6e719351f..3c999052fc690d346753ee7c39f33a3cc18935b8 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift @@ -25,7 +25,7 @@ class ConvAddKernel: Kernel, Computable { super.init(device: device, inFunctionName: "conv_add_3x3") } - param.output.initTexture(device: device, inTranspose: [0, 3, 2, 1]) + param.output.initTexture(device: device, inTranspose: [0, 2, 3, 1]) let offsetX = param.filter.width/2 - Int(param.paddings[0]) let offsetY = param.filter.height/2 - Int(param.paddings[1]) diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ReshapeKernel.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ReshapeKernel.metal index e9ea49f1d774f77a9eabff7f6b1095329395d01a..99d577221b0c3632c83536c652ac688a5b12641f 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ReshapeKernel.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ReshapeKernel.metal @@ -47,20 +47,19 @@ kernel void reshape(texture2d_array inTexture [[texture(0)] invtrans(lrp.otrans, oabcd, tabcd); int index = abcd2index(lrp.odim, tabcd); if (index < count) { - int c = index % 4; - - int temp0 = index % (inTexture.get_array_size() * 4); - int slice = temp0 / 4; - - int temp1 = index % (inTexture.get_array_size() * 4 * lrp.idim[2]); - int w = temp1 / (inTexture.get_array_size() * 4); - - int h = index / (inTexture.get_array_size() * 4 * lrp.idim[2]); - +// int c = index % 4; +// +// int temp0 = index % (inTexture.get_array_size() * 4); +// int slice = temp0 / 4; +// +// int temp1 = index % (inTexture.get_array_size() * 4 * lrp.idim[2]); +// int w = temp1 / (inTexture.get_array_size() * 4); +// +// int h = index / (inTexture.get_array_size() * 4 * lrp.idim[2]); -// index2abcd(lrp.idim, index, tabcd); -// abcd2xyzn(iC, tabcd, ixyzn); - r[n] = inTexture.read(uint2(w, h), slice)[c]; + index2abcd(lrp.idim, index, tabcd); + abcd2xyzn(iC, tabcd, ixyzn); + r[n] = inTexture.read(uint2(ixyzn[0], ixyzn[1]), ixyzn[2])[ixyzn[3]]; } else { r[n] = 0; } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift index b249dc3883ab9110fe3844eeac4a49ba2f868ef1..d132d590b4b3131354244d01ab2c26c0daef052c 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift @@ -53,6 +53,7 @@ class ReshapeOp: Operator, ReshapeParam

>, func delogOutput() { print("reshape delog") // let _: P? = para.input.metalTexture.logDesc(header: "reshape input: ", stridable: false) - let _: P? = para.output.metalTexture.logDesc(header: "reshape output: ", stridable: false) + let _: P? = para.output.metalTexture.logDesc(header: "reshape output: ", stridable: true) + } }