From cbbba151e5e71e0a0cec64e6ec84fe5c7d2de893 Mon Sep 17 00:00:00 2001 From: wdjyd <1014108056@qq.com> Date: Wed, 19 Jun 2024 15:43:16 +0800 Subject: [PATCH 1/3] temp --- env.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 env.sh diff --git a/env.sh b/env.sh new file mode 100644 index 000000000..fccbb0291 --- /dev/null +++ b/env.sh @@ -0,0 +1,7 @@ +cd build/ +export BUDDY_MLIR_BUILD_DIR=$PWD +export LLVM_MLIR_BUILD_DIR=$PWD/../llvm/build +export PYTHONPATH=${LLVM_MLIR_BUILD_DIR}/tools/mlir/python_packages/mlir_core:${BUDDY_MLIR_BUILD_DIR}/python_packages:${PYTHONPATH} + +export LENET_EXAMPLE_PATH=${BUDDY_MLIR_BUILD_DIR}/../examples/BuddyLeNet/ +cd ../ \ No newline at end of file From 0858f29501b321372059431672e3026effd5dc02 Mon Sep 17 00:00:00 2001 From: wdjyd <1014108056@qq.com> Date: Wed, 19 Jun 2024 20:21:22 +0800 Subject: [PATCH 2/3] fix/maxpool2d_simplify --- frontend/Python/graph/operation.py | 9 +++++++++ .../graph/transform/useless_op_eliminate.py | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/frontend/Python/graph/operation.py b/frontend/Python/graph/operation.py index 14bfbf275..6b543224e 100644 --- a/frontend/Python/graph/operation.py +++ b/frontend/Python/graph/operation.py @@ -124,10 +124,19 @@ def args(self): @property def kwargs(self): return self._keyword_arguments + + @property + def parents(self): + return self._parents + + @property + def children(self): + return self._children @property def name(self): return self._name + @name.setter def name(self, new_name): self._name = new_name diff --git a/frontend/Python/graph/transform/useless_op_eliminate.py b/frontend/Python/graph/transform/useless_op_eliminate.py index a99dbe02c..2522e1798 100644 --- a/frontend/Python/graph/transform/useless_op_eliminate.py +++ b/frontend/Python/graph/transform/useless_op_eliminate.py @@ -42,13 +42,24 @@ def maxpool2d_simplify(graph: Graph): and getitem_node.args[1] == 0 ): new_node = MaxPool2dOp() - new_node.name = getitem_node.name + new_node.name = node.name.replace("_with_indices", "") for arg in node.args: new_node.add_argument(arg) for parent in node._parents: new_node.add_parent(parent) + parent_node = graph.node_table[parent] + for cindex, child in enumerate(parent_node.children): + if child == node.name: + parent_node.children[cindex] = new_node.name for child in getitem_node._children: new_node.add_children(child) + child_node = graph.node_table[child] + for pindex, parent in enumerate(child_node.parents): + if parent == getitem_node.name: + child_node.parents[pindex] = new_node.name + for aindex, arg in enumerate(child_node.args): + if arg == getitem_node.name: + child_node.args[aindex] = new_node.name new_node.tensor_meta["shape"] = getitem_node.tensor_meta[ "shape" ] @@ -63,4 +74,4 @@ def maxpool2d_simplify(graph: Graph): for j, op in enumerate(graph.body): if op == getitem_node: graph.body[j] = new_node - break + break \ No newline at end of file From f2fd5720a8f636636346eb37e85b9ec04b1915cb Mon Sep 17 00:00:00 2001 From: wdjyd <1014108056@qq.com> Date: Wed, 19 Jun 2024 20:22:42 +0800 Subject: [PATCH 3/3] fix/maxpool2d_simplify --- env.sh | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 env.sh diff --git a/env.sh b/env.sh deleted file mode 100644 index fccbb0291..000000000 --- a/env.sh +++ /dev/null @@ -1,7 +0,0 @@ -cd build/ -export BUDDY_MLIR_BUILD_DIR=$PWD -export LLVM_MLIR_BUILD_DIR=$PWD/../llvm/build -export PYTHONPATH=${LLVM_MLIR_BUILD_DIR}/tools/mlir/python_packages/mlir_core:${BUDDY_MLIR_BUILD_DIR}/python_packages:${PYTHONPATH} - -export LENET_EXAMPLE_PATH=${BUDDY_MLIR_BUILD_DIR}/../examples/BuddyLeNet/ -cd ../ \ No newline at end of file