From 57342221cec92a8a9240250f33c5ae2c3255dc14 Mon Sep 17 00:00:00 2001 From: abisca Date: Tue, 12 Dec 2023 14:17:24 -0700 Subject: [PATCH] Update python bindings and includes. --- .../color_detect/aie2_colorDetect.py | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/reference_designs/ipu-xrt/vision_pipelines/color_detect/aie2_colorDetect.py b/reference_designs/ipu-xrt/vision_pipelines/color_detect/aie2_colorDetect.py index 7bdecc33f6..f14bc9ae6a 100644 --- a/reference_designs/ipu-xrt/vision_pipelines/color_detect/aie2_colorDetect.py +++ b/reference_designs/ipu-xrt/vision_pipelines/color_detect/aie2_colorDetect.py @@ -7,11 +7,11 @@ import sys -from aie.ir import * -from aie.dialects.func import * -from aie.dialects.scf import * from aie.dialects.aie import * from aie.dialects.aiex import * +from aie.dialects.scf import * +from aie.extras.dialects import memref, arith +from aie.extras.util import mlir_mod_ctx width = 64 height = 36 @@ -41,30 +41,30 @@ def deviceBody(): # AIE Core Function declarations rgba2hueLine = external_func( - "rgba2grayLine", inputs=[line_bytes_ty, line_ty, T.i132()] + "rgba2hueLine", inputs=[line_bytes_ty, line_ty, T.i32()] ) thresholdLine = external_func( "thresholdLine", - inputs=[line_ty, line_ty, T.i132(), T.i16(), T.i16(), T.i8()], + inputs=[line_ty, line_ty, T.i32(), T.i16(), T.i16(), T.i8()], ) bitwiseORLine = external_func( - "bitwiseORLine", inputs=[line_ty, line_ty, line_ty, T.i132()] + "bitwiseORLine", inputs=[line_ty, line_ty, line_ty, T.i32()] ) gray2rgbaLine = external_func( - "gray2rgbaLine", inputs=[line_ty, line_bytes_ty, T.i132()] + "gray2rgbaLine", inputs=[line_ty, line_bytes_ty, T.i32()] ) bitwiseANDLine = external_func( "bitwiseORLine", - inputs=[line_bytes_ty, line_bytes_ty, line_bytes_ty, T.i132()], + inputs=[line_bytes_ty, line_bytes_ty, line_bytes_ty, T.i32()], ) # Tile declarations - ShimTile = Tile(0, 0) - MemTile = Tile(0, 1) - ComputeTile2 = Tile(0, 2) - ComputeTile3 = Tile(0, 3) - ComputeTile4 = Tile(0, 4) - ComputeTile5 = Tile(0, 5) + ShimTile = tile(0, 0) + MemTile = tile(0, 1) + ComputeTile2 = tile(0, 2) + ComputeTile3 = tile(0, 3) + ComputeTile4 = tile(0, 4) + ComputeTile5 = tile(0, 5) # AIE-array data movement with object fifos @@ -93,7 +93,7 @@ def deviceBody(): objectfifo( "outOF_L2L3", MemTile, - ShimTile, + [ShimTile], 2, ofifo_line_bytes_ty, [], @@ -102,7 +102,7 @@ def deviceBody(): objectfifo( "outOF_L1L2", ComputeTile5, - MemTile, + [MemTile], 2, ofifo_line_bytes_ty, [], @@ -123,7 +123,7 @@ def deviceBody(): objectfifo( "OF_3to3", ComputeTile3, - ComputeTile3, + [ComputeTile3], 1, ofifo_line_ty, [], @@ -132,7 +132,7 @@ def deviceBody(): objectfifo( "OF_3to5", ComputeTile3, - ComputeTile5, + [ComputeTile5], 2, ofifo_line_ty, [], @@ -141,7 +141,7 @@ def deviceBody(): objectfifo( "OF_4to4", ComputeTile4, - ComputeTile4, + [ComputeTile4], 1, ofifo_line_ty, [], @@ -150,7 +150,7 @@ def deviceBody(): objectfifo( "OF_4to5", ComputeTile4, - ComputeTile5, + [ComputeTile5], 2, ofifo_line_ty, [], @@ -159,7 +159,7 @@ def deviceBody(): objectfifo( "OF_5to5a", ComputeTile5, - ComputeTile5, + [ComputeTile5], 1, ofifo_line_ty, [], @@ -168,7 +168,7 @@ def deviceBody(): objectfifo( "OF_5to5b", ComputeTile5, - ComputeTile5, + [ComputeTile5], 1, ofifo_line_ty, [], @@ -183,11 +183,11 @@ def coreBody(): for _ in for_(sys.maxsize): elemIn = acquire( ObjectFifoPort.Consume, "inOF_L3L2", 1, line_bytes_ty - ).acquiredElem() + ).acquired_elem() elemOut = acquire( ObjectFifoPort.Produce, "OF_2to34", 1, line_ty - ).acquiredElem() - Call(rgba2hueLine, [elemIn, elemOut, lineWidth]) + ).acquired_elem() + Call(rgba2hueLine, [elemIn, elemOut, arith.constant(lineWidth)]) objectfifo_release(ObjectFifoPort.Consume, "inOF_L3L2", 1) objectfifo_release(ObjectFifoPort.Produce, "OF_2to34", 1) @@ -202,16 +202,16 @@ def coreBody(): for _ in for_(sys.maxsize): elemIn = acquire( ObjectFifoPort.Consume, "OF_2to34", 1, line_ty - ).acquiredElem() + ).acquired_elem() elemOutTmp = acquire( ObjectFifoPort.Produce, "OF_3to3", 1, line_ty - ).acquiredElem() + ).acquired_elem() Call( thresholdLine, [ elemIn, elemOutTmp, - lineWidth, + arith.constant(lineWidth), thresholdValueUpper1, thresholdMaxvalue, thresholdModeToZeroInv, @@ -221,16 +221,16 @@ def coreBody(): objectfifo_release(ObjectFifoPort.Produce, "OF_3to3", 1) elemInTmp = acquire( ObjectFifoPort.Consume, "OF_3to3", 1, line_ty - ).acquiredElem() + ).acquired_elem() elemOut = acquire( ObjectFifoPort.Produce, "OF_3to5", 1, line_ty - ).acquiredElem() + ).acquired_elem() Call( thresholdLine, [ elemInTmp, elemOut, - lineWidth, + arith.constant(lineWidth), thresholdValueLower1, thresholdMaxvalue, thresholdModeBinary, @@ -250,16 +250,16 @@ def coreBody(): for _ in for_(sys.maxsize): elemIn = acquire( ObjectFifoPort.Consume, "OF_2to34", 1, line_ty - ).acquiredElem() + ).acquired_elem() elemOutTmp = acquire( ObjectFifoPort.Produce, "OF_4to4", 1, line_ty - ).acquiredElem() + ).acquired_elem() Call( thresholdLine, [ elemIn, elemOutTmp, - lineWidth, + arith.constant(lineWidth), thresholdValueUpper1, thresholdMaxvalue, thresholdModeToZeroInv, @@ -269,16 +269,16 @@ def coreBody(): objectfifo_release(ObjectFifoPort.Produce, "OF_4to4", 1) elemInTmp = acquire( ObjectFifoPort.Consume, "OF_4to4", 1, line_ty - ).acquiredElem() + ).acquired_elem() elemOut = acquire( ObjectFifoPort.Produce, "OF_4to5", 1, line_ty - ).acquiredElem() + ).acquired_elem() Call( thresholdLine, [ elemInTmp, elemOut, - lineWidth, + arith.constant(lineWidth), thresholdValueLower1, thresholdMaxvalue, thresholdModeBinary, @@ -294,40 +294,40 @@ def coreBody(): # bitwise OR elemIn1 = acquire( ObjectFifoPort.Consume, "OF_3to5", 1, line_ty - ).acquiredElem() + ).acquired_elem() elemIn2 = acquire( ObjectFifoPort.Consume, "OF_4to5", 1, line_ty - ).acquiredElem() + ).acquired_elem() elemOutTmpA = acquire( ObjectFifoPort.Produce, "OF_5to5a", 1, line_ty - ).acquiredElem() - Call(bitwiseORLine, [elemIn1, elemIn2, elemOutTmpA, lineWidth]) + ).acquired_elem() + Call(bitwiseORLine, [elemIn1, elemIn2, elemOutTmpA, arith.constant(lineWidth)]) objectfifo_release(ObjectFifoPort.Consume, "OF_3to5", 1) objectfifo_release(ObjectFifoPort.Consume, "OF_4to5", 1) objectfifo_release(ObjectFifoPort.Produce, "OF_5to5a", 1) # gray2rgba elemInTmpA = acquire( ObjectFifoPort.Consume, "OF_5to5a", 1, line_ty - ).acquiredElem() + ).acquired_elem() elemOutTmpB = acquire( ObjectFifoPort.Produce, "OF_5to5b", 1, line_bytes_ty - ).acquiredElem() - Call(gray2rgbaLine, [elemInTmpA, elemOutTmpB, lineWidth]) + ).acquired_elem() + Call(gray2rgbaLine, [elemInTmpA, elemOutTmpB, arith.constant(lineWidth)]) objectfifo_release(ObjectFifoPort.Consume, "OF_5to5a", 1) objectfifo_release(ObjectFifoPort.Produce, "OF_5to5b", 1) # bitwise AND elemInTmpB1 = acquire( ObjectFifoPort.Consume, "OF_5to5b", 1, line_bytes_ty - ).acquiredElem() + ).acquired_elem() elemInTmpB2 = acquire( ObjectFifoPort.Consume, "inOF_L2L1", 1, line_bytes_ty - ).acquiredElem() + ).acquired_elem() elemOut = acquire( ObjectFifoPort.Produce, "outOF_L1L2", 1, line_bytes_ty - ).acquiredElem() + ).acquired_elem() Call( bitwiseANDLine, - [elemInTmpB1, elemInTmpB2, elemOut, lineWidthInBytes], + [elemInTmpB1, elemInTmpB2, elemOut, arith.constant(lineWidthInBytes)], ) objectfifo_release(ObjectFifoPort.Consume, "OF_5to5b", 1) objectfifo_release(ObjectFifoPort.Consume, "inOF_L2L1", 1) @@ -337,8 +337,8 @@ def coreBody(): tensorSize = width * height * 4 # 4 channels tensorSizeInInt32s = tensorSize // 4 - tensor_ty = MemRefType.get((tensorSizeInInt32s,), T.i132()) - memRef_16x16_ty = MemRefType.get((16,16,), T.i132()) + tensor_ty = MemRefType.get((tensorSizeInInt32s,), T.i32()) + memRef_16x16_ty = MemRefType.get((16,16,), T.i32()) @FuncOp.from_py_func(tensor_ty, memRef_16x16_ty, tensor_ty) def sequence(I, B, O):