Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/buddy-compiler/buddy-mlir i…
Browse files Browse the repository at this point in the history
…nto vector
  • Loading branch information
FloatingcloudKnight committed Aug 28, 2024
2 parents 2dd733f + 952d558 commit 76706e7
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@

# Clangd cache
.cache

# Clangd configurations
.clangd
10 changes: 10 additions & 0 deletions docs/PythonEnvironment.md
Original file line number Diff line number Diff line change
@@ -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 <your virtual environment name> python=3.11
$ conda activate <your virtual environment name>
$ cd buddy-mlir
$ pip install -r requirements.txt
```
File renamed without changes.
4 changes: 4 additions & 0 deletions examples/BuddyGen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
log.mlir
log.ll
log.s
a.out
43 changes: 43 additions & 0 deletions examples/BuddyGen/GenMemRef.cpp
Original file line number Diff line number Diff line change
@@ -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<?xf64, strided<[1], offset: ?>>`
mlir::MemRefType memrefType = mlir::MemRefType::get(
{mlir::ShapedType::kDynamic}, eleType,
mlir::StridedLayoutAttr::get(
&context, /*offset=*/mlir::ShapedType::kDynamic, /*strides=*/{1}));
memrefType.dump();
return 0;
}
17 changes: 9 additions & 8 deletions examples/BuddyLlama/import-llama2.py
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/BuddyMobileNetV3/buddy-mobilenetv3-main.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 76706e7

Please sign in to comment.