junrushao1994 commented on a change in pull request #8943:
URL: https://github.com/apache/tvm/pull/8943#discussion_r703896891



##########
File path: src/support/nd_int_set.h
##########
@@ -0,0 +1,150 @@
+/*
+ * 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.
+ */
+#ifndef TVM_SUPPORT_ND_INT_SET_H_
+#define TVM_SUPPORT_ND_INT_SET_H_
+
+#include <tvm/arith/int_set.h>
+#include <tvm/ir/expr.h>
+
+#include <unordered_map>
+#include <vector>
+
+namespace tvm {
+namespace support {
+
+/*! \brief An N-dimensional integer set representing a rectangle region */
+using NDIntSet = std::vector<tvm::arith::IntSet>;
+
+/*!
+ * \brief Construct an N-dimensional integer set representing a region.
+ * \param region The region.
+ * \return constructed set.
+ */
+inline NDIntSet NDIntSetFromRegion(const tir::Region& region) {
+  NDIntSet result;
+  result.reserve(region.size());
+  for (const Range& range : region) {
+    result.push_back(arith::IntSet::FromRange(range));
+  }
+  return result;
+}
+
+/*!
+ * \brief Construct an N-dimensional integer set representing a shape.
+ * \param shape The shape which is an array of the length of each dimension.
+ * \return constructed set.
+ */
+inline NDIntSet NDIntSetFromShape(const Array<PrimExpr>& shape) {
+  PrimExpr zero = Integer(0);

Review comment:
       There won't be too much difference though but it does help a little bit. 
On the other hand, incrementing atomic ref counter in more than 1 thread could 
cause a performance issue on CPUs, so that's why I didn't do any further 
immature optimization




-- 
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