diff --git a/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift b/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift index 3bcf9c15a0fe2d075e79ee98f2f32726efbdbad7..4c4e910499435294bddfaba717b8690492649072 100644 --- a/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift +++ b/metal/paddle-mobile/paddle-mobile/Operators/ReshapeOp.swift @@ -20,14 +20,36 @@ class ReshapeParam: OpParam { do { input = try ReshapeParam.inputX(inputs: opDesc.inputs, from: inScope) output = try ReshapeParam.outputOut(outputs: opDesc.outputs, from: inScope) - // shape = output.dim + shape = try ReshapeParam.getAttr(key: "shape", attrs: opDesc.attrs) + + var s: [Int] = shape.map { Int($0) } + var di = -1 + var ml = 1 + for i in 0..= 0 { + s[di] = input.dim.numel() / ml + } + output.tensorDim = Dim.init(inDim: s) + var dim: [Int] = [1, 1, 1, 1] + for i in 0.. - // let shape: [Int] + let shape: [Int32] let inplace: Bool var output: Texture

} diff --git a/metal/paddle-mobile/paddle-mobile/framework/Texture.swift b/metal/paddle-mobile/paddle-mobile/framework/Texture.swift index 231ef0fb278d0e634c853d7a84a06b7fb9acedee..9889171dba3cb8f18b20cac597a6fec505a92e73 100644 --- a/metal/paddle-mobile/paddle-mobile/framework/Texture.swift +++ b/metal/paddle-mobile/paddle-mobile/framework/Texture.swift @@ -40,8 +40,8 @@ extension InputTexture { public class Texture: Tensorial { var dim: Dim - private(set) public var tensorDim: Dim - private(set) public var originDim: Dim + public var tensorDim: Dim + public var originDim: Dim private var textureDesc: MTLTextureDescriptor! public var metalTexture: MTLTexture! var transpose: [Int] = [0, 1, 2, 3]