diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift b/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift index e2351d14e317ada506d1f15c59efda22c984cab8..6e832a612107162adce250c3172602d4d5553547 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift @@ -79,7 +79,7 @@ class ViewController: UIViewController { return } do { - let max = 10 + let max = 1 let startDate = Date.init() for i in 0.. { buffer.addCompletedHandler { (commandbuffer) in +// let inputArr = resInput.floatArray(res: { (p:P) -> P in +// return p +// }) +// print(inputArr.strideArray()) +// // let inputArr = resInput.floatArray(res: { (p:P) -> P in // return p // }) @@ -124,12 +129,12 @@ public class Executor { // print(stridableInput) // let _: Flo? = input.logDesc(header: "input: ", stridable: true) -// for i in 0..: Operator, BoxcoderParam

print(targetBoxArray.strideArray()) let originDim = para.output.originDim - let outputArray = para.output.metalTexture.realNHWC(dim: (n: originDim[0], h: originDim[1], w: originDim[2], c: originDim[3])) + print(" output ") print(outputArray.strideArray()) - } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/ConcatOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/ConcatOp.swift index 117fd8c39fadec55b88cc1aeaf3b91e5a0dd966d..84e58a0f3d537ed96d24744fc3803d0885375e14 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/ConcatOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/ConcatOp.swift @@ -65,10 +65,16 @@ class ConcatOp: Operator, ConcatParam

>, Run func delogOutput() { print(" \(type) output: ") + let originDim = para.output.originDim - let outputArray = para.output.metalTexture.realNHWC(dim: (n: originDim[0], h: originDim[1], w: originDim[2], c: originDim[3])) - print(outputArray.strideArray()) - print(para.output.metalTexture.toTensor(dim: (n: para.output.tensorDim[0], c: para.output.tensorDim[1], h: para.output.tensorDim[2], w: para.output.tensorDim[3])).strideArray()) + if para.output.transpose == [0, 1, 2, 3] { + let outputArray = para.output.metalTexture.realNHWC(dim: (n: originDim[0], h: originDim[1], w: originDim[2], c: originDim[3])) + print(outputArray.strideArray()) + } else if para.output.transpose == [0, 2, 3, 1] { + print(para.output.metalTexture.toTensor(dim: (n: para.output.tensorDim[0], c: para.output.tensorDim[1], h: para.output.tensorDim[2], w: para.output.tensorDim[3])).strideArray()) + } else { + fatalError() + } } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/ConvAddBatchNormReluOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/ConvAddBatchNormReluOp.swift index 6f67014444e5ef82fe4cdc30f99bc371fef2d417..8bb9349be7bd054a5e00005131b9baf1afa370d5 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/ConvAddBatchNormReluOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/ConvAddBatchNormReluOp.swift @@ -125,13 +125,13 @@ class ConvAddBatchNormReluOp: Operator P in - return p - } - // - writeToLibrary(fileName: "output_112x112x32_2", array: output) - print(" write done") - - // let _: P? = para.output.metalTexture.logDesc(header: "conv add batchnorm relu output: ", stridable: false) +// let output = para.output.metalTexture.floatArray { (p: P) -> P in +// return p +// } +// // +// writeToLibrary(fileName: "output_112x112x32_2", array: output) +// print(" write done") +// +// // let _: P? = para.output.metalTexture.logDesc(header: "conv add batchnorm relu output: ", stridable: false) } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/FeedOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/FeedOp.swift index 59e5443a0f8c372dc366e2e1c65422dffbf42252..93560582166c53b6de308e53b1cda431151ad741 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/FeedOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/FeedOp.swift @@ -60,9 +60,8 @@ class FeedOp: Operator, FeedParam< } func delogOutput() { - // para.input.mtlTexture.logDesc() - // let _: P? = para.input.mtlTexture.logDesc(header: "feed input: ", stridable: true) - // let _: P? = para.output.metalTexture.logDesc(header: "feed output: ", stridable: false) + print(" \(type) output: ") + print(para.output.metalTexture.toTensor(dim: (n: para.output.originDim[0], c: para.output.originDim[1], h: para.output.originDim[2], w: para.output.originDim[3])).strideArray()) } } diff --git a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConvKernel.metal b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConvKernel.metal index a17366cbe0e67b4cd38cafe4e09909f537d269bf..3254346c8da2b63420c6dcaf540e3c28f663b890 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConvKernel.metal +++ b/metal/paddle-mobile/paddle-mobile/Operators/Kernels/metal/ConvKernel.metal @@ -769,3 +769,4 @@ kernel void depthwise_conv_batch_norm_relu_3x3(texture2d_array: Operator, TransposeParam func delogOutput() { print(" \(type) output: ") - let originDim = para.output.tensorDim - let outputArray = para.output.metalTexture.realNHWC(dim: (n: originDim[0], h: originDim[1], w: originDim[2], c: originDim[3])) - print(outputArray.strideArray()) + let originDim = para.output.originDim + if para.output.transpose == [0, 1, 2, 3] { + let outputArray = para.output.metalTexture.realNHWC(dim: (n: originDim[0], h: originDim[1], w: originDim[2], c: originDim[3])) + print(outputArray.strideArray()) + } else if para.output.transpose == [0, 2, 3, 1] { + print(para.output.metalTexture.toTensor(dim: (n: para.output.tensorDim[0], c: para.output.tensorDim[1], h: para.output.tensorDim[2], w: para.output.tensorDim[3])).strideArray()) + } else { + print(" not implement") + } } }