You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2023/01/05 07:25:53 UTC

[GitHub] [tvm] multiverstack-intellif opened a new pull request, #13702: [TIR][Arith] Add common sub expr analyzer

multiverstack-intellif opened a new pull request, #13702:
URL: https://github.com/apache/tvm/pull/13702

   Add an arith helper interface to analyze common sub expression.
   
   Also modify InsertVectorToSortedSemanticComputations to be aware of the occurrence.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] Hzfengsy commented on a diff in pull request #13702: [TIR][Arith] Add common sub expr analyzer

Posted by GitBox <gi...@apache.org>.
Hzfengsy commented on code in PR #13702:
URL: https://github.com/apache/tvm/pull/13702#discussion_r1063212959


##########
python/tvm/arith/pattern.py:
##########
@@ -58,3 +58,22 @@ def detect_clip_bound(expr, var_list):
         An empty list if the match failed.
     """
     return _ffi_api.DetectClipBound(expr, var_list)
+
+
+def detect_common_subexpr(expr, thresh):

Review Comment:
   ```suggestion
   def detect_common_subexpr(expr: PrimExpr, threshold: int) -> Dict[PrimExpr, int]:
   ```
   



##########
python/tvm/arith/pattern.py:
##########
@@ -58,3 +58,22 @@ def detect_clip_bound(expr, var_list):
         An empty list if the match failed.
     """
     return _ffi_api.DetectClipBound(expr, var_list)
+
+
+def detect_common_subexpr(expr, thresh):
+    """Detect common sub expression which shows up more than a threshold times
+
+    Parameters
+    ----------
+    expr : PrimExpr
+        The expression to be analyzed.
+
+    thresh : int
+        The threshold of repeat times that determines a common sub expression
+
+    Returns
+    -------
+    cse : Dict{PrimExpr: int}

Review Comment:
   ```suggestion
       cse_dict : Dict[PrimExpr, int]
   ```



##########
src/arith/detect_common_subexpr.cc:
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+/*!
+ * \file detect_common_subexpr.cc
+ * \brief Utility to detect common sub expressions.
+ */
+#include <tvm/tir/expr.h>
+
+#include <limits>
+
+#include "../tir/transforms/common_subexpr_elim_tools.h"
+
+namespace tvm {
+namespace arith {
+
+using namespace tir;
+
+Map<PrimExpr, Integer> DetectCommonSubExpr(const PrimExpr& e, const Integer thresh) {

Review Comment:
   ```suggestion
   Map<PrimExpr, Integer> DetectCommonSubExpr(const PrimExpr& e, int thresh) {
   ```
   
   Integer is not needed here, feel free to use `int`



##########
src/arith/detect_common_subexpr.cc:
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+/*!
+ * \file detect_common_subexpr.cc
+ * \brief Utility to detect common sub expressions.
+ */
+#include <tvm/tir/expr.h>
+
+#include <limits>
+
+#include "../tir/transforms/common_subexpr_elim_tools.h"
+
+namespace tvm {
+namespace arith {
+
+using namespace tir;
+
+Map<PrimExpr, Integer> DetectCommonSubExpr(const PrimExpr& e, const Integer thresh) {
+  // Check the treshold in range of size_t

Review Comment:
   ```suggestion
     // Check the threshold in the range of size_t
   ```



##########
python/tvm/arith/pattern.py:
##########
@@ -58,3 +58,22 @@ def detect_clip_bound(expr, var_list):
         An empty list if the match failed.
     """
     return _ffi_api.DetectClipBound(expr, var_list)
+
+
+def detect_common_subexpr(expr, thresh):
+    """Detect common sub expression which shows up more than a threshold times
+
+    Parameters
+    ----------
+    expr : PrimExpr
+        The expression to be analyzed.
+
+    thresh : int

Review Comment:
   ```suggestion
       threshold : int
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] tvm-bot commented on pull request #13702: [TIR][Arith] Add common sub expr analyzer

Posted by GitBox <gi...@apache.org>.
tvm-bot commented on PR #13702:
URL: https://github.com/apache/tvm/pull/13702#issuecomment-1371868332

   <!---bot-comment-->
   
   Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
   
   
   
   <sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] wrongtest-intellif merged pull request #13702: [TIR][Arith] Add common sub expr analyzer

Posted by GitBox <gi...@apache.org>.
wrongtest-intellif merged PR #13702:
URL: https://github.com/apache/tvm/pull/13702


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org