From 780e711c9fdd3b2f4b1bb5cb5de58f090e1b9d16 Mon Sep 17 00:00:00 2001 From: Hanchen Ye Date: Mon, 28 Mar 2022 16:13:42 -0500 Subject: [PATCH] [HLS] Rename from HLSCpp dialect to HLS dialect --- include/scalehls-c/{HLSCpp.h => HLS.h} | 8 +- include/scalehls/Dialect/CMakeLists.txt | 2 +- .../Dialect/{HLSCpp => HLS}/Attributes.td | 16 +-- include/scalehls/Dialect/HLS/CMakeLists.txt | 11 ++ .../Dialect/{HLSCpp/HLSCpp.h => HLS/HLS.h} | 26 ++--- include/scalehls/Dialect/HLS/HLS.td | 34 ++++++ .../scalehls/Dialect/{HLSCpp => HLS}/Ops.td | 34 +++--- .../scalehls/Dialect/{HLSCpp => HLS}/Types.td | 10 +- .../Dialect/{HLSCpp => HLS}/Visitor.h | 16 +-- .../scalehls/Dialect/HLSCpp/CMakeLists.txt | 11 -- include/scalehls/Dialect/HLSCpp/HLSCpp.td | 34 ------ include/scalehls/InitAllDialects.h | 4 +- include/scalehls/Support/Utils.h | 2 +- include/scalehls/Transforms/Passes.h | 2 +- include/scalehls/Transforms/Passes.td | 8 +- include/scalehls/Transforms/QoREstimation.h | 6 +- include/scalehls/Transforms/Utils.h | 2 +- lib/Bindings/Python/CMakeLists.txt | 8 +- lib/Bindings/Python/ScaleHLSModule.cpp | 16 +-- .../dialects/{HLSCppOps.td => HLSOps.td} | 8 +- .../scalehls/dialects/{hlscpp.py => hls.py} | 2 +- lib/CAPI/Dialect/CMakeLists.txt | 6 +- lib/CAPI/Dialect/{HLSCpp.cpp => HLS.cpp} | 6 +- lib/Dialect/CMakeLists.txt | 2 +- lib/Dialect/HLS/CMakeLists.txt | 8 ++ .../{HLSCpp/HLSCpp.cpp => HLS/HLS.cpp} | 87 +++++++------- lib/Dialect/HLSCpp/CMakeLists.txt | 8 -- lib/Support/CMakeLists.txt | 2 +- lib/Support/Utils.cpp | 2 +- lib/Transforms/CMakeLists.txt | 2 +- lib/Transforms/Directive/ArrayPartition.cpp | 6 +- ...ppPrimitive.cpp => CreateHLSPrimitive.cpp} | 9 +- lib/Transforms/Directive/FuncPipelining.cpp | 2 +- lib/Transforms/Directive/LoopPipelining.cpp | 2 +- lib/Transforms/Directive/QoREstimation.cpp | 2 +- .../Graph/ConvertDataflowToFunc.cpp | 4 +- lib/Transforms/Graph/CreateTokenFlow.cpp | 4 +- lib/Transforms/Graph/DataflowBufferize.cpp | 4 +- lib/Transforms/Graph/FuncDataflow.cpp | 8 +- lib/Transforms/Graph/HoistStreamChannel.cpp | 27 +++-- lib/Transforms/Graph/TosaNodeFusion.cpp | 4 +- lib/Transforms/Loop/AffineLoopTile.cpp | 2 +- .../Loop/ConvertCopyToAffineLoops.cpp | 2 +- lib/Transforms/Loop/FuncPreprocess.cpp | 2 +- lib/Transforms/Memory/CreateMemrefSubview.cpp | 2 +- lib/Transforms/Memory/PromoteBuffer.cpp | 2 +- lib/Transforms/Passes.cpp | 4 +- lib/Transforms/Runtime/CreateAxiInterface.cpp | 2 +- lib/Transforms/Runtime/CreateRuntimeMain.cpp | 2 +- lib/Transforms/Utils.cpp | 2 +- lib/Translation/CMakeLists.txt | 2 +- lib/Translation/EmitHLSCpp.cpp | 16 +-- test/Bindings/import.py | 2 +- test/Dialect/errors.mlir | 20 ++-- test/EmitHLSCpp/test-call.mlir | 4 +- test/EmitHLSCpp/test-syrk.mlir | 8 +- .../Transforms/Directive/array-partition.mlir | 24 ++-- .../Directive/create-hlscpp-primitive.mlir | 26 ++--- .../Transforms/Directive/loop-pipelining.mlir | 26 ++--- test/Transforms/Directive/qor-estimation.mlir | 10 +- test/Transforms/Graph/create-token-flow.mlir | 60 +++++----- test/Transforms/Graph/func-dataflow.mlir | 106 +++++++++--------- .../Graph/hoist-stream-channel.mlir | 34 +++--- .../Transforms/Loop/affine-loop-dataflow.mlir | 12 +- test/Transforms/Loop/affine-loop-tile.mlir | 8 +- .../Loop/convert-copy-to-affine-loops.mlir | 4 +- test/Transforms/Loop/func-preprocess.mlir | 6 +- test/Transforms/Loop/simplify-affine-if.mlir | 8 +- .../Memory/affine-store-forward.mlir | 8 +- .../Memory/create-memref-subview.mlir | 8 +- test/Transforms/Memory/promote-buffer.mlir | 8 +- .../Memory/simplify-memref-access.mlir | 8 +- .../Runtime/create-axi-interface.mlir | 30 ++--- .../Runtime/create-runtime-main.mlir | 8 +- tools/scalehls-opt/CMakeLists.txt | 2 +- tools/scalehls-translate/CMakeLists.txt | 2 +- 76 files changed, 461 insertions(+), 464 deletions(-) rename include/scalehls-c/{HLSCpp.h => HLS.h} (65%) rename include/scalehls/Dialect/{HLSCpp => HLS}/Attributes.td (84%) create mode 100644 include/scalehls/Dialect/HLS/CMakeLists.txt rename include/scalehls/Dialect/{HLSCpp/HLSCpp.h => HLS/HLS.h} (83%) create mode 100644 include/scalehls/Dialect/HLS/HLS.td rename include/scalehls/Dialect/{HLSCpp => HLS}/Ops.td (85%) rename include/scalehls/Dialect/{HLSCpp => HLS}/Types.td (73%) rename include/scalehls/Dialect/{HLSCpp => HLS}/Visitor.h (95%) delete mode 100644 include/scalehls/Dialect/HLSCpp/CMakeLists.txt delete mode 100644 include/scalehls/Dialect/HLSCpp/HLSCpp.td rename lib/Bindings/Python/scalehls/dialects/{HLSCppOps.td => HLSOps.td} (61%) rename lib/Bindings/Python/scalehls/dialects/{hlscpp.py => hls.py} (87%) rename lib/CAPI/Dialect/{HLSCpp.cpp => HLS.cpp} (66%) create mode 100644 lib/Dialect/HLS/CMakeLists.txt rename lib/Dialect/{HLSCpp/HLSCpp.cpp => HLS/HLS.cpp} (85%) delete mode 100644 lib/Dialect/HLSCpp/CMakeLists.txt rename lib/Transforms/Directive/{CreateHLSCppPrimitive.cpp => CreateHLSPrimitive.cpp} (94%) diff --git a/include/scalehls-c/HLSCpp.h b/include/scalehls-c/HLS.h similarity index 65% rename from include/scalehls-c/HLSCpp.h rename to include/scalehls-c/HLS.h index b9b7d84..9ee3702 100644 --- a/include/scalehls-c/HLSCpp.h +++ b/include/scalehls-c/HLS.h @@ -4,8 +4,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SCALEHLS_C_DIALECT_HLSCPP_H -#define SCALEHLS_C_DIALECT_HLSCPP_H +#ifndef SCALEHLS_C_DIALECT_HLS_H +#define SCALEHLS_C_DIALECT_HLS_H #include "mlir-c/Registration.h" @@ -13,10 +13,10 @@ extern "C" { #endif -MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(HLSCpp, hlscpp); +MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(HLS, hls); #ifdef __cplusplus } #endif -#endif // SCALEHLS_C_DIALECT_HLSCPP_H +#endif // SCALEHLS_C_DIALECT_HLS_H diff --git a/include/scalehls/Dialect/CMakeLists.txt b/include/scalehls/Dialect/CMakeLists.txt index 6431d5b..2e54a5d 100644 --- a/include/scalehls/Dialect/CMakeLists.txt +++ b/include/scalehls/Dialect/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(HLSCpp) +add_subdirectory(HLS) diff --git a/include/scalehls/Dialect/HLSCpp/Attributes.td b/include/scalehls/Dialect/HLS/Attributes.td similarity index 84% rename from include/scalehls/Dialect/HLSCpp/Attributes.td rename to include/scalehls/Dialect/HLS/Attributes.td index b7925e8..943b76d 100644 --- a/include/scalehls/Dialect/HLSCpp/Attributes.td +++ b/include/scalehls/Dialect/HLS/Attributes.td @@ -4,10 +4,10 @@ // //===----------------------------------------------------------------------===// -#ifndef SCALEHLS_DIALECT_HLSCPP_ATTRIBUTES_TD -#define SCALEHLS_DIALECT_HLSCPP_ATTRIBUTES_TD +#ifndef SCALEHLS_DIALECT_HLS_ATTRIBUTES_TD +#define SCALEHLS_DIALECT_HLS_ATTRIBUTES_TD -def Resource : HLSCppAttr<"Resource"> { +def Resource : HLSAttr<"Resource"> { let summary = "Resource utilization information"; let description = [{ This attribute includes the utilization of several important on-chip @@ -22,7 +22,7 @@ def Resource : HLSCppAttr<"Resource"> { ); } -def Timing : HLSCppAttr<"Timing"> { +def Timing : HLSAttr<"Timing"> { let summary = "Timing information"; let description = [{ This attribute indicates the timing of operations, including scheduling @@ -38,7 +38,7 @@ def Timing : HLSCppAttr<"Timing"> { ); } -def LoopInfo : HLSCppAttr<"LoopInfo"> { +def LoopInfo : HLSAttr<"LoopInfo"> { let summary = "Loop information"; let description = [{ This attribute includes loop information used by estimator and optimizer, @@ -54,7 +54,7 @@ def LoopInfo : HLSCppAttr<"LoopInfo"> { ); } -def LoopDirective : HLSCppAttr<"LoopDirective"> { +def LoopDirective : HLSAttr<"LoopDirective"> { let summary = "Aggregation of loop directives"; let description = [{ This attribute includes all loop directives, including loop pipelining, @@ -70,7 +70,7 @@ def LoopDirective : HLSCppAttr<"LoopDirective"> { ); } -def FuncDirective : HLSCppAttr<"FuncDirective"> { +def FuncDirective : HLSAttr<"FuncDirective"> { let summary = "Aggregation of function directives"; let description = [{ This attribute includes all function directives, including function @@ -85,4 +85,4 @@ def FuncDirective : HLSCppAttr<"FuncDirective"> { ); } -#endif // SCALEHLS_DIALECT_HLSCPP_ATTRIBUTES_TD +#endif // SCALEHLS_DIALECT_HLS_ATTRIBUTES_TD diff --git a/include/scalehls/Dialect/HLS/CMakeLists.txt b/include/scalehls/Dialect/HLS/CMakeLists.txt new file mode 100644 index 0000000..ee1c3fb --- /dev/null +++ b/include/scalehls/Dialect/HLS/CMakeLists.txt @@ -0,0 +1,11 @@ +add_mlir_dialect(HLS hls) + +set(LLVM_TARGET_DEFINITIONS HLS.td) +mlir_tablegen(HLSEnums.h.inc -gen-enum-decls) +mlir_tablegen(HLSEnums.cpp.inc -gen-enum-defs) +add_public_tablegen_target(MLIRHLSEnumsIncGen) + +set(LLVM_TARGET_DEFINITIONS HLS.td) +mlir_tablegen(HLSAttributes.h.inc -gen-attrdef-decls) +mlir_tablegen(HLSAttributes.cpp.inc -gen-attrdef-defs) +add_public_tablegen_target(MLIRHLSAttributesIncGen) diff --git a/include/scalehls/Dialect/HLSCpp/HLSCpp.h b/include/scalehls/Dialect/HLS/HLS.h similarity index 83% rename from include/scalehls/Dialect/HLSCpp/HLSCpp.h rename to include/scalehls/Dialect/HLS/HLS.h index f6650fd..8d7937b 100644 --- a/include/scalehls/Dialect/HLSCpp/HLSCpp.h +++ b/include/scalehls/Dialect/HLS/HLS.h @@ -4,25 +4,25 @@ // //===----------------------------------------------------------------------===// -#ifndef SCALEHLS_DIALECT_HLSCPP_HLSCPP_H -#define SCALEHLS_DIALECT_HLSCPP_HLSCPP_H +#ifndef SCALEHLS_DIALECT_HLS_HLS_H +#define SCALEHLS_DIALECT_HLS_HLS_H #include "mlir/IR/Dialect.h" #include "mlir/IR/OpDefinition.h" #include "mlir/Interfaces/SideEffectInterfaces.h" -#include "scalehls/Dialect/HLSCpp/HLSCppDialect.h.inc" -#include "scalehls/Dialect/HLSCpp/HLSCppEnums.h.inc" +#include "scalehls/Dialect/HLS/HLSDialect.h.inc" +#include "scalehls/Dialect/HLS/HLSEnums.h.inc" #define GET_TYPEDEF_CLASSES -#include "scalehls/Dialect/HLSCpp/HLSCppTypes.h.inc" +#include "scalehls/Dialect/HLS/HLSTypes.h.inc" #define GET_ATTRDEF_CLASSES -#include "scalehls/Dialect/HLSCpp/HLSCppAttributes.h.inc" +#include "scalehls/Dialect/HLS/HLSAttributes.h.inc" namespace mlir { namespace scalehls { -namespace hlscpp { +namespace hls { enum class MemoryKind { BRAM_S2P = 0, BRAM_T2P = 1, BRAM_1P = 2, DRAM = 3 }; enum class PartitionKind { CYCLIC = 0, BLOCK = 1, NONE = 2 }; @@ -74,7 +74,7 @@ void setTopFuncAttr(Operation *op); bool hasRuntimeAttr(Operation *op); void setRuntimeAttr(Operation *op); -} // namespace hlscpp +} // namespace hls } // namespace scalehls } // namespace mlir @@ -86,7 +86,7 @@ class DeclaresStreamChannel public: static LogicalResult verifyTrait(Operation *op) { if (op->getNumResults() != 1 || - !op->getResult(0).getType().isa()) + !op->getResult(0).getType().isa()) return failure(); return success(); } @@ -94,8 +94,8 @@ public: /// Get all users of the channel. SmallVector getChannelUsers() { SmallVector users; - scalehls::hlscpp::getStreamChannelUsers(this->getOperation()->getResult(0), - users); + scalehls::hls::getStreamChannelUsers(this->getOperation()->getResult(0), + users); return users; } }; @@ -103,6 +103,6 @@ public: } // namespace mlir #define GET_OP_CLASSES -#include "scalehls/Dialect/HLSCpp/HLSCpp.h.inc" +#include "scalehls/Dialect/HLS/HLS.h.inc" -#endif // SCALEHLS_DIALECT_HLSCPP_HLSCPP_H +#endif // SCALEHLS_DIALECT_HLS_HLS_H diff --git a/include/scalehls/Dialect/HLS/HLS.td b/include/scalehls/Dialect/HLS/HLS.td new file mode 100644 index 0000000..ce0f8c9 --- /dev/null +++ b/include/scalehls/Dialect/HLS/HLS.td @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// Copyright 2020-2021 The ScaleHLS Authors. +// +//===----------------------------------------------------------------------===// + +#ifndef SCALEHLS_DIALECT_HLS_HLS_TD +#define SCALEHLS_DIALECT_HLS_HLS_TD + +include "mlir/IR/OpBase.td" + +def HLSDialect : Dialect { + let name = "hls"; + let summary = "An HLS out-of-tree MLIR dialect"; + let description = [{ + This dialect contains dedicated operations, types, and attributes designed + for representing HLS C++ specific structures and components in MLIR, while + enabling comprehensive optimization for both performance and area. + }]; + let cppNamespace = "::mlir::scalehls::hls"; +} + +class HLSType : TypeDef; + +class HLSAttr : AttrDef; + +class HLSOp traits = []> : + Op; + +include "scalehls/Dialect/HLS/Types.td" +include "scalehls/Dialect/HLS/Attributes.td" +include "scalehls/Dialect/HLS/Ops.td" + +#endif // SCALEHLS_DIALECT_HLS_HLS_TD diff --git a/include/scalehls/Dialect/HLSCpp/Ops.td b/include/scalehls/Dialect/HLS/Ops.td similarity index 85% rename from include/scalehls/Dialect/HLSCpp/Ops.td rename to include/scalehls/Dialect/HLS/Ops.td index 6ce006f..49fdf78 100644 --- a/include/scalehls/Dialect/HLSCpp/Ops.td +++ b/include/scalehls/Dialect/HLS/Ops.td @@ -4,8 +4,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SCALEHLS_DIALECT_HLSCPP_OPS_TD -#define SCALEHLS_DIALECT_HLSCPP_OPS_TD +#ifndef SCALEHLS_DIALECT_HLS_OPS_TD +#define SCALEHLS_DIALECT_HLS_OPS_TD include "mlir/Interfaces/SideEffectInterfaces.td" @@ -13,7 +13,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td" // Dataflow Operations //===----------------------------------------------------------------------===// -def DataflowNodeOp : HLSCppOp<"dataflow.node", +def DataflowNodeOp : HLSOp<"dataflow.node", [SingleBlockImplicitTerminator<"DataflowOutputOp">]> { let summary = "Dataflow node operation"; let description = [{ @@ -29,7 +29,7 @@ def DataflowNodeOp : HLSCppOp<"dataflow.node", let extraClassDeclaration = [{ DataflowOutputOp getOutputOp(); }]; } -def DataflowOutputOp : HLSCppOp<"dataflow.output", +def DataflowOutputOp : HLSOp<"dataflow.output", [Terminator, HasParent<"DataflowNodeOp">]> { let summary = "Output operation of a dataflow node"; let description = [{ @@ -43,7 +43,7 @@ def DataflowOutputOp : HLSCppOp<"dataflow.output", let builders = [ OpBuilder<(ins), "build($_builder, $_state, Value());"> ]; } -def DataflowSourceOp : HLSCppOp<"dataflow.source"> { +def DataflowSourceOp : HLSOp<"dataflow.source"> { let summary = "Dataflow source operation"; let description = [{ The operation represents the source of a dataflow value. @@ -52,7 +52,7 @@ def DataflowSourceOp : HLSCppOp<"dataflow.source"> { let results = (outs AnyType:$output); } -def DataflowSinkOp : HLSCppOp<"dataflow.sink"> { +def DataflowSinkOp : HLSOp<"dataflow.sink"> { let summary = "Dataflow sink operation"; let description = [{ The operation represents the sink of a dataflow value. @@ -61,7 +61,7 @@ def DataflowSinkOp : HLSCppOp<"dataflow.sink"> { let arguments = (ins AnyType:$input); } -def DataflowBufferOp : HLSCppOp<"dataflow.buffer", +def DataflowBufferOp : HLSOp<"dataflow.buffer", [SameOperandsAndResultElementType]> { let summary = "Dataflow buffer operation"; let description = [{ @@ -79,20 +79,20 @@ def DataflowBufferOp : HLSCppOp<"dataflow.buffer", def DeclaresStreamChannel : NativeOpTrait<"DeclaresStreamChannel">; class StreamOf allowedTypes> : Type()">, + CPred<"$_self.isa<::mlir::scalehls::hls::StreamType>()">, Concat<"[](::mlir::Type elementType) { return ", SubstLeaves<"$_self", "elementType", AnyTypeOf.predicate>, - "; }($_self.cast<::mlir::scalehls::hlscpp::StreamType>().getElementType())"> + "; }($_self.cast<::mlir::scalehls::hls::StreamType>().getElementType())"> ]>>; -def StreamChannelOp : HLSCppOp<"stream.channel", [DeclaresStreamChannel]> { +def StreamChannelOp : HLSOp<"stream.channel", [DeclaresStreamChannel]> { let summary = "Stream channel declaration operation"; let hasVerifier = 1; let results = (outs StreamOf<[AnyType]>:$channel); } -def StreamReadOp : HLSCppOp<"stream.read"> { +def StreamReadOp : HLSOp<"stream.read"> { let summary = "Stream channel read operation"; let description = [{ Read/pop a value from a stream channel. The absence of the result indicates @@ -104,7 +104,7 @@ def StreamReadOp : HLSCppOp<"stream.read"> { let results = (outs Optional:$result); } -def StreamWriteOp : HLSCppOp<"stream.write"> { +def StreamWriteOp : HLSOp<"stream.write"> { let summary = "Stream channel write operation"; let description = [{ Write/push a value to a stream channel. Each stream channel can only be @@ -115,7 +115,7 @@ def StreamWriteOp : HLSCppOp<"stream.write"> { let arguments = (ins StreamOf<[AnyType]>:$channel, AnyType:$value); } -def StreamBufferOp : HLSCppOp<"stream.buffer", [DeclaresStreamChannel]> { +def StreamBufferOp : HLSOp<"stream.buffer", [DeclaresStreamChannel]> { let summary = "Stream channel buffer operation"; let hasVerifier = 1; @@ -127,7 +127,7 @@ def StreamBufferOp : HLSCppOp<"stream.buffer", [DeclaresStreamChannel]> { // Primitive Operations //===----------------------------------------------------------------------===// -def PrimMulOp : HLSCppOp<"prim.mul", [NoSideEffect]> { +def PrimMulOp : HLSOp<"prim.mul", [NoSideEffect]> { let summary = "Multiplication primitive operation"; let description = [{ This primitive performs C = A * B, where A and B are 8-bits integers, while @@ -153,7 +153,7 @@ def PrimMulOp : HLSCppOp<"prim.mul", [NoSideEffect]> { let extraClassDeclaration = [{ bool isPackMul(); }]; } -def PrimCastOp : HLSCppOp<"prim.cast", +def PrimCastOp : HLSOp<"prim.cast", [SameOperandsAndResultShape, NoSideEffect]> { let summary = "Cast primitive operation"; @@ -168,7 +168,7 @@ def PrimCastOp : HLSCppOp<"prim.cast", ); } -def BufferOp : HLSCppOp<"buffer", +def BufferOp : HLSOp<"buffer", [SameOperandsAndResultElementType, NoSideEffect]> { let summary = "Buffer the input value"; @@ -177,4 +177,4 @@ def BufferOp : HLSCppOp<"buffer", let results = (outs AnyType:$output); } -#endif // SCALEHLS_DIALECT_HLSCPP_OPS_TD +#endif // SCALEHLS_DIALECT_HLS_OPS_TD diff --git a/include/scalehls/Dialect/HLSCpp/Types.td b/include/scalehls/Dialect/HLS/Types.td similarity index 73% rename from include/scalehls/Dialect/HLSCpp/Types.td rename to include/scalehls/Dialect/HLS/Types.td index 4c9769f..739ac4c 100644 --- a/include/scalehls/Dialect/HLSCpp/Types.td +++ b/include/scalehls/Dialect/HLS/Types.td @@ -4,11 +4,11 @@ // //===----------------------------------------------------------------------===// -#ifndef SCALEHLS_DIALECT_HLSCPP_TYPES_TD -#define SCALEHLS_DIALECT_HLSCPP_TYPES_TD +#ifndef SCALEHLS_DIALECT_HLS_TYPES_TD +#define SCALEHLS_DIALECT_HLS_TYPES_TD -def StreamType : HLSCppType<"Stream"> { - let summary = "An HLSCpp stream type"; +def StreamType : HLSType<"Stream"> { + let summary = "An HLS stream type"; let description = [{ Represents a stream of any type that can be transfered between HLS modules. This type is equal to the hls::stream<> type in Xilinx Vivado HLS. @@ -23,4 +23,4 @@ def StreamType : HLSCppType<"Stream"> { let assemblyFormat = "`<` qualified($elementType) `,` $depth `>`"; } -#endif // SCALEHLS_DIALECT_HLSCPP_TYPES_TD +#endif // SCALEHLS_DIALECT_HLS_TYPES_TD diff --git a/include/scalehls/Dialect/HLSCpp/Visitor.h b/include/scalehls/Dialect/HLS/Visitor.h similarity index 95% rename from include/scalehls/Dialect/HLSCpp/Visitor.h rename to include/scalehls/Dialect/HLS/Visitor.h index 5dc905c..7369901 100644 --- a/include/scalehls/Dialect/HLSCpp/Visitor.h +++ b/include/scalehls/Dialect/HLS/Visitor.h @@ -4,8 +4,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SCALEHLS_DIALECT_HLSCPP_VISITOR_H -#define SCALEHLS_DIALECT_HLSCPP_VISITOR_H +#ifndef SCALEHLS_DIALECT_HLS_VISITOR_H +#define SCALEHLS_DIALECT_HLS_VISITOR_H #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arithmetic/IR/Arithmetic.h" @@ -16,17 +16,17 @@ #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" -#include "scalehls/Dialect/HLSCpp/HLSCpp.h" +#include "scalehls/Dialect/HLS/HLS.h" #include "llvm/ADT/TypeSwitch.h" namespace mlir { namespace scalehls { -using namespace hlscpp; +using namespace hls; /// This class is a visitor for SSACFG operation nodes. template -class HLSCppVisitorBase { +class HLSVisitorBase { public: ResultType dispatchVisitor(Operation *op, ExtraArgs... args) { auto *thisCast = static_cast(this); @@ -52,7 +52,7 @@ public: memref::ExpandShapeOp, memref::ReinterpretCastOp, bufferization::ToMemrefOp, bufferization::ToTensorOp, - // HLSCpp dialect operations. + // HLS dialect operations. StreamChannelOp, StreamReadOp, StreamWriteOp, PrimMulOp, PrimCastOp, BufferOp, @@ -146,7 +146,7 @@ public: HANDLE(bufferization::ToMemrefOp); HANDLE(bufferization::ToTensorOp); - // HLSCpp dialect operations. + // HLS dialect operations. HANDLE(StreamChannelOp); HANDLE(StreamReadOp); HANDLE(StreamWriteOp); @@ -221,4 +221,4 @@ public: } // namespace scalehls } // namespace mlir -#endif // SCALEHLS_DIALECT_HLSCPP_VISITOR_H +#endif // SCALEHLS_DIALECT_HLS_VISITOR_H diff --git a/include/scalehls/Dialect/HLSCpp/CMakeLists.txt b/include/scalehls/Dialect/HLSCpp/CMakeLists.txt deleted file mode 100644 index 1bded3b..0000000 --- a/include/scalehls/Dialect/HLSCpp/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -add_mlir_dialect(HLSCpp hlscpp) - -set(LLVM_TARGET_DEFINITIONS HLSCpp.td) -mlir_tablegen(HLSCppEnums.h.inc -gen-enum-decls) -mlir_tablegen(HLSCppEnums.cpp.inc -gen-enum-defs) -add_public_tablegen_target(MLIRHLSCppEnumsIncGen) - -set(LLVM_TARGET_DEFINITIONS HLSCpp.td) -mlir_tablegen(HLSCppAttributes.h.inc -gen-attrdef-decls) -mlir_tablegen(HLSCppAttributes.cpp.inc -gen-attrdef-defs) -add_public_tablegen_target(MLIRHLSCppAttributesIncGen) diff --git a/include/scalehls/Dialect/HLSCpp/HLSCpp.td b/include/scalehls/Dialect/HLSCpp/HLSCpp.td deleted file mode 100644 index 57f01cb..0000000 --- a/include/scalehls/Dialect/HLSCpp/HLSCpp.td +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Copyright 2020-2021 The ScaleHLS Authors. -// -//===----------------------------------------------------------------------===// - -#ifndef SCALEHLS_DIALECT_HLSCPP_HLSCPP_TD -#define SCALEHLS_DIALECT_HLSCPP_HLSCPP_TD - -include "mlir/IR/OpBase.td" - -def HLSCppDialect : Dialect { - let name = "hlscpp"; - let summary = "An HLSCpp out-of-tree MLIR dialect"; - let description = [{ - This dialect contains dedicated operations, types, and attributes designed - for representing HLS C++ specific structures and components in MLIR, while - enabling comprehensive optimization for both performance and area. - }]; - let cppNamespace = "::mlir::scalehls::hlscpp"; -} - -class HLSCppType : TypeDef; - -class HLSCppAttr : AttrDef; - -class HLSCppOp traits = []> : - Op; - -include "scalehls/Dialect/HLSCpp/Types.td" -include "scalehls/Dialect/HLSCpp/Attributes.td" -include "scalehls/Dialect/HLSCpp/Ops.td" - -#endif // SCALEHLS_DIALECT_HLSCPP_HLSCPP_TD diff --git a/include/scalehls/InitAllDialects.h b/include/scalehls/InitAllDialects.h index 30f9737..bcc894b 100644 --- a/include/scalehls/InitAllDialects.h +++ b/include/scalehls/InitAllDialects.h @@ -19,7 +19,7 @@ #include "mlir/Dialect/Tosa/IR/TosaOps.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" #include "mlir/IR/Dialect.h" -#include "scalehls/Dialect/HLSCpp/HLSCpp.h" +#include "scalehls/Dialect/HLS/HLS.h" namespace mlir { namespace scalehls { @@ -38,7 +38,7 @@ inline void registerAllDialects(mlir::DialectRegistry ®istry) { mlir::arith::ArithmeticDialect, mlir::vector::VectorDialect, mlir::scf::SCFDialect, - mlir::scalehls::hlscpp::HLSCppDialect, + mlir::scalehls::hls::HLSDialect, mlir::LLVM::LLVMDialect, mlir::DLTIDialect >(); diff --git a/include/scalehls/Support/Utils.h b/include/scalehls/Support/Utils.h index 7f34f19..ffbad98 100644 --- a/include/scalehls/Support/Utils.h +++ b/include/scalehls/Support/Utils.h @@ -10,7 +10,7 @@ #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/IR/AffineValueMap.h" #include "mlir/IR/BuiltinOps.h" -#include "scalehls/Dialect/HLSCpp/HLSCpp.h" +#include "scalehls/Dialect/HLS/HLS.h" namespace mlir { namespace scalehls { diff --git a/include/scalehls/Transforms/Passes.h b/include/scalehls/Transforms/Passes.h index 52d8c7f..bf289dc 100644 --- a/include/scalehls/Transforms/Passes.h +++ b/include/scalehls/Transforms/Passes.h @@ -75,7 +75,7 @@ std::unique_ptr createReduceInitialIntervalPass(); std::unique_ptr createFuncPipeliningPass(); std::unique_ptr createLoopPipeliningPass(); std::unique_ptr createArrayPartitionPass(); -std::unique_ptr createCreateHLSCppPrimitivePass(); +std::unique_ptr createCreateHLSPrimitivePass(); #define GEN_PASS_CLASSES #include "scalehls/Transforms/Passes.h.inc" diff --git a/include/scalehls/Transforms/Passes.td b/include/scalehls/Transforms/Passes.td index de57e59..aa4903f 100644 --- a/include/scalehls/Transforms/Passes.td +++ b/include/scalehls/Transforms/Passes.td @@ -359,14 +359,14 @@ def ArrayPartition : Pass<"scalehls-array-partition", "ModuleOp"> { let constructor = "mlir::scalehls::createArrayPartitionPass()"; } -def CreateHLSCppPrimitive : Pass<"scalehls-create-hlscpp-primitive", "FuncOp"> { +def CreateHLSPrimitive : Pass<"scalehls-create-hls-primitive", "FuncOp"> { let summary = "Create HLS C++ multiplification primitives"; let description = [{ - This create-hlscpp-primitive pass will convert 8-bits multiplifications to - HLS C++ primitives in order to utilize DSP instances in FPGA. + This create-hls-primitive pass will convert 8-bits multiplifications to HLS + C++ primitives in order to utilize DSP instances in FPGA. }]; - let constructor = "mlir::scalehls::createCreateHLSCppPrimitivePass()"; + let constructor = "mlir::scalehls::createCreateHLSPrimitivePass()"; } //===----------------------------------------------------------------------===// diff --git a/include/scalehls/Transforms/QoREstimation.h b/include/scalehls/Transforms/QoREstimation.h index eccb8e1..7af880c 100644 --- a/include/scalehls/Transforms/QoREstimation.h +++ b/include/scalehls/Transforms/QoREstimation.h @@ -10,7 +10,7 @@ #include "mlir/Dialect/Affine/Analysis/AffineAnalysis.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/Dominance.h" -#include "scalehls/Dialect/HLSCpp/Visitor.h" +#include "scalehls/Dialect/HLS/Visitor.h" #include "scalehls/Support/Utils.h" #include "scalehls/Transforms/Utils.h" #include "llvm/Support/JSON.h" @@ -29,7 +29,7 @@ void getDspUsageMap(llvm::json::Object *config, //===----------------------------------------------------------------------===// class ScaleHLSEstimator - : public HLSCppVisitorBase { + : public HLSVisitorBase { public: explicit ScaleHLSEstimator(llvm::StringMap &latencyMap, llvm::StringMap &dspUsageMap, @@ -41,7 +41,7 @@ public: void estimateFunc(FuncOp func); void estimateLoop(AffineForOp loop, FuncOp func); - using HLSCppVisitorBase::visitOp; + using HLSVisitorBase::visitOp; bool visitUnhandledOp(Operation *op, int64_t begin) { // Default latency of any unhandled operation is 0. return setTiming(op, begin, begin, 0, 0), true; diff --git a/include/scalehls/Transforms/Utils.h b/include/scalehls/Transforms/Utils.h index d21deb9..4d9d587 100644 --- a/include/scalehls/Transforms/Utils.h +++ b/include/scalehls/Transforms/Utils.h @@ -48,7 +48,7 @@ bool applyDataflow(Block &block, StringRef prefix, unsigned gran, bool balance); /// Apply the specified array partition factors and kinds. bool applyArrayPartition(Value array, ArrayRef factors, - ArrayRef kinds, + ArrayRef kinds, bool updateFuncSignature = true); /// Find the suitable array partition factors and kinds for all arrays in the diff --git a/lib/Bindings/Python/CMakeLists.txt b/lib/Bindings/Python/CMakeLists.txt index 5141616..b6746e5 100644 --- a/lib/Bindings/Python/CMakeLists.txt +++ b/lib/Bindings/Python/CMakeLists.txt @@ -16,7 +16,7 @@ declare_mlir_python_extension(ScaleHLSBindingsPythonExtension.Core SOURCES ScaleHLSModule.cpp EMBED_CAPI_LINK_LIBS - MLIRScaleHLSCAPIHLSCpp + MLIRScaleHLSCAPIHLS MLIRScaleHLSCAPIEmitHLSCpp PRIVATE_LINK_LIBS LLVMSupport @@ -48,10 +48,10 @@ declare_mlir_python_sources(ScaleHLSBindingsPythonSources.Dialects declare_mlir_dialect_python_bindings( ADD_TO_PARENT ScaleHLSBindingsPythonSources.Dialects ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}" - TD_FILE scalehls/dialects/HLSCppOps.td + TD_FILE scalehls/dialects/HLSOps.td SOURCES - scalehls/dialects/hlscpp.py - DIALECT_NAME hlscpp) + scalehls/dialects/hls.py + DIALECT_NAME hls) ################################################################################ # Build composite binaries diff --git a/lib/Bindings/Python/ScaleHLSModule.cpp b/lib/Bindings/Python/ScaleHLSModule.cpp index 5fd54ec..080f6ec 100644 --- a/lib/Bindings/Python/ScaleHLSModule.cpp +++ b/lib/Bindings/Python/ScaleHLSModule.cpp @@ -13,7 +13,7 @@ #include "mlir/CAPI/IR.h" #include "mlir/Dialect/Affine/Analysis/LoopAnalysis.h" #include "scalehls-c/EmitHLSCpp.h" -#include "scalehls-c/HLSCpp.h" +#include "scalehls-c/HLS.h" #include "scalehls/Transforms/Utils.h" #include "llvm-c/ErrorHandling.h" @@ -222,10 +222,10 @@ static bool arrayPartition(MlirValue array, py::object factorsObject, py::gil_scoped_release(); llvm::SmallVector factors; getVectorFromUnsignedNpArray(factorsObject.ptr(), factors); - llvm::SmallVector kinds( - factors.size(), kind == "cyclic" ? hlscpp::PartitionKind::CYCLIC - : kind == "block" ? hlscpp::PartitionKind::BLOCK - : hlscpp::PartitionKind::NONE); + llvm::SmallVector kinds( + factors.size(), kind == "cyclic" ? hls::PartitionKind::CYCLIC + : kind == "block" ? hls::PartitionKind::BLOCK + : hls::PartitionKind::NONE); return applyArrayPartition(unwrap(array), factors, kinds); } @@ -254,9 +254,9 @@ PYBIND11_MODULE(_scalehls, m) { auto wrappedCapsule = capsule.attr(MLIR_PYTHON_CAPI_PTR_ATTR); MlirContext context = mlirPythonCapsuleToContext(wrappedCapsule.ptr()); - MlirDialectHandle hlscpp = mlirGetDialectHandle__hlscpp__(); - mlirDialectHandleRegisterDialect(hlscpp, context); - mlirDialectHandleLoadDialect(hlscpp, context); + MlirDialectHandle hls = mlirGetDialectHandle__hls__(); + mlirDialectHandleRegisterDialect(hls, context); + mlirDialectHandleLoadDialect(hls, context); }); // Loop transform APIs. diff --git a/lib/Bindings/Python/scalehls/dialects/HLSCppOps.td b/lib/Bindings/Python/scalehls/dialects/HLSOps.td similarity index 61% rename from lib/Bindings/Python/scalehls/dialects/HLSCppOps.td rename to lib/Bindings/Python/scalehls/dialects/HLSOps.td index a48693d..d8a4572 100644 --- a/lib/Bindings/Python/scalehls/dialects/HLSCppOps.td +++ b/lib/Bindings/Python/scalehls/dialects/HLSOps.td @@ -4,10 +4,10 @@ // //===----------------------------------------------------------------------===// -#ifndef BINDINGS_PYTHON_HLSCPP_OPS_TD -#define BINDINGS_PYTHON_HLSCPP_OPS_TD +#ifndef BINDINGS_PYTHON_HLS_OPS_TD +#define BINDINGS_PYTHON_HLS_OPS_TD include "mlir/Bindings/Python/Attributes.td" -include "scalehls/Dialect/HLSCpp/HLSCpp.td" +include "scalehls/Dialect/HLS/HLS.td" -#endif // BINDINGS_PYTHON_HLSCPP_OPS_TD +#endif // BINDINGS_PYTHON_HLS_OPS_TD diff --git a/lib/Bindings/Python/scalehls/dialects/hlscpp.py b/lib/Bindings/Python/scalehls/dialects/hls.py similarity index 87% rename from lib/Bindings/Python/scalehls/dialects/hlscpp.py rename to lib/Bindings/Python/scalehls/dialects/hls.py index 3c47329..9fe6bf9 100644 --- a/lib/Bindings/Python/scalehls/dialects/hlscpp.py +++ b/lib/Bindings/Python/scalehls/dialects/hls.py @@ -4,4 +4,4 @@ # # ===----------------------------------------------------------------------=== # -from ._hlscpp_ops_gen import * +from ._hls_ops_gen import * diff --git a/lib/CAPI/Dialect/CMakeLists.txt b/lib/CAPI/Dialect/CMakeLists.txt index 7d38453..fa0f368 100644 --- a/lib/CAPI/Dialect/CMakeLists.txt +++ b/lib/CAPI/Dialect/CMakeLists.txt @@ -1,10 +1,10 @@ -add_mlir_public_c_api_library(MLIRScaleHLSCAPIHLSCpp - HLSCpp.cpp +add_mlir_public_c_api_library(MLIRScaleHLSCAPIHLS + HLS.cpp ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir-c LINK_LIBS PUBLIC MLIRCAPIIR - MLIRHLSCpp + MLIRHLS ) diff --git a/lib/CAPI/Dialect/HLSCpp.cpp b/lib/CAPI/Dialect/HLS.cpp similarity index 66% rename from lib/CAPI/Dialect/HLSCpp.cpp rename to lib/CAPI/Dialect/HLS.cpp index 13832d4..d3bcda9 100644 --- a/lib/CAPI/Dialect/HLSCpp.cpp +++ b/lib/CAPI/Dialect/HLS.cpp @@ -4,11 +4,11 @@ // //===----------------------------------------------------------------------===// -#include "scalehls-c/HLSCpp.h" +#include "scalehls-c/HLS.h" #include "mlir/CAPI/Registration.h" -#include "scalehls/Dialect/HLSCpp/HLSCpp.h" +#include "scalehls/Dialect/HLS/HLS.h" using namespace mlir; using namespace scalehls; -MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(HLSCpp, hlscpp, hlscpp::HLSCppDialect) +MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(HLS, hls, hls::HLSDialect) diff --git a/lib/Dialect/CMakeLists.txt b/lib/Dialect/CMakeLists.txt index 6431d5b..2e54a5d 100644 --- a/lib/Dialect/CMakeLists.txt +++ b/lib/Dialect/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(HLSCpp) +add_subdirectory(HLS) diff --git a/lib/Dialect/HLS/CMakeLists.txt b/lib/Dialect/HLS/CMakeLists.txt new file mode 100644 index 0000000..51ac94e --- /dev/null +++ b/lib/Dialect/HLS/CMakeLists.txt @@ -0,0 +1,8 @@ +add_mlir_dialect_library(MLIRHLS + HLS.cpp + + DEPENDS + MLIRHLSIncGen + MLIRHLSEnumsIncGen + MLIRHLSAttributesIncGen + ) diff --git a/lib/Dialect/HLSCpp/HLSCpp.cpp b/lib/Dialect/HLS/HLS.cpp similarity index 85% rename from lib/Dialect/HLSCpp/HLSCpp.cpp rename to lib/Dialect/HLS/HLS.cpp index c9d3cf0..423d1f1 100644 --- a/lib/Dialect/HLSCpp/HLSCpp.cpp +++ b/lib/Dialect/HLS/HLS.cpp @@ -4,7 +4,7 @@ // //===----------------------------------------------------------------------===// -#include "scalehls/Dialect/HLSCpp/HLSCpp.h" +#include "scalehls/Dialect/HLS/HLS.h" #include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/DialectImplementation.h" #include "mlir/IR/PatternMatch.h" @@ -12,39 +12,39 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; //===----------------------------------------------------------------------===// -// HLSCpp dialect +// HLS dialect //===----------------------------------------------------------------------===// -void HLSCppDialect::initialize() { +void HLSDialect::initialize() { addTypes< #define GET_TYPEDEF_LIST -#include "scalehls/Dialect/HLSCpp/HLSCppTypes.cpp.inc" +#include "scalehls/Dialect/HLS/HLSTypes.cpp.inc" >(); addAttributes< #define GET_ATTRDEF_LIST -#include "scalehls/Dialect/HLSCpp/HLSCppAttributes.cpp.inc" +#include "scalehls/Dialect/HLS/HLSAttributes.cpp.inc" >(); addOperations< #define GET_OP_LIST -#include "scalehls/Dialect/HLSCpp/HLSCpp.cpp.inc" +#include "scalehls/Dialect/HLS/HLS.cpp.inc" >(); } //===----------------------------------------------------------------------===// -// HLSCpp dialect utils +// HLS dialect utils //===----------------------------------------------------------------------===// /// Get the users of a stream channel. If the channel is used by a function /// call, this method will recursively look into the corresponding sub-function. /// If the channel is used by a function return, this method will recursively /// look into each function that calls the parent function of the return. -void hlscpp::getStreamChannelUsers(Value channel, - SmallVectorImpl &users) { +void hls::getStreamChannelUsers(Value channel, + SmallVectorImpl &users) { assert(channel.getType().isa() && "channel must be stream type"); for (auto &use : channel.getUses()) { @@ -70,99 +70,98 @@ void hlscpp::getStreamChannelUsers(Value channel, } /// Timing attribute utils. -TimingAttr hlscpp::getTiming(Operation *op) { +TimingAttr hls::getTiming(Operation *op) { return op->getAttrOfType("timing"); } -void hlscpp::setTiming(Operation *op, TimingAttr timing) { +void hls::setTiming(Operation *op, TimingAttr timing) { assert(timing.getBegin() <= timing.getEnd() && "invalid timing attribute"); op->setAttr("timing", timing); } -void hlscpp::setTiming(Operation *op, int64_t begin, int64_t end, - int64_t latency, int64_t minII) { +void hls::setTiming(Operation *op, int64_t begin, int64_t end, int64_t latency, + int64_t minII) { auto timing = TimingAttr::get(op->getContext(), begin, end, latency, minII); setTiming(op, timing); } /// Resource attribute utils. -ResourceAttr hlscpp::getResource(Operation *op) { +ResourceAttr hls::getResource(Operation *op) { return op->getAttrOfType("resource"); } -void hlscpp::setResource(Operation *op, ResourceAttr resource) { +void hls::setResource(Operation *op, ResourceAttr resource) { op->setAttr("resource", resource); } -void hlscpp::setResource(Operation *op, int64_t lut, int64_t dsp, - int64_t bram) { +void hls::setResource(Operation *op, int64_t lut, int64_t dsp, int64_t bram) { auto resource = ResourceAttr::get(op->getContext(), lut, dsp, bram); setResource(op, resource); } /// Loop information attribute utils. -LoopInfoAttr hlscpp::getLoopInfo(Operation *op) { +LoopInfoAttr hls::getLoopInfo(Operation *op) { return op->getAttrOfType("loop_info"); } -void hlscpp::setLoopInfo(Operation *op, LoopInfoAttr loopInfo) { +void hls::setLoopInfo(Operation *op, LoopInfoAttr loopInfo) { op->setAttr("loop_info", loopInfo); } -void hlscpp::setLoopInfo(Operation *op, int64_t flattenTripCount, - int64_t iterLatency, int64_t minII) { +void hls::setLoopInfo(Operation *op, int64_t flattenTripCount, + int64_t iterLatency, int64_t minII) { auto loopInfo = LoopInfoAttr::get(op->getContext(), flattenTripCount, iterLatency, minII); setLoopInfo(op, loopInfo); } /// Loop directives attribute utils. -LoopDirectiveAttr hlscpp::getLoopDirective(Operation *op) { +LoopDirectiveAttr hls::getLoopDirective(Operation *op) { return op->getAttrOfType("loop_directive"); } -void hlscpp::setLoopDirective(Operation *op, LoopDirectiveAttr loopDirective) { +void hls::setLoopDirective(Operation *op, LoopDirectiveAttr loopDirective) { op->setAttr("loop_directive", loopDirective); } -void hlscpp::setLoopDirective(Operation *op, bool pipeline, int64_t targetII, - bool dataflow, bool flatten) { +void hls::setLoopDirective(Operation *op, bool pipeline, int64_t targetII, + bool dataflow, bool flatten) { auto loopDirective = LoopDirectiveAttr::get(op->getContext(), pipeline, targetII, dataflow, flatten); setLoopDirective(op, loopDirective); } /// Parrallel and point loop attribute utils. -void hlscpp::setParallelAttr(Operation *op) { +void hls::setParallelAttr(Operation *op) { op->setAttr("parallel", UnitAttr::get(op->getContext())); } -bool hlscpp::hasParallelAttr(Operation *op) { +bool hls::hasParallelAttr(Operation *op) { return op->hasAttrOfType("parallel"); } -void hlscpp::setPointAttr(Operation *op) { +void hls::setPointAttr(Operation *op) { op->setAttr("point", UnitAttr::get(op->getContext())); } -bool hlscpp::hasPointAttr(Operation *op) { +bool hls::hasPointAttr(Operation *op) { return op->hasAttrOfType("point"); } /// Function directives attribute utils. -FuncDirectiveAttr hlscpp::getFuncDirective(Operation *op) { +FuncDirectiveAttr hls::getFuncDirective(Operation *op) { return op->getAttrOfType("func_directive"); } -void hlscpp::setFuncDirective(Operation *op, FuncDirectiveAttr funcDirective) { +void hls::setFuncDirective(Operation *op, FuncDirectiveAttr funcDirective) { op->setAttr("func_directive", funcDirective); } -void hlscpp::setFuncDirective(Operation *op, bool pipeline, - int64_t targetInterval, bool dataflow) { +void hls::setFuncDirective(Operation *op, bool pipeline, int64_t targetInterval, + bool dataflow) { auto funcDirective = FuncDirectiveAttr::get(op->getContext(), pipeline, targetInterval, dataflow); setFuncDirective(op, funcDirective); } /// Top and runtime function attribute utils. -void hlscpp::setTopFuncAttr(Operation *op) { +void hls::setTopFuncAttr(Operation *op) { op->setAttr("top_func", UnitAttr::get(op->getContext())); } -bool hlscpp::hasTopFuncAttr(Operation *op) { +bool hls::hasTopFuncAttr(Operation *op) { return op->hasAttrOfType("top_func"); } -void hlscpp::setRuntimeAttr(Operation *op) { +void hls::setRuntimeAttr(Operation *op) { op->setAttr("runtime", UnitAttr::get(op->getContext())); } -bool hlscpp::hasRuntimeAttr(Operation *op) { +bool hls::hasRuntimeAttr(Operation *op) { return op->hasAttrOfType("runtime"); } @@ -380,7 +379,7 @@ void FuncDirectiveAttr::print(AsmPrinter &p) const { } //===----------------------------------------------------------------------===// -// HLSCpp operation canonicalizers +// HLS operation canonicalizers //===----------------------------------------------------------------------===// namespace { @@ -436,14 +435,14 @@ void BufferOp::getCanonicalizationPatterns(RewritePatternSet &results, // Include tablegen classes //===----------------------------------------------------------------------===// -#include "scalehls/Dialect/HLSCpp/HLSCppDialect.cpp.inc" -#include "scalehls/Dialect/HLSCpp/HLSCppEnums.cpp.inc" +#include "scalehls/Dialect/HLS/HLSDialect.cpp.inc" +#include "scalehls/Dialect/HLS/HLSEnums.cpp.inc" #define GET_TYPEDEF_CLASSES -#include "scalehls/Dialect/HLSCpp/HLSCppTypes.cpp.inc" +#include "scalehls/Dialect/HLS/HLSTypes.cpp.inc" #define GET_ATTRDEF_CLASSES -#include "scalehls/Dialect/HLSCpp/HLSCppAttributes.cpp.inc" +#include "scalehls/Dialect/HLS/HLSAttributes.cpp.inc" #define GET_OP_CLASSES -#include "scalehls/Dialect/HLSCpp/HLSCpp.cpp.inc" +#include "scalehls/Dialect/HLS/HLS.cpp.inc" diff --git a/lib/Dialect/HLSCpp/CMakeLists.txt b/lib/Dialect/HLSCpp/CMakeLists.txt deleted file mode 100644 index 777e486..0000000 --- a/lib/Dialect/HLSCpp/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -add_mlir_dialect_library(MLIRHLSCpp - HLSCpp.cpp - - DEPENDS - MLIRHLSCppIncGen - MLIRHLSCppEnumsIncGen - MLIRHLSCppAttributesIncGen - ) diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt index 4250280..f63e5e3 100644 --- a/lib/Support/CMakeLists.txt +++ b/lib/Support/CMakeLists.txt @@ -2,5 +2,5 @@ add_mlir_library(MLIRScaleHLSSupport Utils.cpp LINK_LIBS PUBLIC - MLIRHLSCpp + MLIRHLS ) diff --git a/lib/Support/Utils.cpp b/lib/Support/Utils.cpp index 7c17084..3d43965 100644 --- a/lib/Support/Utils.cpp +++ b/lib/Support/Utils.cpp @@ -15,7 +15,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; //===----------------------------------------------------------------------===// // Memory and loop analysis utils diff --git a/lib/Transforms/CMakeLists.txt b/lib/Transforms/CMakeLists.txt index 918d5c0..caa15cf 100644 --- a/lib/Transforms/CMakeLists.txt +++ b/lib/Transforms/CMakeLists.txt @@ -1,6 +1,6 @@ add_mlir_library(MLIRScaleHLSTransforms Directive/ArrayPartition.cpp - Directive/CreateHLSCppPrimitive.cpp + Directive/CreateHLSPrimitive.cpp Directive/FuncPipelining.cpp Directive/LoopPipelining.cpp Directive/QoREstimation.cpp diff --git a/lib/Transforms/Directive/ArrayPartition.cpp b/lib/Transforms/Directive/ArrayPartition.cpp index 79f8918..5e1ff44 100644 --- a/lib/Transforms/Directive/ArrayPartition.cpp +++ b/lib/Transforms/Directive/ArrayPartition.cpp @@ -13,7 +13,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; static void updateSubFuncs(FuncOp func, Builder builder) { func.walk([&](func::CallOp op) { @@ -47,7 +47,7 @@ static void updateSubFuncs(FuncOp func, Builder builder) { /// Apply the specified array partition factors and kinds. bool scalehls::applyArrayPartition(Value array, ArrayRef factors, - ArrayRef kinds, + ArrayRef kinds, bool updateFuncSignature) { auto builder = Builder(array.getContext()); auto arrayType = array.getType().dyn_cast(); @@ -399,7 +399,7 @@ bool scalehls::applyAutoArrayPartition(FuncOp func) { auto memref = pair.first; auto partitions = pair.second; - SmallVector kinds; + SmallVector kinds; SmallVector factors; for (auto info : partitions) { kinds.push_back(info.first); diff --git a/lib/Transforms/Directive/CreateHLSCppPrimitive.cpp b/lib/Transforms/Directive/CreateHLSPrimitive.cpp similarity index 94% rename from lib/Transforms/Directive/CreateHLSCppPrimitive.cpp rename to lib/Transforms/Directive/CreateHLSPrimitive.cpp index 5830d38..5d755cb 100644 --- a/lib/Transforms/Directive/CreateHLSCppPrimitive.cpp +++ b/lib/Transforms/Directive/CreateHLSPrimitive.cpp @@ -12,7 +12,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; static IntegerType getIntDataType(Type type) { auto dataType = type.dyn_cast(); @@ -98,8 +98,7 @@ struct MulOpRewritePattern : public OpRewritePattern { } // namespace namespace { -struct CreateHLSCppPrimitive - : public CreateHLSCppPrimitiveBase { +struct CreateHLSPrimitive : public CreateHLSPrimitiveBase { void runOnOperation() override { auto func = getOperation(); @@ -111,6 +110,6 @@ struct CreateHLSCppPrimitive }; } // namespace -std::unique_ptr scalehls::createCreateHLSCppPrimitivePass() { - return std::make_unique(); +std::unique_ptr scalehls::createCreateHLSPrimitivePass() { + return std::make_unique(); } diff --git a/lib/Transforms/Directive/FuncPipelining.cpp b/lib/Transforms/Directive/FuncPipelining.cpp index a1bfb2b..3fb2231 100644 --- a/lib/Transforms/Directive/FuncPipelining.cpp +++ b/lib/Transforms/Directive/FuncPipelining.cpp @@ -10,7 +10,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; /// Apply function pipelining to the input function, all contained loops are /// automatically fully unrolled. diff --git a/lib/Transforms/Directive/LoopPipelining.cpp b/lib/Transforms/Directive/LoopPipelining.cpp index 10d0323..429758f 100644 --- a/lib/Transforms/Directive/LoopPipelining.cpp +++ b/lib/Transforms/Directive/LoopPipelining.cpp @@ -9,7 +9,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; /// Apply loop pipelining to the input loop, all inner loops are automatically /// fully unrolled. diff --git a/lib/Transforms/Directive/QoREstimation.cpp b/lib/Transforms/Directive/QoREstimation.cpp index 5a71991..d2e3e51 100644 --- a/lib/Transforms/Directive/QoREstimation.cpp +++ b/lib/Transforms/Directive/QoREstimation.cpp @@ -15,7 +15,7 @@ using namespace std; using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; //===----------------------------------------------------------------------===// // LoadOp and StoreOp Related Methods diff --git a/lib/Transforms/Graph/ConvertDataflowToFunc.cpp b/lib/Transforms/Graph/ConvertDataflowToFunc.cpp index 82ce202..f795dce 100644 --- a/lib/Transforms/Graph/ConvertDataflowToFunc.cpp +++ b/lib/Transforms/Graph/ConvertDataflowToFunc.cpp @@ -5,13 +5,13 @@ //===----------------------------------------------------------------------===// #include "mlir/Transforms/GreedyPatternRewriteDriver.h" -#include "scalehls/Dialect/HLSCpp/HLSCpp.h" +#include "scalehls/Dialect/HLS/HLS.h" #include "scalehls/Transforms/Passes.h" #include "scalehls/Transforms/Utils.h" using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; namespace { struct ConvertDataflowToFuncPattern : public OpRewritePattern { diff --git a/lib/Transforms/Graph/CreateTokenFlow.cpp b/lib/Transforms/Graph/CreateTokenFlow.cpp index 76da9e6..c03245c 100644 --- a/lib/Transforms/Graph/CreateTokenFlow.cpp +++ b/lib/Transforms/Graph/CreateTokenFlow.cpp @@ -4,13 +4,13 @@ // //===----------------------------------------------------------------------===// -#include "scalehls/Dialect/HLSCpp/HLSCpp.h" +#include "scalehls/Dialect/HLS/HLS.h" #include "scalehls/Transforms/Passes.h" #include "scalehls/Transforms/Utils.h" using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; namespace { struct CreateTokenFlow : public CreateTokenFlowBase { diff --git a/lib/Transforms/Graph/DataflowBufferize.cpp b/lib/Transforms/Graph/DataflowBufferize.cpp index 70afe3d..f15e812 100644 --- a/lib/Transforms/Graph/DataflowBufferize.cpp +++ b/lib/Transforms/Graph/DataflowBufferize.cpp @@ -7,13 +7,13 @@ #include "mlir/Dialect/Tosa/IR/TosaOps.h" #include "mlir/IR/Dominance.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" -#include "scalehls/Dialect/HLSCpp/HLSCpp.h" +#include "scalehls/Dialect/HLS/HLS.h" #include "scalehls/Transforms/Passes.h" #include "scalehls/Transforms/Utils.h" using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; namespace { /// This pattern will outline ops with the specified type. diff --git a/lib/Transforms/Graph/FuncDataflow.cpp b/lib/Transforms/Graph/FuncDataflow.cpp index 3c4af27..510a488 100644 --- a/lib/Transforms/Graph/FuncDataflow.cpp +++ b/lib/Transforms/Graph/FuncDataflow.cpp @@ -11,13 +11,13 @@ #include "mlir/Dialect/Tosa/IR/TosaOps.h" #include "mlir/IR/Dominance.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" -#include "scalehls/Dialect/HLSCpp/HLSCpp.h" +#include "scalehls/Dialect/HLS/HLS.h" #include "scalehls/Transforms/Passes.h" #include "scalehls/Transforms/Utils.h" using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; namespace { struct DataflowGraph { @@ -179,11 +179,11 @@ bool Dataflower::applyLegalizeDataflow(int64_t gran, bool balance) { copyOp = builder.create(op->getLoc(), values.back(), newValue); } else if (auto type = value.getType().dyn_cast()) { - copyOp = builder.create( + copyOp = builder.create( op->getLoc(), value.getType(), values.back()); newValue = copyOp->getResult(0); } else { - copyOp = builder.create( + copyOp = builder.create( op->getLoc(), value.getType(), values.back()); newValue = copyOp->getResult(0); } diff --git a/lib/Transforms/Graph/HoistStreamChannel.cpp b/lib/Transforms/Graph/HoistStreamChannel.cpp index 9be70de..bf67e86 100644 --- a/lib/Transforms/Graph/HoistStreamChannel.cpp +++ b/lib/Transforms/Graph/HoistStreamChannel.cpp @@ -10,7 +10,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; // Updates the func op and entry block. Any args appended to the entry block are // added to `appendedEntryArgs`. @@ -22,7 +22,7 @@ static void updateFuncOp(FuncOp func, SmallVector erasedResultTypes; BitVector erasedResultIndices(functionType.getNumResults()); for (const auto &resultType : llvm::enumerate(functionType.getResults())) { - if (resultType.value().isa()) { + if (resultType.value().isa()) { erasedResultIndices.set(resultType.index()); erasedResultTypes.push_back(resultType.value()); } @@ -70,7 +70,7 @@ static void updateReturnOps(FuncOp func, OpBuilder builder(op); for (auto t : llvm::zip(copyIntoOutParams, appendedEntryArgs)) { std::get<0>(t).replaceAllUsesWith(std::get<1>(t)); - if (auto stream = std::get<0>(t).getDefiningOp()) + if (auto stream = std::get<0>(t).getDefiningOp()) stream.erase(); } builder.create(op.getLoc(), keepAsReturnOperands); @@ -85,7 +85,7 @@ static void updateCalls(ModuleOp module) { SmallVector replaceWithNewCallResults; SmallVector replaceWithOutParams; for (OpResult result : op.getResults()) { - if (result.getType().isa()) + if (result.getType().isa()) replaceWithOutParams.push_back(result); else replaceWithNewCallResults.push_back(result); @@ -93,7 +93,7 @@ static void updateCalls(ModuleOp module) { SmallVector outParams; OpBuilder builder(op); for (Value stream : replaceWithOutParams) { - Value outParam = builder.create( + Value outParam = builder.create( op.getLoc(), stream.getType().cast()); stream.replaceAllUsesWith(outParam); outParams.push_back(outParam); @@ -113,27 +113,26 @@ static void updateCalls(ModuleOp module) { namespace { struct LowerStreamBufferOpRewritePattern - : public OpRewritePattern { - using OpRewritePattern::OpRewritePattern; + : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; - LogicalResult matchAndRewrite(hlscpp::StreamBufferOp buffer, + LogicalResult matchAndRewrite(hls::StreamBufferOp buffer, PatternRewriter &rewriter) const override { auto loc = buffer.getLoc(); auto block = buffer->getBlock(); rewriter.setInsertionPointToStart(block); - if (!llvm::any_of(buffer.input().getUsers(), [](Operation *op) { - return isa(op); - })) - rewriter.create(loc, Type(), buffer.input()); - auto channel = rewriter.replaceOpWithNewOp( + if (!llvm::any_of(buffer.input().getUsers(), + [](Operation *op) { return isa(op); })) + rewriter.create(loc, Type(), buffer.input()); + auto channel = rewriter.replaceOpWithNewOp( buffer, buffer.getType()); rewriter.setInsertionPoint(block->getTerminator()); auto tokenType = channel.getType().cast().getElementType(); auto tokenValue = rewriter.create( loc, rewriter.getZeroAttr(tokenType)); - rewriter.create(loc, channel, tokenValue); + rewriter.create(loc, channel, tokenValue); return success(); } }; diff --git a/lib/Transforms/Graph/TosaNodeFusion.cpp b/lib/Transforms/Graph/TosaNodeFusion.cpp index 55a7c6a..a1cb41d 100644 --- a/lib/Transforms/Graph/TosaNodeFusion.cpp +++ b/lib/Transforms/Graph/TosaNodeFusion.cpp @@ -7,13 +7,13 @@ #include "mlir/Dialect/Tosa/IR/TosaOps.h" #include "mlir/IR/Dominance.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" -#include "scalehls/Dialect/HLSCpp/HLSCpp.h" +#include "scalehls/Dialect/HLS/HLS.h" #include "scalehls/Transforms/Passes.h" #include "scalehls/Transforms/Utils.h" using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; namespace { /// This pattern will outline ops with the specified type. diff --git a/lib/Transforms/Loop/AffineLoopTile.cpp b/lib/Transforms/Loop/AffineLoopTile.cpp index 9238ee7..7712302 100644 --- a/lib/Transforms/Loop/AffineLoopTile.cpp +++ b/lib/Transforms/Loop/AffineLoopTile.cpp @@ -14,7 +14,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; /// Apply loop tiling to the input loop band and sink all intra-tile loops to /// the innermost loop with the original loop order. diff --git a/lib/Transforms/Loop/ConvertCopyToAffineLoops.cpp b/lib/Transforms/Loop/ConvertCopyToAffineLoops.cpp index df64938..689cb20 100644 --- a/lib/Transforms/Loop/ConvertCopyToAffineLoops.cpp +++ b/lib/Transforms/Loop/ConvertCopyToAffineLoops.cpp @@ -16,7 +16,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; namespace { struct AllocOpRewritePattern : public OpRewritePattern { diff --git a/lib/Transforms/Loop/FuncPreprocess.cpp b/lib/Transforms/Loop/FuncPreprocess.cpp index eb138a4..f4f65c1 100644 --- a/lib/Transforms/Loop/FuncPreprocess.cpp +++ b/lib/Transforms/Loop/FuncPreprocess.cpp @@ -14,7 +14,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; namespace { /// Simple memref load to affine load raising. diff --git a/lib/Transforms/Memory/CreateMemrefSubview.cpp b/lib/Transforms/Memory/CreateMemrefSubview.cpp index 150c01b..a845955 100644 --- a/lib/Transforms/Memory/CreateMemrefSubview.cpp +++ b/lib/Transforms/Memory/CreateMemrefSubview.cpp @@ -12,7 +12,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; namespace { struct CreateMemrefSubview diff --git a/lib/Transforms/Memory/PromoteBuffer.cpp b/lib/Transforms/Memory/PromoteBuffer.cpp index e57babc..b30b048 100644 --- a/lib/Transforms/Memory/PromoteBuffer.cpp +++ b/lib/Transforms/Memory/PromoteBuffer.cpp @@ -13,7 +13,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; static void createBufferAndCopy(MemRefType type, Value memref, OpBuilder &builder) { diff --git a/lib/Transforms/Passes.cpp b/lib/Transforms/Passes.cpp index b54b520..078c28d 100644 --- a/lib/Transforms/Passes.cpp +++ b/lib/Transforms/Passes.cpp @@ -160,7 +160,7 @@ void scalehls::registerScaleHLSPyTorchPipeline() { pm.addPass(mlir::createCanonicalizerPass()); pm.addPass(scalehls::createLoopPipeliningPass()); pm.addPass(scalehls::createArrayPartitionPass()); - pm.addPass(scalehls::createCreateHLSCppPrimitivePass()); + pm.addPass(scalehls::createCreateHLSPrimitivePass()); pm.addPass(mlir::createCanonicalizerPass()); }); } @@ -279,7 +279,7 @@ void scalehls::registerScaleHLSPyTorchPipelineV2() { pm.addPass(scalehls::createLoopPipeliningPass()); pm.addPass(scalehls::createArrayPartitionPass()); - pm.addPass(scalehls::createCreateHLSCppPrimitivePass()); + pm.addPass(scalehls::createCreateHLSPrimitivePass()); pm.addPass(mlir::createCanonicalizerPass()); }); } diff --git a/lib/Transforms/Runtime/CreateAxiInterface.cpp b/lib/Transforms/Runtime/CreateAxiInterface.cpp index 1784846..639ebe6 100644 --- a/lib/Transforms/Runtime/CreateAxiInterface.cpp +++ b/lib/Transforms/Runtime/CreateAxiInterface.cpp @@ -11,7 +11,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; // A helper to get corresponding DRAM memref type from normal memref type. static MemRefType getDramType(MemRefType type) { diff --git a/lib/Transforms/Runtime/CreateRuntimeMain.cpp b/lib/Transforms/Runtime/CreateRuntimeMain.cpp index 8dba206..f250b8b 100644 --- a/lib/Transforms/Runtime/CreateRuntimeMain.cpp +++ b/lib/Transforms/Runtime/CreateRuntimeMain.cpp @@ -10,7 +10,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; static SmallVector collectConstantsAndUpdateFuncionType(FuncOp func) { diff --git a/lib/Transforms/Utils.cpp b/lib/Transforms/Utils.cpp index ddef1a7..5b2d740 100644 --- a/lib/Transforms/Utils.cpp +++ b/lib/Transforms/Utils.cpp @@ -13,7 +13,7 @@ using namespace mlir; using namespace scalehls; -using namespace hlscpp; +using namespace hls; static void addMemoryOptsPipeline(PassManager &pm) { // To factor out the redundant affine operations. diff --git a/lib/Translation/CMakeLists.txt b/lib/Translation/CMakeLists.txt index 0ac840a..d21814d 100644 --- a/lib/Translation/CMakeLists.txt +++ b/lib/Translation/CMakeLists.txt @@ -2,6 +2,6 @@ add_mlir_library(MLIRScaleHLSEmitHLSCpp EmitHLSCpp.cpp LINK_LIBS PUBLIC - MLIRHLSCpp + MLIRHLS MLIRScaleHLSSupport ) diff --git a/lib/Translation/EmitHLSCpp.cpp b/lib/Translation/EmitHLSCpp.cpp index eb4a188..3ee237c 100644 --- a/lib/Translation/EmitHLSCpp.cpp +++ b/lib/Translation/EmitHLSCpp.cpp @@ -9,7 +9,7 @@ #include "mlir/IR/AffineExprVisitor.h" #include "mlir/IR/IntegerSet.h" #include "mlir/Translation.h" -#include "scalehls/Dialect/HLSCpp/Visitor.h" +#include "scalehls/Dialect/HLS/Visitor.h" #include "scalehls/InitAllDialects.h" #include "scalehls/Support/Utils.h" #include "llvm/Support/raw_ostream.h" @@ -226,7 +226,7 @@ public: void emitTensorToMemref(bufferization::ToMemrefOp op); void emitMemrefToTensor(bufferization::ToTensorOp op); - /// HLSCpp dialect operation emitters. + /// HLS dialect operation emitters. void emitStreamChannel(StreamChannelOp op); void emitStreamRead(StreamReadOp op); void emitStreamWrite(StreamWriteOp op); @@ -358,11 +358,11 @@ private: //===----------------------------------------------------------------------===// namespace { -class StmtVisitor : public HLSCppVisitorBase { +class StmtVisitor : public HLSVisitorBase { public: StmtVisitor(ModuleEmitter &emitter) : emitter(emitter) {} - using HLSCppVisitorBase::visitOp; + using HLSVisitorBase::visitOp; /// SCF statements. bool visitOp(scf::ForOp op) { return emitter.emitScfFor(op), true; }; bool visitOp(scf::IfOp op) { return emitter.emitScfIf(op), true; }; @@ -429,7 +429,7 @@ public: return emitter.emitMemrefToTensor(op), true; } - /// HLSCpp dialect operations. + /// HLS dialect operations. bool visitOp(StreamChannelOp op) { return emitter.emitStreamChannel(op), true; } @@ -449,10 +449,10 @@ private: } // namespace namespace { -class ExprVisitor : public HLSCppVisitorBase { +class ExprVisitor : public HLSVisitorBase { public: ExprVisitor(ModuleEmitter &emitter) : emitter(emitter) {} - using HLSCppVisitorBase::visitOp; + using HLSVisitorBase::visitOp; /// Unary expressions. bool visitOp(math::AbsOp op) { return emitter.emitUnary(op, "abs"), true; } @@ -1263,7 +1263,7 @@ void ModuleEmitter::emitMemrefToTensor(bufferization::ToTensorOp op) { } } -/// HLSCpp dialect operation emitters. +/// HLS dialect operation emitters. void ModuleEmitter::emitStreamChannel(StreamChannelOp op) { indent(); emitValue(op.channel()); diff --git a/test/Bindings/import.py b/test/Bindings/import.py index 40a7f20..903d083 100644 --- a/test/Bindings/import.py +++ b/test/Bindings/import.py @@ -4,4 +4,4 @@ import mlir.ir from mlir.dialects import builtin import scalehls -from scalehls.dialects import hlscpp +from scalehls.dialects import hls diff --git a/test/Dialect/errors.mlir b/test/Dialect/errors.mlir index 6ed6e40..91a94e8 100644 --- a/test/Dialect/errors.mlir +++ b/test/Dialect/errors.mlir @@ -1,22 +1,22 @@ // RUN: scalehls-opt %s -verify-diagnostics -func @node0() -> (!hlscpp.stream) { - // expected-error @+1 {{'hlscpp.stream.channel' op stream channel is written by multiple ops}} - %channel = "hlscpp.stream.channel"() : () -> !hlscpp.stream - return %channel : !hlscpp.stream +func @node0() -> (!hls.stream) { + // expected-error @+1 {{'hls.stream.channel' op stream channel is written by multiple ops}} + %channel = "hls.stream.channel"() : () -> !hls.stream + return %channel : !hls.stream } -func @node1(%channel : !hlscpp.stream) { - call @node0() : () -> !hlscpp.stream +func @node1(%channel : !hls.stream) { + call @node0() : () -> !hls.stream %false = arith.constant false - "hlscpp.stream.write"(%channel, %false) : (!hlscpp.stream, i1) -> () + "hls.stream.write"(%channel, %false) : (!hls.stream, i1) -> () return } func @dataflow() { - %channel = call @node0() : () -> !hlscpp.stream - call @node1(%channel) : (!hlscpp.stream) -> () + %channel = call @node0() : () -> !hls.stream + call @node1(%channel) : (!hls.stream) -> () %false = arith.constant false - "hlscpp.stream.write"(%channel, %false) : (!hlscpp.stream, i1) -> () + "hls.stream.write"(%channel, %false) : (!hls.stream, i1) -> () return } diff --git a/test/EmitHLSCpp/test-call.mlir b/test/EmitHLSCpp/test-call.mlir index f6bb23a..e5b821c 100644 --- a/test/EmitHLSCpp/test-call.mlir +++ b/test/EmitHLSCpp/test-call.mlir @@ -1,6 +1,6 @@ // RUN: scalehls-translate -emit-hlscpp %s | FileCheck %s -func @callee(%arg0: index, %arg1: memref<16xindex>) -> (index, index, memref<16xindex>, memref<16xindex>) attributes {func_directive = #hlscpp.fd} { +func @callee(%arg0: index, %arg1: memref<16xindex>) -> (index, index, memref<16xindex>, memref<16xindex>) attributes {func_directive = #hls.fd} { // CHECK-NOT: #pragma HLS interface s_axilite port=return bundle=ctrl // CHECK-NOT: #pragma HLS interface s_axilite port=v0 bundle=ctrl // CHECK-NOT: #pragma HLS interface s_axilite port=v2 bundle=ctrl @@ -13,7 +13,7 @@ func @callee(%arg0: index, %arg1: memref<16xindex>) -> (index, index, memref<16x return %0, %1, %2, %3 : index, index, memref<16xindex>, memref<16xindex> } -func @test_call(%arg0: index, %arg1: memref<16xindex>) -> (index, memref<16xindex>) attributes {func_directive = #hlscpp.fd, top_func} { +func @test_call(%arg0: index, %arg1: memref<16xindex>) -> (index, memref<16xindex>) attributes {func_directive = #hls.fd, top_func} { // CHECK: #pragma HLS interface s_axilite port=return bundle=ctrl // CHECK: #pragma HLS interface s_axilite port=v6 bundle=ctrl // CHECK: #pragma HLS interface s_axilite port=v8 bundle=ctrl diff --git a/test/EmitHLSCpp/test-syrk.mlir b/test/EmitHLSCpp/test-syrk.mlir index eee3270..be022ec 100644 --- a/test/EmitHLSCpp/test-syrk.mlir +++ b/test/EmitHLSCpp/test-syrk.mlir @@ -53,7 +53,7 @@ #set0 = affine_set<(d0, d1) : (d0 - d1 >= 0)> #set1 = affine_set<(d0) : (d0 == 0)> module { - func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, #map0>, %arg3: memref<16x16xf32, #map1>) attributes {func_directive = #hlscpp.fd, top_func} { + func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, #map0>, %arg3: memref<16x16xf32, #map1>) attributes {func_directive = #hls.fd, top_func} { affine.for %arg4 = 0 to 16 step 2 { affine.for %arg5 = 0 to 16 { affine.for %arg6 = 0 to 16 { @@ -77,9 +77,9 @@ module { %12 = arith.addf %11, %7 : f32 affine.store %12, %arg3[%arg5, %arg6] : memref<16x16xf32, #map1> } - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} return } } diff --git a/test/Transforms/Directive/array-partition.mlir b/test/Transforms/Directive/array-partition.mlir index 247f63e..378dc59 100644 --- a/test/Transforms/Directive/array-partition.mlir +++ b/test/Transforms/Directive/array-partition.mlir @@ -7,8 +7,8 @@ module { // CHECK-LABEL: func @test_syrk( - // CHECK-SAME: %arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, #map0>, %arg3: memref<16x16xf32, #map1>) attributes {func_directive = #hlscpp.fd, top_func} { - func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32>, %arg3: memref<16x16xf32>) attributes {func_directive = #hlscpp.fd, top_func} { + // CHECK-SAME: %arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, #map0>, %arg3: memref<16x16xf32, #map1>) attributes {func_directive = #hls.fd, top_func} { + func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32>, %arg3: memref<16x16xf32>) attributes {func_directive = #hls.fd, top_func} { affine.for %arg4 = 0 to 16 step 2 { affine.for %arg5 = 0 to 16 { affine.for %arg6 = 0 to 16 { @@ -38,9 +38,9 @@ module { // CHECK: affine.store %12, %arg3[%arg5, %arg6] : memref<16x16xf32, #map1> affine.store %12, %arg3[%arg5, %arg6] : memref<16x16xf32> } - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld} return } } @@ -85,13 +85,13 @@ module { %11 = arith.muli %8, %9 : vector<2xi8> %12 = arith.addi %10, %11 : vector<2xi8> vector.transfer_write %12, %arg2[%arg3, %6, %arg5, %arg6] : vector<2xi8>, memref<1x32x32x64xi8> - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} return } } diff --git a/test/Transforms/Directive/create-hlscpp-primitive.mlir b/test/Transforms/Directive/create-hlscpp-primitive.mlir index e758182..a4ce68a 100644 --- a/test/Transforms/Directive/create-hlscpp-primitive.mlir +++ b/test/Transforms/Directive/create-hlscpp-primitive.mlir @@ -1,4 +1,4 @@ -// RUN: scalehls-opt -scalehls-create-hlscpp-primitive %s | FileCheck %s +// RUN: scalehls-opt -scalehls-create-hls-primitive %s | FileCheck %s #map0 = affine_map<(d0, d1, d2, d3) -> (0, 0, 0, 0, d0, d1, d2, d3)> #map1 = affine_map<(d0, d1, d2, d3) -> (0, 0, 0, d3 mod 2, d0, d1, d2, d3 floordiv 2)> @@ -21,14 +21,14 @@ module { %2 = vector.transfer_read %arg1[%arg7, %arg8, %arg9, %arg6], %c0_i8 : memref<3x3x64x64xi8, #map1>, vector<2xi8> %3 = vector.transfer_read %arg2[%arg3, %arg4, %arg5, %arg6], %c0_i8 : memref<1x32x32x64xi8, #map2>, vector<2xi8> - // CHECK: %3 = "hlscpp.prim.mul"(%0, %1) : (i8, vector<2xi8>) -> vector<2xi16> - // CHECK: %4 = "hlscpp.prim.cast"(%3) : (vector<2xi16>) -> vector<2xi8> + // CHECK: %3 = "hls.prim.mul"(%0, %1) : (i8, vector<2xi8>) -> vector<2xi16> + // CHECK: %4 = "hls.prim.cast"(%3) : (vector<2xi16>) -> vector<2xi8> %4 = arith.muli %1, %2 : vector<2xi8> - // CHECK: %5 = "hlscpp.prim.cast"(%2) : (vector<2xi8>) -> vector<2xi32> - // CHECK: %6 = "hlscpp.prim.cast"(%4) : (vector<2xi8>) -> vector<2xi32> + // CHECK: %5 = "hls.prim.cast"(%2) : (vector<2xi8>) -> vector<2xi32> + // CHECK: %6 = "hls.prim.cast"(%4) : (vector<2xi8>) -> vector<2xi32> // CHECK: %7 = arith.addi %5, %6 : vector<2xi32> - // CHECK: %8 = "hlscpp.prim.cast"(%7) : (vector<2xi32>) -> vector<2xi8> + // CHECK: %8 = "hls.prim.cast"(%7) : (vector<2xi32>) -> vector<2xi8> %5 = arith.addi %3, %4 : vector<2xi8> vector.transfer_write %5, %arg2[%arg3, %arg4, %arg5, %arg6] : vector<2xi8>, memref<1x32x32x64xi8, #map2> %6 = affine.apply #map3(%arg4) @@ -39,13 +39,13 @@ module { %11 = arith.muli %8, %9 : vector<2xi8> %12 = arith.addi %10, %11 : vector<2xi8> vector.transfer_write %12, %arg2[%arg3, %6, %arg5, %arg6] : vector<2xi8>, memref<1x32x32x64xi8, #map2> - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld} return } } diff --git a/test/Transforms/Directive/loop-pipelining.mlir b/test/Transforms/Directive/loop-pipelining.mlir index 7712e71..eac3f81 100644 --- a/test/Transforms/Directive/loop-pipelining.mlir +++ b/test/Transforms/Directive/loop-pipelining.mlir @@ -8,7 +8,7 @@ #set0 = affine_set<(d0, d1) : (d0 - d1 >= 0)> #set1 = affine_set<(d0) : (d0 == 0)> module { - func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32>, %arg3: memref<16x16xf32>) attributes {func_directive = #hlscpp.fd, top_func} { + func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32>, %arg3: memref<16x16xf32>) attributes {func_directive = #hls.fd, top_func} { affine.for %arg4 = 0 to 16 step 2 { affine.for %arg5 = 0 to 16 { affine.for %arg6 = 0 to 16 { @@ -50,19 +50,19 @@ module { // CHECK: affine.store %8, %arg3[%arg5, %arg6] : memref<16x16xf32> // CHECK: } - // CHECK-NOT: } {loop_directive = #hlscpp.ld, parallel} - // CHECK-NOT: } {loop_directive = #hlscpp.ld, parallel} - // CHECK-NOT: } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld} + // CHECK-NOT: } {loop_directive = #hls.ld, parallel} + // CHECK-NOT: } {loop_directive = #hls.ld, parallel} + // CHECK-NOT: } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld} - // CHECK: } {loop_directive = #hlscpp.ld, parallel} - // CHECK: } {loop_directive = #hlscpp.ld, parallel} - // CHECK: } {loop_directive = #hlscpp.ld} - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld} + // CHECK: } {loop_directive = #hls.ld, parallel} + // CHECK: } {loop_directive = #hls.ld, parallel} + // CHECK: } {loop_directive = #hls.ld} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld} return } } diff --git a/test/Transforms/Directive/qor-estimation.mlir b/test/Transforms/Directive/qor-estimation.mlir index 7611b42..eb09662 100644 --- a/test/Transforms/Directive/qor-estimation.mlir +++ b/test/Transforms/Directive/qor-estimation.mlir @@ -5,8 +5,8 @@ #set0 = affine_set<(d0, d1) : (d0 - d1 >= 0)> #set1 = affine_set<(d0) : (d0 == 0)> module { - // CHECK: attributes {func_directive = #hlscpp.fd, resource = #hlscpp.r, timing = #hlscpp.t<0 -> 4119, 4119, 4119>, top_func} - func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, #map0>, %arg3: memref<16x16xf32, #map1>) attributes {func_directive = #hlscpp.fd, top_func} { + // CHECK: attributes {func_directive = #hls.fd, resource = #hls.r, timing = #hls.t<0 -> 4119, 4119, 4119>, top_func} + func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, #map0>, %arg3: memref<16x16xf32, #map1>) attributes {func_directive = #hls.fd, top_func} { affine.for %arg4 = 0 to 16 step 2 { affine.for %arg5 = 0 to 16 { affine.for %arg6 = 0 to 16 { @@ -30,9 +30,9 @@ module { %12 = arith.addf %11, %7 : f32 affine.store %12, %arg3[%arg5, %arg6] : memref<16x16xf32, #map1> } - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld} return } } diff --git a/test/Transforms/Graph/create-token-flow.mlir b/test/Transforms/Graph/create-token-flow.mlir index 3e56e07..fe524e7 100644 --- a/test/Transforms/Graph/create-token-flow.mlir +++ b/test/Transforms/Graph/create-token-flow.mlir @@ -1,7 +1,7 @@ // RUN: scalehls-opt -scalehls-create-token-flow %s | FileCheck %s module { - // CHECK: func @forward_node0(%arg0: tensor<1x3x32x32xi8>) -> (tensor<1x32x32x64xi8>, !hlscpp.stream) { + // CHECK: func @forward_node0(%arg0: tensor<1x3x32x32xi8>) -> (tensor<1x32x32x64xi8>, !hls.stream) { func @forward_node0(%arg0: tensor<1x3x32x32xi8>) -> tensor<1x32x32x64xi8> { %0 = "tosa.const"() {value = dense<4> : tensor<64x3x3x3xi8>} : () -> tensor<64x3x3x3xi8> %1 = "tosa.const"() {value = dense<5> : tensor<64xi8>} : () -> tensor<64xi8> @@ -10,107 +10,107 @@ module { %4 = "tosa.conv2d"(%3, %0, %1) {dilation = [1, 1], pad = [1, 1, 1, 1], quantization_info = {input_zp = 0 : i32, weight_zp = 0 : i32}, stride = [1, 1]} : (tensor<1x32x32x3xi8>, tensor<64x3x3x3xi8>, tensor<64xi8>) -> tensor<1x32x32x64xi8> %5 = "tosa.clamp"(%4) {max_fp = 3.40282347E+38 : f32, max_int = 2147483647 : i64, min_fp = 0.000000e+00 : f32, min_int = 0 : i64} : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> - // CHECK: %6 = "hlscpp.stream.channel"() : () -> !hlscpp.stream + // CHECK: %6 = "hls.stream.channel"() : () -> !hls.stream // CHECK: %false = arith.constant false - // CHECK: "hlscpp.stream.write"(%6, %false) : (!hlscpp.stream, i1) -> () - // CHECK: return %5, %6 : tensor<1x32x32x64xi8>, !hlscpp.stream + // CHECK: "hls.stream.write"(%6, %false) : (!hls.stream, i1) -> () + // CHECK: return %5, %6 : tensor<1x32x32x64xi8>, !hls.stream return %5 : tensor<1x32x32x64xi8> } - // CHECK: func @forward_node1(%arg0: tensor<1x32x32x64xi8>, %arg1: !hlscpp.stream) -> (tensor<1x32x32x64xi8>, !hlscpp.stream) { + // CHECK: func @forward_node1(%arg0: tensor<1x32x32x64xi8>, %arg1: !hls.stream) -> (tensor<1x32x32x64xi8>, !hls.stream) { func @forward_node1(%arg0: tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> { - // CHECK: "hlscpp.stream.read"(%arg1) : (!hlscpp.stream) -> () + // CHECK: "hls.stream.read"(%arg1) : (!hls.stream) -> () %0 = "tosa.const"() {value = dense<3> : tensor<64x3x3x64xi8>} : () -> tensor<64x3x3x64xi8> %1 = "tosa.const"() {value = dense<5> : tensor<64xi8>} : () -> tensor<64xi8> %2 = "tosa.conv2d"(%arg0, %0, %1) {dilation = [1, 1], pad = [1, 1, 1, 1], quantization_info = {input_zp = 0 : i32, weight_zp = 0 : i32}, stride = [1, 1]} : (tensor<1x32x32x64xi8>, tensor<64x3x3x64xi8>, tensor<64xi8>) -> tensor<1x32x32x64xi8> %3 = "tosa.clamp"(%2) {max_fp = 3.40282347E+38 : f32, max_int = 2147483647 : i64, min_fp = 0.000000e+00 : f32, min_int = 0 : i64} : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> - // CHECK: return %3, %4 : tensor<1x32x32x64xi8>, !hlscpp.stream + // CHECK: return %3, %4 : tensor<1x32x32x64xi8>, !hls.stream return %3 : tensor<1x32x32x64xi8> } - // CHECK: func @forward_node2(%arg0: tensor<1x32x32x64xi8>, %arg1: !hlscpp.stream) -> (tensor<1x32x32x64xi8>, !hlscpp.stream) { + // CHECK: func @forward_node2(%arg0: tensor<1x32x32x64xi8>, %arg1: !hls.stream) -> (tensor<1x32x32x64xi8>, !hls.stream) { func @forward_node2(%arg0: tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> { - // CHECK: "hlscpp.stream.read"(%arg1) : (!hlscpp.stream) -> () + // CHECK: "hls.stream.read"(%arg1) : (!hls.stream) -> () %0 = "tosa.const"() {value = dense<2> : tensor<64x3x3x64xi8>} : () -> tensor<64x3x3x64xi8> %1 = "tosa.const"() {value = dense<5> : tensor<64xi8>} : () -> tensor<64xi8> %2 = "tosa.conv2d"(%arg0, %0, %1) {dilation = [1, 1], pad = [1, 1, 1, 1], quantization_info = {input_zp = 0 : i32, weight_zp = 0 : i32}, stride = [1, 1]} : (tensor<1x32x32x64xi8>, tensor<64x3x3x64xi8>, tensor<64xi8>) -> tensor<1x32x32x64xi8> - // CHECK: return %2, %3 : tensor<1x32x32x64xi8>, !hlscpp.stream + // CHECK: return %2, %3 : tensor<1x32x32x64xi8>, !hls.stream return %2 : tensor<1x32x32x64xi8> } - // CHECK: func @forward_node3(%arg0: tensor<1x32x32x64xi8>, %arg1: tensor<1x32x32x64xi8>, %arg2: !hlscpp.stream, %arg3: !hlscpp.stream) -> (tensor<1x32x32x64xi8>, !hlscpp.stream) { + // CHECK: func @forward_node3(%arg0: tensor<1x32x32x64xi8>, %arg1: tensor<1x32x32x64xi8>, %arg2: !hls.stream, %arg3: !hls.stream) -> (tensor<1x32x32x64xi8>, !hls.stream) { func @forward_node3(%arg0: tensor<1x32x32x64xi8>, %arg1: tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> { - // CHECK: "hlscpp.stream.read"(%arg3) : (!hlscpp.stream) -> () - // CHECK: "hlscpp.stream.read"(%arg2) : (!hlscpp.stream) -> () + // CHECK: "hls.stream.read"(%arg3) : (!hls.stream) -> () + // CHECK: "hls.stream.read"(%arg2) : (!hls.stream) -> () %0 = "tosa.add"(%arg0, %arg1) : (tensor<1x32x32x64xi8>, tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> %1 = "tosa.clamp"(%0) {max_fp = 3.40282347E+38 : f32, max_int = 2147483647 : i64, min_fp = 0.000000e+00 : f32, min_int = 0 : i64} : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> - // CHECK: return %1, %2 : tensor<1x32x32x64xi8>, !hlscpp.stream + // CHECK: return %1, %2 : tensor<1x32x32x64xi8>, !hls.stream return %1 : tensor<1x32x32x64xi8> } - // CHECK: func @forward_node4(%arg0: tensor<1x32x32x64xi8>, %arg1: !hlscpp.stream) -> (tensor<1x1x1x64xi8>, !hlscpp.stream) { + // CHECK: func @forward_node4(%arg0: tensor<1x32x32x64xi8>, %arg1: !hls.stream) -> (tensor<1x1x1x64xi8>, !hls.stream) { func @forward_node4(%arg0: tensor<1x32x32x64xi8>) -> tensor<1x1x1x64xi8> { - // CHECK: "hlscpp.stream.read"(%arg1) : (!hlscpp.stream) -> () + // CHECK: "hls.stream.read"(%arg1) : (!hls.stream) -> () %0 = "tosa.avg_pool2d"(%arg0) {kernel = [32, 32], pad = [0, 0, 0, 0], quantization_info = {input_zp = 0 : i32, output_zp = 0 : i32}, stride = [32, 32]} : (tensor<1x32x32x64xi8>) -> tensor<1x1x1x64xi8> - // CHECK: return %0, %1 : tensor<1x1x1x64xi8>, !hlscpp.stream + // CHECK: return %0, %1 : tensor<1x1x1x64xi8>, !hls.stream return %0 : tensor<1x1x1x64xi8> } - // CHECK: func @forward_node5(%arg0: tensor<1x1x1x64xi8>, %arg1: !hlscpp.stream) -> (tensor<1x1x10xi8>, !hlscpp.stream) { + // CHECK: func @forward_node5(%arg0: tensor<1x1x1x64xi8>, %arg1: !hls.stream) -> (tensor<1x1x10xi8>, !hls.stream) { func @forward_node5(%arg0: tensor<1x1x1x64xi8>) -> tensor<1x1x10xi8> { - // CHECK: "hlscpp.stream.read"(%arg1) : (!hlscpp.stream) -> () + // CHECK: "hls.stream.read"(%arg1) : (!hls.stream) -> () %0 = "tosa.const"() {value = dense<[0, 3, 1, 2]> : tensor<4xi32>} : () -> tensor<4xi32> %1 = "tosa.transpose"(%arg0, %0) : (tensor<1x1x1x64xi8>, tensor<4xi32>) -> tensor<1x64x1x1xi8> %2 = "tosa.const"() {value = dense<1> : tensor<1x64x10xi8>} : () -> tensor<1x64x10xi8> %3 = "tosa.reshape"(%1) {new_shape = [1, 1, 64]} : (tensor<1x64x1x1xi8>) -> tensor<1x1x64xi8> %4 = "tosa.matmul"(%3, %2) {quantization_info = {a_zp = 0 : i32, b_zp = 0 : i32}} : (tensor<1x1x64xi8>, tensor<1x64x10xi8>) -> tensor<1x1x10xi8> - // CHECK: return %4, %5 : tensor<1x1x10xi8>, !hlscpp.stream + // CHECK: return %4, %5 : tensor<1x1x10xi8>, !hls.stream return %4 : tensor<1x1x10xi8> } - // CHECK: func @forward_node6(%arg0: tensor<1x1x10xi8>, %arg1: !hlscpp.stream) -> (tensor<1x10xi8>, !hlscpp.stream) { + // CHECK: func @forward_node6(%arg0: tensor<1x1x10xi8>, %arg1: !hls.stream) -> (tensor<1x10xi8>, !hls.stream) { func @forward_node6(%arg0: tensor<1x1x10xi8>) -> tensor<1x10xi8> { - // CHECK: "hlscpp.stream.read"(%arg1) : (!hlscpp.stream) -> () + // CHECK: "hls.stream.read"(%arg1) : (!hls.stream) -> () %0 = "tosa.const"() {value = dense<0> : tensor<1x10xi8>} : () -> tensor<1x10xi8> %1 = "tosa.reshape"(%arg0) {new_shape = [1, 10]} : (tensor<1x1x10xi8>) -> tensor<1x10xi8> %2 = "tosa.add"(%1, %0) : (tensor<1x10xi8>, tensor<1x10xi8>) -> tensor<1x10xi8> - // CHECK: return %2, %3 : tensor<1x10xi8>, !hlscpp.stream + // CHECK: return %2, %3 : tensor<1x10xi8>, !hls.stream return %2 : tensor<1x10xi8> } // CHECK: func @forward(%arg0: tensor<1x3x32x32xi8>) -> tensor<1x10xi8> { func @forward(%arg0: tensor<1x3x32x32xi8>) -> tensor<1x10xi8> { - // CHECK: %0:2 = call @forward_node0(%arg0) : (tensor<1x3x32x32xi8>) -> (tensor<1x32x32x64xi8>, !hlscpp.stream) + // CHECK: %0:2 = call @forward_node0(%arg0) : (tensor<1x3x32x32xi8>) -> (tensor<1x32x32x64xi8>, !hls.stream) %0 = call @forward_node0(%arg0) : (tensor<1x3x32x32xi8>) -> tensor<1x32x32x64xi8> - // CHECK: %1:2 = call @forward_node1(%0#0, %0#1) : (tensor<1x32x32x64xi8>, !hlscpp.stream) -> (tensor<1x32x32x64xi8>, !hlscpp.stream) + // CHECK: %1:2 = call @forward_node1(%0#0, %0#1) : (tensor<1x32x32x64xi8>, !hls.stream) -> (tensor<1x32x32x64xi8>, !hls.stream) %1 = call @forward_node1(%0) : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> - // CHECK: %2:2 = call @forward_node2(%1#0, %1#1) : (tensor<1x32x32x64xi8>, !hlscpp.stream) -> (tensor<1x32x32x64xi8>, !hlscpp.stream) + // CHECK: %2:2 = call @forward_node2(%1#0, %1#1) : (tensor<1x32x32x64xi8>, !hls.stream) -> (tensor<1x32x32x64xi8>, !hls.stream) %2 = call @forward_node2(%1) : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> - // CHECK: %3:2 = call @forward_node3(%2#0, %0#0, %0#1, %2#1) : (tensor<1x32x32x64xi8>, tensor<1x32x32x64xi8>, !hlscpp.stream, !hlscpp.stream) -> (tensor<1x32x32x64xi8>, !hlscpp.stream) + // CHECK: %3:2 = call @forward_node3(%2#0, %0#0, %0#1, %2#1) : (tensor<1x32x32x64xi8>, tensor<1x32x32x64xi8>, !hls.stream, !hls.stream) -> (tensor<1x32x32x64xi8>, !hls.stream) %3 = call @forward_node3(%2, %0) : (tensor<1x32x32x64xi8>, tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> - // CHECK: %4:2 = call @forward_node4(%3#0, %3#1) : (tensor<1x32x32x64xi8>, !hlscpp.stream) -> (tensor<1x1x1x64xi8>, !hlscpp.stream) + // CHECK: %4:2 = call @forward_node4(%3#0, %3#1) : (tensor<1x32x32x64xi8>, !hls.stream) -> (tensor<1x1x1x64xi8>, !hls.stream) %4 = call @forward_node4(%3) : (tensor<1x32x32x64xi8>) -> tensor<1x1x1x64xi8> - // CHECK: %5:2 = call @forward_node5(%4#0, %4#1) : (tensor<1x1x1x64xi8>, !hlscpp.stream) -> (tensor<1x1x10xi8>, !hlscpp.stream) + // CHECK: %5:2 = call @forward_node5(%4#0, %4#1) : (tensor<1x1x1x64xi8>, !hls.stream) -> (tensor<1x1x10xi8>, !hls.stream) %5 = call @forward_node5(%4) : (tensor<1x1x1x64xi8>) -> tensor<1x1x10xi8> - // CHECK: %6:2 = call @forward_node6(%5#0, %5#1) : (tensor<1x1x10xi8>, !hlscpp.stream) -> (tensor<1x10xi8>, !hlscpp.stream) + // CHECK: %6:2 = call @forward_node6(%5#0, %5#1) : (tensor<1x1x10xi8>, !hls.stream) -> (tensor<1x10xi8>, !hls.stream) %6 = call @forward_node6(%5) : (tensor<1x1x10xi8>) -> tensor<1x10xi8> // CHECK: return %6#0 : tensor<1x10xi8> diff --git a/test/Transforms/Graph/func-dataflow.mlir b/test/Transforms/Graph/func-dataflow.mlir index 0ebfd03..c91cbe1 100644 --- a/test/Transforms/Graph/func-dataflow.mlir +++ b/test/Transforms/Graph/func-dataflow.mlir @@ -1,44 +1,44 @@ // RUN: scalehls-opt -scalehls-func-dataflow="gran=3 target-func=forward" -split-input-file %s | FileCheck %s module { - // CHECK: func @forward_dataflow2(%arg0: tensor<1x32x32x64xi8>) -> tensor<1x1x64xi8> attributes {func_directive = #hlscpp.fd} { + // CHECK: func @forward_dataflow2(%arg0: tensor<1x32x32x64xi8>) -> tensor<1x1x64xi8> attributes {func_directive = #hls.fd} { // CHECK: %1 = "tosa.avg_pool2d" // CHECK: %2 = "tosa.transpose" // CHECK: %3 = "tosa.reshape" // CHECK: return %3 : tensor<1x1x64xi8> // CHECK: } - // CHECK: func @forward_dataflow4(%arg0: tensor<1x32x32x64xi8>) -> (tensor<1x32x32x64xi8>, tensor<1x32x32x64xi8>) attributes {func_directive = #hlscpp.fd} { + // CHECK: func @forward_dataflow4(%arg0: tensor<1x32x32x64xi8>) -> (tensor<1x32x32x64xi8>, tensor<1x32x32x64xi8>) attributes {func_directive = #hls.fd} { // CHECK: %2 = "tosa.clamp" // CHECK: %3 = "tosa.conv2d" // CHECK: %4 = "tosa.clamp" - // CHECK: %5 = "hlscpp.buffer" - // CHECK: %6 = "hlscpp.buffer" + // CHECK: %5 = "hls.buffer" + // CHECK: %6 = "hls.buffer" // CHECK: return %4, %6 // CHECK: } - // CHECK: func @forward_dataflow1(%arg0: tensor<1x1x64xi8>) -> tensor<1x10xi8> attributes {func_directive = #hlscpp.fd} { + // CHECK: func @forward_dataflow1(%arg0: tensor<1x1x64xi8>) -> tensor<1x10xi8> attributes {func_directive = #hls.fd} { // CHECK: %2 = "tosa.matmul" // CHECK: %3 = "tosa.reshape" // CHECK: %4 = "tosa.add" // CHECK: return %4 // CHECK: } - // CHECK: func @forward_dataflow3(%arg0: tensor<1x32x32x64xi8>, %arg1: tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> attributes {func_directive = #hlscpp.fd} { + // CHECK: func @forward_dataflow3(%arg0: tensor<1x32x32x64xi8>, %arg1: tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> attributes {func_directive = #hls.fd} { // CHECK: %2 = "tosa.conv2d" - // CHECK: %3 = "hlscpp.buffer" + // CHECK: %3 = "hls.buffer" // CHECK: %4 = "tosa.add" // CHECK: %5 = "tosa.clamp" // CHECK: return %5 // CHECK: } - // CHECK: func @forward_dataflow5(%arg0: tensor<1x3x32x32xi8>) -> tensor<1x32x32x64xi8> attributes {func_directive = #hlscpp.fd} { + // CHECK: func @forward_dataflow5(%arg0: tensor<1x3x32x32xi8>) -> tensor<1x32x32x64xi8> attributes {func_directive = #hls.fd} { // CHECK: %3 = "tosa.transpose" // CHECK: %4 = "tosa.conv2d" // CHECK: return %4 // CHECK: } - // CHECK: func @forward(%arg0: tensor<1x3x32x32xi8>) -> tensor<1x10xi8> attributes {func_directive = #hlscpp.fd} { + // CHECK: func @forward(%arg0: tensor<1x3x32x32xi8>) -> tensor<1x10xi8> attributes {func_directive = #hls.fd} { func @forward(%arg0: tensor<1x3x32x32xi8>) -> tensor<1x10xi8> { // CHECK-NOT: %0 = "tosa.const"() {value = dense<0> : tensor<1x10xi8>} : () -> tensor<1x10xi8> // CHECK-NOT: %1 = "tosa.const"() {value = dense<1> : tensor<1x64x10xi8>} : () -> tensor<1x64x10xi8> @@ -90,80 +90,80 @@ module { // RUN: scalehls-opt -scalehls-func-dataflow="target-func=forward" -split-input-file %s | FileCheck %s --check-prefix=CALL module { - func private @forward_node0(%arg0: memref<1x3x32x32xi8>, %arg1: memref<3x3x3x64xi8>, %arg2: memref<1x32x32x64xi8>) -> !hlscpp.stream - func private @forward_node1(%arg0: memref<1x32x32x64xi8>, %arg1: !hlscpp.stream, %arg2: memref<3x3x64x64xi8>, %arg3: memref<1x32x32x64xi8>) -> !hlscpp.stream - func private @forward_node2(%arg0: memref<1x32x32x64xi8>, %arg1: !hlscpp.stream, %arg2: memref<3x3x64x64xi8>, %arg3: memref<1x32x32x64xi8>) -> !hlscpp.stream - func private @forward_node3(%arg0: memref<1x32x32x64xi8>, %arg1: memref<1x32x32x64xi8>, %arg2: !hlscpp.stream, %arg3: !hlscpp.stream, %arg4: memref<1x32x32x64xi8>) -> !hlscpp.stream - func private @forward_node4(%arg0: memref<1x32x32x64xi8>, %arg1: !hlscpp.stream, %arg2: memref<1x1x1x64xi8>) -> !hlscpp.stream - func private @forward_node5(%arg0: memref<1x1x1x64xi8>, %arg1: !hlscpp.stream, %arg2: memref<1x64x10xi8>, %arg3: memref<1x1x10xi8>) -> !hlscpp.stream - func private @forward_node6(%arg0: memref<1x1x10xi8>, %arg1: !hlscpp.stream, %arg2: memref<1x10xi8>) -> !hlscpp.stream + func private @forward_node0(%arg0: memref<1x3x32x32xi8>, %arg1: memref<3x3x3x64xi8>, %arg2: memref<1x32x32x64xi8>) -> !hls.stream + func private @forward_node1(%arg0: memref<1x32x32x64xi8>, %arg1: !hls.stream, %arg2: memref<3x3x64x64xi8>, %arg3: memref<1x32x32x64xi8>) -> !hls.stream + func private @forward_node2(%arg0: memref<1x32x32x64xi8>, %arg1: !hls.stream, %arg2: memref<3x3x64x64xi8>, %arg3: memref<1x32x32x64xi8>) -> !hls.stream + func private @forward_node3(%arg0: memref<1x32x32x64xi8>, %arg1: memref<1x32x32x64xi8>, %arg2: !hls.stream, %arg3: !hls.stream, %arg4: memref<1x32x32x64xi8>) -> !hls.stream + func private @forward_node4(%arg0: memref<1x32x32x64xi8>, %arg1: !hls.stream, %arg2: memref<1x1x1x64xi8>) -> !hls.stream + func private @forward_node5(%arg0: memref<1x1x1x64xi8>, %arg1: !hls.stream, %arg2: memref<1x64x10xi8>, %arg3: memref<1x1x10xi8>) -> !hls.stream + func private @forward_node6(%arg0: memref<1x1x10xi8>, %arg1: !hls.stream, %arg2: memref<1x10xi8>) -> !hls.stream - // CALL: func @forward_dataflow7(%arg0: memref<1x3x32x32xi8>, %arg1: memref<3x3x3x64xi8>, %arg2: memref<1x32x32x64xi8>) -> !hlscpp.stream attributes {func_directive = #hlscpp.fd} { - // CALL: %0 = call @forward_node0(%arg0, %arg1, %arg2) : (memref<1x3x32x32xi8>, memref<3x3x3x64xi8>, memref<1x32x32x64xi8>) -> !hlscpp.stream - // CALL: return %0 : !hlscpp.stream + // CALL: func @forward_dataflow7(%arg0: memref<1x3x32x32xi8>, %arg1: memref<3x3x3x64xi8>, %arg2: memref<1x32x32x64xi8>) -> !hls.stream attributes {func_directive = #hls.fd} { + // CALL: %0 = call @forward_node0(%arg0, %arg1, %arg2) : (memref<1x3x32x32xi8>, memref<3x3x3x64xi8>, memref<1x32x32x64xi8>) -> !hls.stream + // CALL: return %0 : !hls.stream // CALL: } - // CALL: func @forward_dataflow2(%arg0: memref<1x1x1x64xi8>, %arg1: !hlscpp.stream, %arg2: memref<1x64x10xi8>, %arg3: memref<1x1x10xi8>) -> !hlscpp.stream attributes {func_directive = #hlscpp.fd} { - // CALL: %0 = call @forward_node5(%arg0, %arg1, %arg2, %arg3) : (memref<1x1x1x64xi8>, !hlscpp.stream, memref<1x64x10xi8>, memref<1x1x10xi8>) -> !hlscpp.stream - // CALL: return %0 : !hlscpp.stream + // CALL: func @forward_dataflow2(%arg0: memref<1x1x1x64xi8>, %arg1: !hls.stream, %arg2: memref<1x64x10xi8>, %arg3: memref<1x1x10xi8>) -> !hls.stream attributes {func_directive = #hls.fd} { + // CALL: %0 = call @forward_node5(%arg0, %arg1, %arg2, %arg3) : (memref<1x1x1x64xi8>, !hls.stream, memref<1x64x10xi8>, memref<1x1x10xi8>) -> !hls.stream + // CALL: return %0 : !hls.stream // CALL: } - // CALL: func @forward_dataflow4(%arg0: memref<1x32x32x64xi8>, %arg1: memref<1x32x32x64xi8>, %arg2: !hlscpp.stream, %arg3: !hlscpp.stream, %arg4: memref<1x32x32x64xi8>) -> !hlscpp.stream attributes {func_directive = #hlscpp.fd} { - // CALL: %0 = call @forward_node3(%arg0, %arg1, %arg2, %arg3, %arg4) : (memref<1x32x32x64xi8>, memref<1x32x32x64xi8>, !hlscpp.stream, !hlscpp.stream, memref<1x32x32x64xi8>) -> !hlscpp.stream - // CALL: return %0 : !hlscpp.stream + // CALL: func @forward_dataflow4(%arg0: memref<1x32x32x64xi8>, %arg1: memref<1x32x32x64xi8>, %arg2: !hls.stream, %arg3: !hls.stream, %arg4: memref<1x32x32x64xi8>) -> !hls.stream attributes {func_directive = #hls.fd} { + // CALL: %0 = call @forward_node3(%arg0, %arg1, %arg2, %arg3, %arg4) : (memref<1x32x32x64xi8>, memref<1x32x32x64xi8>, !hls.stream, !hls.stream, memref<1x32x32x64xi8>) -> !hls.stream + // CALL: return %0 : !hls.stream // CALL: } - // CALL: func @forward_dataflow6(%arg0: memref<1x32x32x64xi8>, %arg1: !hlscpp.stream, %arg2: memref<3x3x64x64xi8>, %arg3: memref<1x32x32x64xi8>) -> (!hlscpp.stream, !hlscpp.stream) attributes {func_directive = #hlscpp.fd} { - // CALL: %0 = call @forward_node1(%arg0, %arg1, %arg2, %arg3) : (memref<1x32x32x64xi8>, !hlscpp.stream, memref<3x3x64x64xi8>, memref<1x32x32x64xi8>) -> !hlscpp.stream - // CALL: %1 = "hlscpp.stream.buffer"(%arg1) : (!hlscpp.stream) -> !hlscpp.stream - // CALL: return %0, %1 : !hlscpp.stream, !hlscpp.stream + // CALL: func @forward_dataflow6(%arg0: memref<1x32x32x64xi8>, %arg1: !hls.stream, %arg2: memref<3x3x64x64xi8>, %arg3: memref<1x32x32x64xi8>) -> (!hls.stream, !hls.stream) attributes {func_directive = #hls.fd} { + // CALL: %0 = call @forward_node1(%arg0, %arg1, %arg2, %arg3) : (memref<1x32x32x64xi8>, !hls.stream, memref<3x3x64x64xi8>, memref<1x32x32x64xi8>) -> !hls.stream + // CALL: %1 = "hls.stream.buffer"(%arg1) : (!hls.stream) -> !hls.stream + // CALL: return %0, %1 : !hls.stream, !hls.stream // CALL: } - // CALL: func @forward_dataflow1(%arg0: memref<1x1x10xi8>, %arg1: !hlscpp.stream, %arg2: memref<1x10xi8>) attributes {func_directive = #hlscpp.fd} { - // CALL: %0 = call @forward_node6(%arg0, %arg1, %arg2) : (memref<1x1x10xi8>, !hlscpp.stream, memref<1x10xi8>) -> !hlscpp.stream + // CALL: func @forward_dataflow1(%arg0: memref<1x1x10xi8>, %arg1: !hls.stream, %arg2: memref<1x10xi8>) attributes {func_directive = #hls.fd} { + // CALL: %0 = call @forward_node6(%arg0, %arg1, %arg2) : (memref<1x1x10xi8>, !hls.stream, memref<1x10xi8>) -> !hls.stream // CALL: return // CALL: } - // CALL: func @forward_dataflow3(%arg0: memref<1x32x32x64xi8>, %arg1: !hlscpp.stream, %arg2: memref<1x1x1x64xi8>) -> !hlscpp.stream attributes {func_directive = #hlscpp.fd} { - // CALL: %0 = call @forward_node4(%arg0, %arg1, %arg2) : (memref<1x32x32x64xi8>, !hlscpp.stream, memref<1x1x1x64xi8>) -> !hlscpp.stream - // CALL: return %0 : !hlscpp.stream + // CALL: func @forward_dataflow3(%arg0: memref<1x32x32x64xi8>, %arg1: !hls.stream, %arg2: memref<1x1x1x64xi8>) -> !hls.stream attributes {func_directive = #hls.fd} { + // CALL: %0 = call @forward_node4(%arg0, %arg1, %arg2) : (memref<1x32x32x64xi8>, !hls.stream, memref<1x1x1x64xi8>) -> !hls.stream + // CALL: return %0 : !hls.stream // CALL: } - // CALL: func @forward_dataflow5(%arg0: memref<1x32x32x64xi8>, %arg1: !hlscpp.stream, %arg2: memref<3x3x64x64xi8>, %arg3: memref<1x32x32x64xi8>, %arg4: !hlscpp.stream) -> (!hlscpp.stream, !hlscpp.stream) attributes {func_directive = #hlscpp.fd} { - // CALL: %0 = call @forward_node2(%arg0, %arg1, %arg2, %arg3) : (memref<1x32x32x64xi8>, !hlscpp.stream, memref<3x3x64x64xi8>, memref<1x32x32x64xi8>) -> !hlscpp.stream - // CALL: %1 = "hlscpp.stream.buffer"(%arg4) : (!hlscpp.stream) -> !hlscpp.stream - // CALL: return %0, %1 : !hlscpp.stream, !hlscpp.stream + // CALL: func @forward_dataflow5(%arg0: memref<1x32x32x64xi8>, %arg1: !hls.stream, %arg2: memref<3x3x64x64xi8>, %arg3: memref<1x32x32x64xi8>, %arg4: !hls.stream) -> (!hls.stream, !hls.stream) attributes {func_directive = #hls.fd} { + // CALL: %0 = call @forward_node2(%arg0, %arg1, %arg2, %arg3) : (memref<1x32x32x64xi8>, !hls.stream, memref<3x3x64x64xi8>, memref<1x32x32x64xi8>) -> !hls.stream + // CALL: %1 = "hls.stream.buffer"(%arg4) : (!hls.stream) -> !hls.stream + // CALL: return %0, %1 : !hls.stream, !hls.stream // CALL: } - // CALL: func @forward(%arg0: memref<1x3x32x32xi8>, %arg1: memref<3x3x3x64xi8>, %arg2: memref<3x3x64x64xi8>, %arg3: memref<3x3x64x64xi8>, %arg4: memref<1x64x10xi8>, %arg5: memref<1x10xi8>) attributes {func_directive = #hlscpp.fd, top_func} { + // CALL: func @forward(%arg0: memref<1x3x32x32xi8>, %arg1: memref<3x3x3x64xi8>, %arg2: memref<3x3x64x64xi8>, %arg3: memref<3x3x64x64xi8>, %arg4: memref<1x64x10xi8>, %arg5: memref<1x10xi8>) attributes {func_directive = #hls.fd, top_func} { func @forward(%arg0: memref<1x3x32x32xi8>, %arg1: memref<3x3x3x64xi8>, %arg2: memref<3x3x64x64xi8>, %arg3: memref<3x3x64x64xi8>, %arg4: memref<1x64x10xi8>, %arg5: memref<1x10xi8>) attributes {top_func} { %0 = memref.alloc() : memref<1x32x32x64xi8> - // CALL: %1 = call @forward_dataflow7(%arg0, %arg1, %0) : (memref<1x3x32x32xi8>, memref<3x3x3x64xi8>, memref<1x32x32x64xi8>) -> !hlscpp.stream - %1 = call @forward_node0(%arg0, %arg1, %0) : (memref<1x3x32x32xi8>, memref<3x3x3x64xi8>, memref<1x32x32x64xi8>) -> !hlscpp.stream + // CALL: %1 = call @forward_dataflow7(%arg0, %arg1, %0) : (memref<1x3x32x32xi8>, memref<3x3x3x64xi8>, memref<1x32x32x64xi8>) -> !hls.stream + %1 = call @forward_node0(%arg0, %arg1, %0) : (memref<1x3x32x32xi8>, memref<3x3x3x64xi8>, memref<1x32x32x64xi8>) -> !hls.stream %2 = memref.alloc() : memref<1x32x32x64xi8> - // CALL: %5:2 = call @forward_dataflow6(%0, %1, %arg2, %2) : (memref<1x32x32x64xi8>, !hlscpp.stream, memref<3x3x64x64xi8>, memref<1x32x32x64xi8>) -> (!hlscpp.stream, !hlscpp.stream) - %3 = call @forward_node1(%0, %1, %arg2, %2) : (memref<1x32x32x64xi8>, !hlscpp.stream, memref<3x3x64x64xi8>, memref<1x32x32x64xi8>) -> !hlscpp.stream + // CALL: %5:2 = call @forward_dataflow6(%0, %1, %arg2, %2) : (memref<1x32x32x64xi8>, !hls.stream, memref<3x3x64x64xi8>, memref<1x32x32x64xi8>) -> (!hls.stream, !hls.stream) + %3 = call @forward_node1(%0, %1, %arg2, %2) : (memref<1x32x32x64xi8>, !hls.stream, memref<3x3x64x64xi8>, memref<1x32x32x64xi8>) -> !hls.stream %4 = memref.alloc() : memref<1x32x32x64xi8> - // CALL: %6:2 = call @forward_dataflow5(%2, %5#0, %arg3, %3, %5#1) : (memref<1x32x32x64xi8>, !hlscpp.stream, memref<3x3x64x64xi8>, memref<1x32x32x64xi8>, !hlscpp.stream) -> (!hlscpp.stream, !hlscpp.stream) - %5 = call @forward_node2(%2, %3, %arg3, %4) : (memref<1x32x32x64xi8>, !hlscpp.stream, memref<3x3x64x64xi8>, memref<1x32x32x64xi8>) -> !hlscpp.stream + // CALL: %6:2 = call @forward_dataflow5(%2, %5#0, %arg3, %3, %5#1) : (memref<1x32x32x64xi8>, !hls.stream, memref<3x3x64x64xi8>, memref<1x32x32x64xi8>, !hls.stream) -> (!hls.stream, !hls.stream) + %5 = call @forward_node2(%2, %3, %arg3, %4) : (memref<1x32x32x64xi8>, !hls.stream, memref<3x3x64x64xi8>, memref<1x32x32x64xi8>) -> !hls.stream %6 = memref.alloc() : memref<1x32x32x64xi8> - // CALL: %7 = call @forward_dataflow4(%3, %0, %6#1, %6#0, %4) : (memref<1x32x32x64xi8>, memref<1x32x32x64xi8>, !hlscpp.stream, !hlscpp.stream, memref<1x32x32x64xi8>) -> !hlscpp.stream - %7 = call @forward_node3(%4, %0, %1, %5, %6) : (memref<1x32x32x64xi8>, memref<1x32x32x64xi8>, !hlscpp.stream, !hlscpp.stream, memref<1x32x32x64xi8>) -> !hlscpp.stream + // CALL: %7 = call @forward_dataflow4(%3, %0, %6#1, %6#0, %4) : (memref<1x32x32x64xi8>, memref<1x32x32x64xi8>, !hls.stream, !hls.stream, memref<1x32x32x64xi8>) -> !hls.stream + %7 = call @forward_node3(%4, %0, %1, %5, %6) : (memref<1x32x32x64xi8>, memref<1x32x32x64xi8>, !hls.stream, !hls.stream, memref<1x32x32x64xi8>) -> !hls.stream %8 = memref.alloc() : memref<1x1x1x64xi8> - // CALL: %9 = call @forward_dataflow3(%4, %7, %8) : (memref<1x32x32x64xi8>, !hlscpp.stream, memref<1x1x1x64xi8>) -> !hlscpp.stream - %9 = call @forward_node4(%6, %7, %8) : (memref<1x32x32x64xi8>, !hlscpp.stream, memref<1x1x1x64xi8>) -> !hlscpp.stream + // CALL: %9 = call @forward_dataflow3(%4, %7, %8) : (memref<1x32x32x64xi8>, !hls.stream, memref<1x1x1x64xi8>) -> !hls.stream + %9 = call @forward_node4(%6, %7, %8) : (memref<1x32x32x64xi8>, !hls.stream, memref<1x1x1x64xi8>) -> !hls.stream %10 = memref.alloc() : memref<1x1x10xi8> - // CALL: %11 = call @forward_dataflow2(%8, %9, %arg4, %10) : (memref<1x1x1x64xi8>, !hlscpp.stream, memref<1x64x10xi8>, memref<1x1x10xi8>) -> !hlscpp.stream - %11 = call @forward_node5(%8, %9, %arg4, %10) : (memref<1x1x1x64xi8>, !hlscpp.stream, memref<1x64x10xi8>, memref<1x1x10xi8>) -> !hlscpp.stream + // CALL: %11 = call @forward_dataflow2(%8, %9, %arg4, %10) : (memref<1x1x1x64xi8>, !hls.stream, memref<1x64x10xi8>, memref<1x1x10xi8>) -> !hls.stream + %11 = call @forward_node5(%8, %9, %arg4, %10) : (memref<1x1x1x64xi8>, !hls.stream, memref<1x64x10xi8>, memref<1x1x10xi8>) -> !hls.stream - // CALL: call @forward_dataflow1(%10, %11, %arg5) : (memref<1x1x10xi8>, !hlscpp.stream, memref<1x10xi8>) -> () - %12 = call @forward_node6(%10, %11, %arg5) : (memref<1x1x10xi8>, !hlscpp.stream, memref<1x10xi8>) -> !hlscpp.stream + // CALL: call @forward_dataflow1(%10, %11, %arg5) : (memref<1x1x10xi8>, !hls.stream, memref<1x10xi8>) -> () + %12 = call @forward_node6(%10, %11, %arg5) : (memref<1x1x10xi8>, !hls.stream, memref<1x10xi8>) -> !hls.stream return } } diff --git a/test/Transforms/Graph/hoist-stream-channel.mlir b/test/Transforms/Graph/hoist-stream-channel.mlir index f6285c0..a99f63c 100644 --- a/test/Transforms/Graph/hoist-stream-channel.mlir +++ b/test/Transforms/Graph/hoist-stream-channel.mlir @@ -1,33 +1,33 @@ // RUN: scalehls-opt -scalehls-hoist-stream-channel %s | FileCheck %s // CHECK: module { -// CHECK: func @forward_dataflow5(%arg0: !hlscpp.stream, %arg1: !hlscpp.stream, %arg2: !hlscpp.stream, %arg3: !hlscpp.stream) { +// CHECK: func @forward_dataflow5(%arg0: !hls.stream, %arg1: !hls.stream, %arg2: !hls.stream, %arg3: !hls.stream) { // CHECK: %false = arith.constant false -// CHECK: "hlscpp.stream.read"(%arg1) : (!hlscpp.stream) -> () -// CHECK: "hlscpp.stream.read"(%arg0) : (!hlscpp.stream) -> () -// CHECK: "hlscpp.stream.write"(%arg2, %false) : (!hlscpp.stream, i1) -> () -// CHECK: "hlscpp.stream.write"(%arg3, %false) : (!hlscpp.stream, i1) -> () +// CHECK: "hls.stream.read"(%arg1) : (!hls.stream) -> () +// CHECK: "hls.stream.read"(%arg0) : (!hls.stream) -> () +// CHECK: "hls.stream.write"(%arg2, %false) : (!hls.stream, i1) -> () +// CHECK: "hls.stream.write"(%arg3, %false) : (!hls.stream, i1) -> () // CHECK: return // CHECK: } -// CHECK: func @forward(%arg0: !hlscpp.stream, %arg1: !hlscpp.stream) { -// CHECK: %0 = "hlscpp.stream.channel"() : () -> !hlscpp.stream -// CHECK: %1 = "hlscpp.stream.channel"() : () -> !hlscpp.stream -// CHECK: call @forward_dataflow5(%arg0, %arg1, %0, %1) : (!hlscpp.stream, !hlscpp.stream, !hlscpp.stream, !hlscpp.stream) -> () +// CHECK: func @forward(%arg0: !hls.stream, %arg1: !hls.stream) { +// CHECK: %0 = "hls.stream.channel"() : () -> !hls.stream +// CHECK: %1 = "hls.stream.channel"() : () -> !hls.stream +// CHECK: call @forward_dataflow5(%arg0, %arg1, %0, %1) : (!hls.stream, !hls.stream, !hls.stream, !hls.stream) -> () // CHECK: return // CHECK: } // CHECK: } module { - func @forward_dataflow5(%arg0: !hlscpp.stream, %arg1: !hlscpp.stream) -> (!hlscpp.stream, !hlscpp.stream) { + func @forward_dataflow5(%arg0: !hls.stream, %arg1: !hls.stream) -> (!hls.stream, !hls.stream) { %false = arith.constant false - "hlscpp.stream.read"(%arg0) : (!hlscpp.stream) -> () - %0 = "hlscpp.stream.channel"() : () -> !hlscpp.stream - "hlscpp.stream.write"(%0, %false) : (!hlscpp.stream, i1) -> () - %1 = "hlscpp.stream.buffer"(%arg1) : (!hlscpp.stream) -> !hlscpp.stream - return %0, %1 : !hlscpp.stream, !hlscpp.stream + "hls.stream.read"(%arg0) : (!hls.stream) -> () + %0 = "hls.stream.channel"() : () -> !hls.stream + "hls.stream.write"(%0, %false) : (!hls.stream, i1) -> () + %1 = "hls.stream.buffer"(%arg1) : (!hls.stream) -> !hls.stream + return %0, %1 : !hls.stream, !hls.stream } - func @forward(%arg0: !hlscpp.stream, %arg1: !hlscpp.stream) { - %0:2 = call @forward_dataflow5(%arg0, %arg1) : (!hlscpp.stream, !hlscpp.stream) -> (!hlscpp.stream, !hlscpp.stream) + func @forward(%arg0: !hls.stream, %arg1: !hls.stream) { + %0:2 = call @forward_dataflow5(%arg0, %arg1) : (!hls.stream, !hls.stream) -> (!hls.stream, !hls.stream) return } } diff --git a/test/Transforms/Loop/affine-loop-dataflow.mlir b/test/Transforms/Loop/affine-loop-dataflow.mlir index 4356e2e..8629e33 100644 --- a/test/Transforms/Loop/affine-loop-dataflow.mlir +++ b/test/Transforms/Loop/affine-loop-dataflow.mlir @@ -8,15 +8,15 @@ #set0 = affine_set<(d0, d1, d2) : (d0 == 0, d1 == 0, d2 == 0)> #set1 = affine_set<(d0, d1, d2) : (-d0 + 2 == 0, -d1 + 2 == 0, -d2 + 63 == 0)> module { - // CHECK: func @forward_dataflow6(%arg0: memref<1x32x32x64xi8, 3>, %arg1: !hlscpp.stream, %arg2: memref<3x3x64x64xi8, 3>, %arg3: memref<1x32x32x64xi8, 3>, %arg4: !hlscpp.stream, %arg5: !hlscpp.stream) attributes {func_directive = #hlscpp.fd} { - func @forward_dataflow6(%arg0: memref<1x32x32x64xi8, 3>, %arg1: !hlscpp.stream, %arg2: memref<3x3x64x64xi8, 3>, %arg3: memref<1x32x32x64xi8, 3>, %arg4: !hlscpp.stream, %arg5: !hlscpp.stream) attributes {func_directive = #hlscpp.fd} { + // CHECK: func @forward_dataflow6(%arg0: memref<1x32x32x64xi8, 3>, %arg1: !hls.stream, %arg2: memref<3x3x64x64xi8, 3>, %arg3: memref<1x32x32x64xi8, 3>, %arg4: !hls.stream, %arg5: !hls.stream) attributes {func_directive = #hls.fd} { + func @forward_dataflow6(%arg0: memref<1x32x32x64xi8, 3>, %arg1: !hls.stream, %arg2: memref<3x3x64x64xi8, 3>, %arg3: memref<1x32x32x64xi8, 3>, %arg4: !hls.stream, %arg5: !hls.stream) attributes {func_directive = #hls.fd} { %c127_i8 = arith.constant 127 : i8 %cst = arith.constant dense<5> : tensor<64xi8> %c0_i8 = arith.constant 0 : i8 %false = arith.constant false %0 = memref.alloc() : memref<1x1x1x1xi8> %1 = bufferization.to_memref %cst : memref<64xi8> - "hlscpp.stream.read"(%arg1) : (!hlscpp.stream) -> () + "hls.stream.read"(%arg1) : (!hls.stream) -> () %2 = memref.alloc() : memref<1x4x4x4xi8> %3 = memref.alloc() : memref<1x1x4x4xi8> %4 = memref.alloc() : memref<1x4x4x4xi8> @@ -30,7 +30,7 @@ module { // CHECK: call @loop0_dataflow3 // CHECK: call @loop0_dataflow2 // CHECK: call @loop0_dataflow1 - // CHECK: } {loop_directive = #hlscpp.ld} + // CHECK: } {loop_directive = #hls.ld} affine.for %arg11 = 0 to 16 { affine.for %arg12 = 0 to 4 { affine.for %arg13 = 0 to 4 { @@ -87,8 +87,8 @@ module { } } } - "hlscpp.stream.write"(%arg4, %false) : (!hlscpp.stream, i1) -> () - "hlscpp.stream.write"(%arg5, %false) : (!hlscpp.stream, i1) -> () + "hls.stream.write"(%arg4, %false) : (!hls.stream, i1) -> () + "hls.stream.write"(%arg5, %false) : (!hls.stream, i1) -> () return } } diff --git a/test/Transforms/Loop/affine-loop-tile.mlir b/test/Transforms/Loop/affine-loop-tile.mlir index 55661d9..71b5ca5 100644 --- a/test/Transforms/Loop/affine-loop-tile.mlir +++ b/test/Transforms/Loop/affine-loop-tile.mlir @@ -9,14 +9,14 @@ #set0 = affine_set<(d0, d1, d2) : (d0 == 0, d1 == 0, d2 == 0)> #set1 = affine_set<(d0, d1, d2) : (-d0 + 2 == 0, -d1 + 2 == 0, -d2 + 63 == 0)> module { - func @forward_dataflow6(%arg0: memref<1x32x32x64xi8, 3>, %arg1: !hlscpp.stream, %arg2: memref<3x3x64x64xi8, 3>, %arg3: memref<1x32x32x64xi8, 3>, %arg4: !hlscpp.stream, %arg5: !hlscpp.stream) attributes {func_directive = #hlscpp.fd} { + func @forward_dataflow6(%arg0: memref<1x32x32x64xi8, 3>, %arg1: !hls.stream, %arg2: memref<3x3x64x64xi8, 3>, %arg3: memref<1x32x32x64xi8, 3>, %arg4: !hls.stream, %arg5: !hls.stream) attributes {func_directive = #hls.fd} { %false = arith.constant false %c0_i8 = arith.constant 0 : i8 %cst = arith.constant dense<5> : tensor<64xi8> %c127_i8 = arith.constant 127 : i8 %0 = memref.alloc() : memref<1x1x1x1xi8> %1 = bufferization.to_memref %cst : memref<64xi8> - "hlscpp.stream.read"(%arg1) : (!hlscpp.stream) -> () + "hls.stream.read"(%arg1) : (!hls.stream) -> () // CHECK: affine.for %arg6 = 0 to 32 step 4 { // CHECK: affine.for %arg7 = 0 to 32 step 4 { @@ -67,8 +67,8 @@ module { } } } - "hlscpp.stream.write"(%arg4, %false) : (!hlscpp.stream, i1) -> () - "hlscpp.stream.write"(%arg5, %false) : (!hlscpp.stream, i1) -> () + "hls.stream.write"(%arg4, %false) : (!hls.stream, i1) -> () + "hls.stream.write"(%arg5, %false) : (!hls.stream, i1) -> () return } } diff --git a/test/Transforms/Loop/convert-copy-to-affine-loops.mlir b/test/Transforms/Loop/convert-copy-to-affine-loops.mlir index e9e97da..9752e3b 100644 --- a/test/Transforms/Loop/convert-copy-to-affine-loops.mlir +++ b/test/Transforms/Loop/convert-copy-to-affine-loops.mlir @@ -28,11 +28,11 @@ module { } // CHECK-NOT: %[[VAL2:.*]] = bufferization.to_tensor %[[VAL0:.*]] : memref<1x32x32x64xi8> - // CHECK-NOT: %[[VAL3:.*]] = "hlscpp.buffer"(%[[VAL2:.*]]) : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> + // CHECK-NOT: %[[VAL3:.*]] = "hls.buffer"(%[[VAL2:.*]]) : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> // CHECK-NOT: %[[VAL4:.*]] = bufferization.to_memref %[[VAL3:.*]] : memref<1x32x32x64xi8> // CHECK-NOT: memref.copy %[[VAL4:.*]], %arg1 : memref<1x32x32x64xi8> to memref<1x32x32x64xi8> %2 = bufferization.to_tensor %1 : memref<1x32x32x64xi8> - %10 = "hlscpp.buffer"(%2) : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> + %10 = "hls.buffer"(%2) : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> %11 = bufferization.to_memref %10 : memref<1x32x32x64xi8> memref.copy %11, %arg1 : memref<1x32x32x64xi8> to memref<1x32x32x64xi8> return diff --git a/test/Transforms/Loop/func-preprocess.mlir b/test/Transforms/Loop/func-preprocess.mlir index e11f39a..26deedc 100644 --- a/test/Transforms/Loop/func-preprocess.mlir +++ b/test/Transforms/Loop/func-preprocess.mlir @@ -53,9 +53,9 @@ func @test_buffer(%arg0: f32, %arg1: memref<16xf32, 1>) -> (f32, memref<16xf32, %cst = arith.constant dense<[[11, 0], [0, -42]]> : tensor<2x2xi32> %cst_memref = bufferization.to_memref %cst : memref<2x2xi32, 1> - // CHECK: %1 = "hlscpp.buffer"(%arg0) : (f32) -> f32 - // CHECK: %2 = "hlscpp.buffer"(%arg1) : (memref<16xf32, 1>) -> memref<16xf32, 1> - // CHECK: %3 = "hlscpp.buffer"(%c11_i32) : (i32) -> i32 + // CHECK: %1 = "hls.buffer"(%arg0) : (f32) -> f32 + // CHECK: %2 = "hls.buffer"(%arg1) : (memref<16xf32, 1>) -> memref<16xf32, 1> + // CHECK: %3 = "hls.buffer"(%c11_i32) : (i32) -> i32 // CHECK: return %1, %2, %3, %0 : f32, memref<16xf32, 1>, i32, memref<2x2xi32, 1> return %arg0, %arg1, %c11_i32, %cst_memref : f32, memref<16xf32, 1>, i32, memref<2x2xi32, 1> } diff --git a/test/Transforms/Loop/simplify-affine-if.mlir b/test/Transforms/Loop/simplify-affine-if.mlir index 439ad51..08dc365 100644 --- a/test/Transforms/Loop/simplify-affine-if.mlir +++ b/test/Transforms/Loop/simplify-affine-if.mlir @@ -4,7 +4,7 @@ #set0 = affine_set<(d0, d1) : (d0 - d1 >= 0)> #set1 = affine_set<(d0) : (d0 == 0)> module { - func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, 1>, %arg3: memref<16x16xf32, 1>) attributes {func_directive = #hlscpp.fd, top_func} { + func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, 1>, %arg3: memref<16x16xf32, 1>) attributes {func_directive = #hls.fd, top_func} { affine.for %arg4 = 0 to 16 step 2 { affine.for %arg5 = 0 to 16 { affine.for %arg6 = 0 to 16 { @@ -46,9 +46,9 @@ module { %8 = arith.addf %7, %5 : f32 affine.store %8, %arg3[%arg5, %arg6] : memref<16x16xf32, 1> } - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld} return } } diff --git a/test/Transforms/Memory/affine-store-forward.mlir b/test/Transforms/Memory/affine-store-forward.mlir index 9ec9283..cc16036 100644 --- a/test/Transforms/Memory/affine-store-forward.mlir +++ b/test/Transforms/Memory/affine-store-forward.mlir @@ -4,7 +4,7 @@ #set0 = affine_set<(d0, d1) : (d0 - d1 >= 0)> #set1 = affine_set<(d0) : (d0 == 0)> module { - func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, 1>, %arg3: memref<16x16xf32, 1>) attributes {func_directive = #hlscpp.fd, top_func} { + func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, 1>, %arg3: memref<16x16xf32, 1>) attributes {func_directive = #hls.fd, top_func} { affine.for %arg4 = 0 to 16 step 2 { affine.for %arg5 = 0 to 16 { affine.for %arg6 = 0 to 16 { @@ -43,9 +43,9 @@ module { %16 = arith.addf %15, %13 : f32 affine.store %16, %arg3[%arg5, %arg6] : memref<16x16xf32, 1> } - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld} return } } diff --git a/test/Transforms/Memory/create-memref-subview.mlir b/test/Transforms/Memory/create-memref-subview.mlir index 2e824a8..d25527b 100644 --- a/test/Transforms/Memory/create-memref-subview.mlir +++ b/test/Transforms/Memory/create-memref-subview.mlir @@ -13,14 +13,14 @@ #set0 = affine_set<(d0, d1, d2) : (d0 == 0, d1 == 0, d2 == 0)> #set1 = affine_set<(d0, d1, d2) : (-d0 + 2 == 0, -d1 + 2 == 0, -d2 + 63 == 0)> module { - func @forward_dataflow6(%arg0: memref<1x32x32x64xi8, 3>, %arg1: !hlscpp.stream, %arg2: memref<3x3x64x64xi8, 3>, %arg3: memref<1x32x32x64xi8, 3>, %arg4: !hlscpp.stream, %arg5: !hlscpp.stream) attributes {func_directive = #hlscpp.fd} { + func @forward_dataflow6(%arg0: memref<1x32x32x64xi8, 3>, %arg1: !hls.stream, %arg2: memref<3x3x64x64xi8, 3>, %arg3: memref<1x32x32x64xi8, 3>, %arg4: !hls.stream, %arg5: !hls.stream) attributes {func_directive = #hls.fd} { %c127_i8 = arith.constant 127 : i8 %cst = arith.constant dense<5> : tensor<64xi8> %c0_i8 = arith.constant 0 : i8 %false = arith.constant false %0 = memref.alloc() : memref<1x1x1x1xi8> %1 = bufferization.to_memref %cst : memref<64xi8> - "hlscpp.stream.read"(%arg1) : (!hlscpp.stream) -> () + "hls.stream.read"(%arg1) : (!hls.stream) -> () affine.for %arg6 = 0 to 8 { affine.for %arg7 = 0 to 8 { affine.for %arg8 = 0 to 16 { @@ -82,8 +82,8 @@ module { } } } - "hlscpp.stream.write"(%arg4, %false) : (!hlscpp.stream, i1) -> () - "hlscpp.stream.write"(%arg5, %false) : (!hlscpp.stream, i1) -> () + "hls.stream.write"(%arg4, %false) : (!hls.stream, i1) -> () + "hls.stream.write"(%arg5, %false) : (!hls.stream, i1) -> () return } } diff --git a/test/Transforms/Memory/promote-buffer.mlir b/test/Transforms/Memory/promote-buffer.mlir index 17ebd47..0f47c09 100644 --- a/test/Transforms/Memory/promote-buffer.mlir +++ b/test/Transforms/Memory/promote-buffer.mlir @@ -8,14 +8,14 @@ #set0 = affine_set<(d0, d1, d2) : (d0 == 0, d1 == 0, d2 == 0)> #set1 = affine_set<(d0, d1, d2) : (-d0 + 2 == 0, -d1 + 2 == 0, -d2 + 63 == 0)> module { - func @forward_dataflow6(%arg0: memref<1x32x32x64xi8, 3>, %arg1: !hlscpp.stream, %arg2: memref<3x3x64x64xi8, 3>, %arg3: memref<1x32x32x64xi8, 3>, %arg4: !hlscpp.stream, %arg5: !hlscpp.stream) attributes {func_directive = #hlscpp.fd} { + func @forward_dataflow6(%arg0: memref<1x32x32x64xi8, 3>, %arg1: !hls.stream, %arg2: memref<3x3x64x64xi8, 3>, %arg3: memref<1x32x32x64xi8, 3>, %arg4: !hls.stream, %arg5: !hls.stream) attributes {func_directive = #hls.fd} { %false = arith.constant false %c0_i8 = arith.constant 0 : i8 %cst = arith.constant dense<5> : tensor<64xi8> %c127_i8 = arith.constant 127 : i8 %0 = memref.alloc() : memref<1x1x1x1xi8> %1 = bufferization.to_memref %cst : memref<64xi8> - "hlscpp.stream.read"(%arg1) : (!hlscpp.stream) -> () + "hls.stream.read"(%arg1) : (!hls.stream) -> () affine.for %arg6 = 0 to 8 { affine.for %arg7 = 0 to 8 { affine.for %arg8 = 0 to 16 { @@ -74,8 +74,8 @@ module { } } } - "hlscpp.stream.write"(%arg4, %false) : (!hlscpp.stream, i1) -> () - "hlscpp.stream.write"(%arg5, %false) : (!hlscpp.stream, i1) -> () + "hls.stream.write"(%arg4, %false) : (!hls.stream, i1) -> () + "hls.stream.write"(%arg5, %false) : (!hls.stream, i1) -> () return } } diff --git a/test/Transforms/Memory/simplify-memref-access.mlir b/test/Transforms/Memory/simplify-memref-access.mlir index 1023535..418c7af 100644 --- a/test/Transforms/Memory/simplify-memref-access.mlir +++ b/test/Transforms/Memory/simplify-memref-access.mlir @@ -4,7 +4,7 @@ #set0 = affine_set<(d0, d1) : (d0 - d1 >= 0)> #set1 = affine_set<(d0) : (d0 == 0)> module { - func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, 1>, %arg3: memref<16x16xf32, 1>) attributes {func_directive = #hlscpp.fd, top_func} { + func @test_syrk(%arg0: f32, %arg1: f32, %arg2: memref<16x16xf32, 1>, %arg3: memref<16x16xf32, 1>) attributes {func_directive = #hls.fd, top_func} { affine.for %arg4 = 0 to 16 step 2 { affine.for %arg5 = 0 to 16 { affine.for %arg6 = 0 to 16 { @@ -43,9 +43,9 @@ module { // CHECK: affine.store %[[VAL_15:.*]], %arg3[%arg5, %arg6] : memref<16x16xf32, 1> affine.store %15, %arg3[%arg5, %arg6] : memref<16x16xf32, 1> } - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld, parallel} - } {loop_directive = #hlscpp.ld} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld, parallel} + } {loop_directive = #hls.ld} return } } diff --git a/test/Transforms/Runtime/create-axi-interface.mlir b/test/Transforms/Runtime/create-axi-interface.mlir index 5ebba39..1aa367b 100644 --- a/test/Transforms/Runtime/create-axi-interface.mlir +++ b/test/Transforms/Runtime/create-axi-interface.mlir @@ -1,11 +1,11 @@ // RUN: scalehls-opt -scalehls-create-axi-interface %s | FileCheck %s module { - // CHECK: func @forward_dataflow2(%arg0: memref<1x1x1x64xi8, 3>, %arg1: !hlscpp.stream, %arg2: memref<1x64x10xi8, 3>, %arg3: memref<1x1x10xi8, 3>, %arg4: !hlscpp.stream) { - func @forward_dataflow2(%arg0: memref<1x1x1x64xi8>, %arg1: !hlscpp.stream, %arg2: memref<1x64x10xi8>, %arg3: memref<1x1x10xi8>, %arg4: !hlscpp.stream) { + // CHECK: func @forward_dataflow2(%arg0: memref<1x1x1x64xi8, 3>, %arg1: !hls.stream, %arg2: memref<1x64x10xi8, 3>, %arg3: memref<1x1x10xi8, 3>, %arg4: !hls.stream) { + func @forward_dataflow2(%arg0: memref<1x1x1x64xi8>, %arg1: !hls.stream, %arg2: memref<1x64x10xi8>, %arg3: memref<1x1x10xi8>, %arg4: !hls.stream) { %false = arith.constant false %c0_i8 = arith.constant 0 : i8 - "hlscpp.stream.read"(%arg1) : (!hlscpp.stream) -> () + "hls.stream.read"(%arg1) : (!hls.stream) -> () affine.for %arg5 = 0 to 10 { affine.store %c0_i8, %arg3[0, 0, %arg5] : memref<1x1x10xi8> affine.for %arg6 = 0 to 64 { @@ -17,12 +17,12 @@ module { affine.store %4, %arg3[0, 0, %arg5] : memref<1x1x10xi8> } } - "hlscpp.stream.write"(%arg4, %false) : (!hlscpp.stream, i1) -> () + "hls.stream.write"(%arg4, %false) : (!hls.stream, i1) -> () return } - // CHECK: func @forward_dataflow3(%arg0: memref<1x32x32x64xi8, 3>, %arg1: !hlscpp.stream, %arg2: memref<1x1x1x64xi8, 3>, %arg3: !hlscpp.stream) { - func @forward_dataflow3(%arg0: memref<1x32x32x64xi8>, %arg1: !hlscpp.stream, %arg2: memref<1x1x1x64xi8>, %arg3: !hlscpp.stream) { + // CHECK: func @forward_dataflow3(%arg0: memref<1x32x32x64xi8, 3>, %arg1: !hls.stream, %arg2: memref<1x1x1x64xi8, 3>, %arg3: !hls.stream) { + func @forward_dataflow3(%arg0: memref<1x32x32x64xi8>, %arg1: !hls.stream, %arg2: memref<1x1x1x64xi8>, %arg3: !hls.stream) { %false = arith.constant false %c127_i32 = arith.constant 127 : i32 %c-128_i32 = arith.constant -128 : i32 @@ -31,7 +31,7 @@ module { %c1048576_i64 = arith.constant 1048576 : i64 %c30_i64 = arith.constant 30 : i64 %0 = memref.alloc() : memref<1x1x1x1xi32> - "hlscpp.stream.read"(%arg1) : (!hlscpp.stream) -> () + "hls.stream.read"(%arg1) : (!hls.stream) -> () affine.for %arg4 = 0 to 64 { affine.store %c0_i32, %0[0, 0, 0, 0] : memref<1x1x1x1xi32> affine.for %arg5 = 0 to 32 { @@ -56,27 +56,27 @@ module { %11 = arith.trunci %10 : i32 to i8 affine.store %11, %arg2[0, 0, 0, %arg4] : memref<1x1x1x64xi8> } - "hlscpp.stream.write"(%arg3, %false) : (!hlscpp.stream, i1) -> () + "hls.stream.write"(%arg3, %false) : (!hls.stream, i1) -> () return } // CHECK: func @forward(%arg0: memref<1x32x32x64xi8, 3>, %arg1: memref<1x64x10xi8, 3>, %arg2: memref<1x1x1x64xi8, 3>, %arg3: memref<1x1x10xi8, 3>) attributes {top_func} { func @forward(%arg0: memref<1x32x32x64xi8>, %arg4: memref<1x64x10xi8>) attributes {top_func} { - %9 = "hlscpp.stream.channel"() : () -> !hlscpp.stream + %9 = "hls.stream.channel"() : () -> !hls.stream // CHECK-NOT: memref.alloc() : memref<1x1x1x64xi8> %10 = memref.alloc() : memref<1x1x1x64xi8> - %11 = "hlscpp.stream.channel"() : () -> !hlscpp.stream + %11 = "hls.stream.channel"() : () -> !hls.stream - // CHECK: call @forward_dataflow3(%arg0, %0, %arg2, %1) : (memref<1x32x32x64xi8, 3>, !hlscpp.stream, memref<1x1x1x64xi8, 3>, !hlscpp.stream) -> () - call @forward_dataflow3(%arg0, %9, %10, %11) : (memref<1x32x32x64xi8>, !hlscpp.stream, memref<1x1x1x64xi8>, !hlscpp.stream) -> () + // CHECK: call @forward_dataflow3(%arg0, %0, %arg2, %1) : (memref<1x32x32x64xi8, 3>, !hls.stream, memref<1x1x1x64xi8, 3>, !hls.stream) -> () + call @forward_dataflow3(%arg0, %9, %10, %11) : (memref<1x32x32x64xi8>, !hls.stream, memref<1x1x1x64xi8>, !hls.stream) -> () // CHECK-NOT: memref.alloc() : memref<1x1x10xi8> %12 = memref.alloc() : memref<1x1x10xi8> - %13 = "hlscpp.stream.channel"() : () -> !hlscpp.stream + %13 = "hls.stream.channel"() : () -> !hls.stream - // CHECK: call @forward_dataflow2(%arg2, %1, %arg1, %arg3, %2) : (memref<1x1x1x64xi8, 3>, !hlscpp.stream, memref<1x64x10xi8, 3>, memref<1x1x10xi8, 3>, !hlscpp.stream) -> () - call @forward_dataflow2(%10, %11, %arg4, %12, %13) : (memref<1x1x1x64xi8>, !hlscpp.stream, memref<1x64x10xi8>, memref<1x1x10xi8>, !hlscpp.stream) -> () + // CHECK: call @forward_dataflow2(%arg2, %1, %arg1, %arg3, %2) : (memref<1x1x1x64xi8, 3>, !hls.stream, memref<1x64x10xi8, 3>, memref<1x1x10xi8, 3>, !hls.stream) -> () + call @forward_dataflow2(%10, %11, %arg4, %12, %13) : (memref<1x1x1x64xi8>, !hls.stream, memref<1x64x10xi8>, memref<1x1x10xi8>, !hls.stream) -> () return } diff --git a/test/Transforms/Runtime/create-runtime-main.mlir b/test/Transforms/Runtime/create-runtime-main.mlir index 0b383f5..b1fa580 100644 --- a/test/Transforms/Runtime/create-runtime-main.mlir +++ b/test/Transforms/Runtime/create-runtime-main.mlir @@ -18,7 +18,7 @@ module { %0 = "tosa.clamp"(%arg0) {max_fp = 3.40282347E+38 : f32, max_int = 2147483647 : i64, min_fp = 0.000000e+00 : f32, min_int = 0 : i64} : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> %1 = "tosa.conv2d"(%0, %cst, %cst_0) {dilation = [1, 1], pad = [1, 1, 1, 1], quantization_info = {input_zp = 0 : i32, weight_zp = 0 : i32}, stride = [1, 1]} : (tensor<1x32x32x64xi8>, tensor<64x3x3x64xi8>, tensor<64xi8>) -> tensor<1x32x32x64xi8> %2 = "tosa.clamp"(%1) {max_fp = 3.40282347E+38 : f32, max_int = 2147483647 : i64, min_fp = 0.000000e+00 : f32, min_int = 0 : i64} : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> - %3 = "hlscpp.buffer"(%0) : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> + %3 = "hls.buffer"(%0) : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> return %2, %3 : tensor<1x32x32x64xi8>, tensor<1x32x32x64xi8> } @@ -40,7 +40,7 @@ module { %cst = arith.constant dense<2> : tensor<64x3x3x64xi8> %cst_0 = arith.constant dense<5> : tensor<64xi8> %0 = "tosa.conv2d"(%arg0, %cst, %cst_0) {dilation = [1, 1], pad = [1, 1, 1, 1], quantization_info = {input_zp = 0 : i32, weight_zp = 0 : i32}, stride = [1, 1]} : (tensor<1x32x32x64xi8>, tensor<64x3x3x64xi8>, tensor<64xi8>) -> tensor<1x32x32x64xi8> - %1 = "hlscpp.buffer"(%arg1) : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> + %1 = "hls.buffer"(%arg1) : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> %2 = "tosa.add"(%0, %1) : (tensor<1x32x32x64xi8>, tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> %3 = "tosa.clamp"(%2) {max_fp = 3.40282347E+38 : f32, max_int = 2147483647 : i64, min_fp = 0.000000e+00 : f32, min_int = 0 : i64} : (tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> return %3 : tensor<1x32x32x64xi8> @@ -57,7 +57,7 @@ module { return %1 : tensor<1x32x32x64xi8> } - // CHECK: func @forward(%arg0: tensor<1x3x32x32xi8>, %arg1: tensor<64x3x3x3xi8>, %arg2: tensor<64x3x3x64xi8>, %arg3: tensor<64x3x3x64xi8>, %arg4: tensor<1x64x10xi8>) -> tensor<1x10xi8> attributes {func_directive = #hlscpp.fd, top_func} { + // CHECK: func @forward(%arg0: tensor<1x3x32x32xi8>, %arg1: tensor<64x3x3x3xi8>, %arg2: tensor<64x3x3x64xi8>, %arg3: tensor<64x3x3x64xi8>, %arg4: tensor<1x64x10xi8>) -> tensor<1x10xi8> attributes {func_directive = #hls.fd, top_func} { // CHECK: %0 = call @dataflow5(%arg0, %arg1) : (tensor<1x3x32x32xi8>, tensor<64x3x3x3xi8>) -> tensor<1x32x32x64xi8> // CHECK: %1:2 = call @dataflow4(%0, %arg2) : (tensor<1x32x32x64xi8>, tensor<64x3x3x64xi8>) -> (tensor<1x32x32x64xi8>, tensor<1x32x32x64xi8>) // CHECK: %2 = call @dataflow3(%1#0, %1#1, %arg3) : (tensor<1x32x32x64xi8>, tensor<1x32x32x64xi8>, tensor<64x3x3x64xi8>) -> tensor<1x32x32x64xi8> @@ -65,7 +65,7 @@ module { // CHECK: %4 = call @dataflow1(%3, %arg4) : (tensor<1x1x64xi8>, tensor<1x64x10xi8>) -> tensor<1x10xi8> // CHECK: return %4 : tensor<1x10xi8> // CHECK: } - func @forward(%arg0: tensor<1x3x32x32xi8>) -> tensor<1x10xi8> attributes {func_directive = #hlscpp.fd} { + func @forward(%arg0: tensor<1x3x32x32xi8>) -> tensor<1x10xi8> attributes {func_directive = #hls.fd} { %0 = call @dataflow5(%arg0) : (tensor<1x3x32x32xi8>) -> tensor<1x32x32x64xi8> %1:2 = call @dataflow4(%0) : (tensor<1x32x32x64xi8>) -> (tensor<1x32x32x64xi8>, tensor<1x32x32x64xi8>) %2 = call @dataflow3(%1#0, %1#1) : (tensor<1x32x32x64xi8>, tensor<1x32x32x64xi8>) -> tensor<1x32x32x64xi8> diff --git a/tools/scalehls-opt/CMakeLists.txt b/tools/scalehls-opt/CMakeLists.txt index 0ee9087..4af9c0c 100644 --- a/tools/scalehls-opt/CMakeLists.txt +++ b/tools/scalehls-opt/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_libraries(scalehls-opt ${conversion_libs} MLIROptLib - MLIRHLSCpp + MLIRHLS MLIRScaleHLSSupport MLIRScaleHLSTransforms diff --git a/tools/scalehls-translate/CMakeLists.txt b/tools/scalehls-translate/CMakeLists.txt index 2940dfb..3e7c09d 100644 --- a/tools/scalehls-translate/CMakeLists.txt +++ b/tools/scalehls-translate/CMakeLists.txt @@ -16,7 +16,7 @@ target_link_libraries(scalehls-translate ${dialect_libs} ${translation_libs} - MLIRHLSCpp + MLIRHLS MLIRScaleHLSSupport MLIRScaleHLSEmitHLSCpp )