Biubiubiu12 commented on code in PR #15274:
URL: https://github.com/apache/tvm/pull/15274#discussion_r1271690539


##########
src/tir/schedule/primitive/blockize_tensorize.cc:
##########
@@ -441,25 +441,29 @@ Array<BufferRegion> EvalSetRegions(const 
Array<BufferRegion>& regions,
  * \return The union regions
  */
 Array<BufferRegion> UnionRegions(const Array<BufferRegion>& regions) {
+  arith::Analyzer analyzer;
   typedef std::vector<Array<arith::IntSet>> ranges_t;
   std::unordered_map<Buffer, ranges_t, ObjectPtrHash, ObjectPtrEqual> 
intset_map;
+  Array<Buffer> buffer_order;
   for (const BufferRegion& buffer_region : regions) {
     const Buffer& buffer = buffer_region->buffer;
     if (intset_map.find(buffer) == intset_map.end()) {
       intset_map[buffer] = {buffer->shape.size(), Array<arith::IntSet>()};
+      buffer_order.push_back(buffer);
     }
     std::vector<Array<arith::IntSet>> dim_range(buffer->shape.size(), 
Array<arith::IntSet>());
     for (size_t dim = 0; dim < buffer->shape.size(); ++dim) {
       
intset_map[buffer][dim].push_back(arith::IntSet::FromRange(buffer_region->region[dim]));
     }
   }
   Array<BufferRegion> results;
-  for (const auto& it : intset_map) {
-    const Buffer& buffer = it.first;
+  for (size_t i = 0; i < buffer_order.size(); ++i) {
+    auto it = intset_map.find(buffer_order[i]);
+    const Buffer& buffer = it->first;
     Array<Range> regions;
     for (size_t dim = 0; dim < buffer->shape.size(); ++dim) {
-      const arith::IntSet intset = arith::Union(it.second[dim]);
-      regions.push_back({intset.min(), intset.max() + 1});
+      const arith::IntSet intset = arith::Union(it->second[dim]);
+      regions.push_back({analyzer.Simplify(intset.min()), 
analyzer.Simplify(intset.max() + 1)});

Review Comment:
   When using `tvm.ir.assert_structural_equal()`, the handwritten 
`@T.prim_func` will automatically` Simplify` the `regions`. For example, `i -- 
3` will automatically become `i+3`.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to