diff --git a/.gitignore b/.gitignore index 485cccfcf9..1ffba60cbc 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ # Clangd cache .cache + +# Clangd configurations +.clangd \ No newline at end of file diff --git a/docs/PythonEnvironment.md b/docs/PythonEnvironment.md new file mode 100644 index 0000000000..77f431e85c --- /dev/null +++ b/docs/PythonEnvironment.md @@ -0,0 +1,10 @@ +# Python Virtual Environment Setup Guide for Buddy-mlir + +We recommend you to use anaconda3 to create python virtual environment. You should install python packages as buddy-mlir/requirements. + +```bash +$ conda create -n python=3.11 +$ conda activate +$ cd buddy-mlir +$ pip install -r requirements.txt +``` \ No newline at end of file diff --git a/docs/RVVEnviroment.md b/docs/RVVEnvironment.md similarity index 100% rename from docs/RVVEnviroment.md rename to docs/RVVEnvironment.md diff --git a/examples/BuddyGen/.gitignore b/examples/BuddyGen/.gitignore new file mode 100644 index 0000000000..df9389428a --- /dev/null +++ b/examples/BuddyGen/.gitignore @@ -0,0 +1,4 @@ +log.mlir +log.ll +log.s +a.out diff --git a/examples/BuddyGen/GenMemRef.cpp b/examples/BuddyGen/GenMemRef.cpp new file mode 100644 index 0000000000..8ca2526b79 --- /dev/null +++ b/examples/BuddyGen/GenMemRef.cpp @@ -0,0 +1,43 @@ +//===- GenMemRef.cpp ------------------------------------------------------===// +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//===----------------------------------------------------------------------===// + +// $ export LLVM_DIR=$PWD/../../llvm/ +// $ export LLVM_BUILD_DIR=$LLVM_DIR/build +// $ c++ GenMemRef.cpp \ + -I $LLVM_DIR/llvm/include/ -I $LLVM_BUILD_DIR/include/ \ + -I $LLVM_DIR/mlir/include/ -I $LLVM_BUILD_DIR/tools/mlir/include/ \ + -L$LLVM_BUILD_DIR/lib -lMLIRIR -lMLIRParser -lMLIRSupport -lLLVMCore \ + -lLLVMSupport -lncurses -ltinfo -lstdc++ -lLLVMDemangle \ + -o a.out +// $ ./a.out + +#include "mlir/Dialect/MemRef/IR/MemRef.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/MLIRContext.h" + +int main() { + mlir::MLIRContext context; + mlir::OpBuilder builder(&context); + mlir::Type eleType = builder.getF64Type(); + // Target memref type: + // `memref>` + mlir::MemRefType memrefType = mlir::MemRefType::get( + {mlir::ShapedType::kDynamic}, eleType, + mlir::StridedLayoutAttr::get( + &context, /*offset=*/mlir::ShapedType::kDynamic, /*strides=*/{1})); + memrefType.dump(); + return 0; +} diff --git a/examples/BuddyLlama/import-llama2.py b/examples/BuddyLlama/import-llama2.py index fbd12e5bff..2903d6bd81 100644 --- a/examples/BuddyLlama/import-llama2.py +++ b/examples/BuddyLlama/import-llama2.py @@ -1,11 +1,3 @@ -import os -import torch -import torch._dynamo as dynamo -from transformers import LlamaForCausalLM, LlamaTokenizer -from torch._inductor.decomposition import decompositions as inductor_decomp -import numpy - -from buddy.compiler.frontend import DynamoCompiler # ===- import-llama2.py -------------------------------------------------------- # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,6 +17,15 @@ # This is the test of llama2 model. # # ===--------------------------------------------------------------------------- + +import os +import torch +import torch._dynamo as dynamo +from transformers import LlamaForCausalLM, LlamaTokenizer +from torch._inductor.decomposition import decompositions as inductor_decomp +import numpy + +from buddy.compiler.frontend import DynamoCompiler from buddy.compiler.ops import tosa from buddy.compiler.graph import GraphDriver from buddy.compiler.graph.transform import simply_fuse diff --git a/examples/BuddyMobileNetV3/buddy-mobilenetv3-main.cpp b/examples/BuddyMobileNetV3/buddy-mobilenetv3-main.cpp index 68d9d15411..0c5318b37d 100644 --- a/examples/BuddyMobileNetV3/buddy-mobilenetv3-main.cpp +++ b/examples/BuddyMobileNetV3/buddy-mobilenetv3-main.cpp @@ -1,4 +1,4 @@ -//===- MobileNetBenchmark.cpp ---------------------------------------------===// +//===- buddy-mobilenetv3-main.cpp -----------------------------------------===// // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.