From 1e5520f70f196d8d6bf9b45c8e7db68e33b900af Mon Sep 17 00:00:00 2001 From: liuruilong Date: Fri, 31 Aug 2018 19:22:57 +0800 Subject: [PATCH] update log --- .../paddle-mobile-demo/ViewController.swift | 2 +- .../paddle-mobile/paddle-mobile/Executor.swift | 17 +++++++++++------ .../paddle-mobile/Operators/BoxcoderOp.swift | 3 +-- .../paddle-mobile/Operators/ConcatOp.swift | 12 +++++++++--- .../Operators/ConvAddBatchNormReluOp.swift | 16 ++++++++-------- .../paddle-mobile/Operators/FeedOp.swift | 5 ++--- .../Operators/Kernels/metal/ConvKernel.metal | 1 + .../paddle-mobile/Operators/TransposeOp.swift | 12 +++++++++--- 8 files changed, 42 insertions(+), 26 deletions(-) diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift b/metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift index e2351d14e3..6e832a6121 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 117fd8c39f..84e58a0f3d 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 6f67014444..8bb9349be7 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 59e5443a0f..9356058216 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 a17366cbe0..3254346c8d 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") + } } } -- GitLab