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 2021/06/03 15:20:50 UTC

[GitHub] [tvm] ZihengJiang opened a new pull request #8183: [RUNTIME] ShapeTuple Container and Re-organize for Containers

ZihengJiang opened a new pull request #8183:
URL: https://github.com/apache/tvm/pull/8183


   Thanks for contributing to TVM!   Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @ them in the pull request thread.
   


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

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



[GitHub] [tvm] tqchen merged pull request #8183: [RUNTIME][REFACTOR] Re-organize Containers into SubFolders

Posted by GitBox <gi...@apache.org>.
tqchen merged pull request #8183:
URL: https://github.com/apache/tvm/pull/8183


   


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

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



[GitHub] [tvm] junrushao1994 commented on pull request #8183: [RUNTIME][REFACTOR] Re-organize Containers into SubFolders

Posted by GitBox <gi...@apache.org>.
junrushao1994 commented on pull request #8183:
URL: https://github.com/apache/tvm/pull/8183#issuecomment-855337812


   Overall looks good, but not familiar with this CI failure
   


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

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



[GitHub] [tvm] tqchen commented on pull request #8183: [RUNTIME][REFACTOR] Re-organize Containers into SubFolders

Posted by GitBox <gi...@apache.org>.
tqchen commented on pull request #8183:
URL: https://github.com/apache/tvm/pull/8183#issuecomment-855246005


   cc @junrushao1994 @yzhliu 


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

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



[GitHub] [tvm] tqchen commented on a change in pull request #8183: [RUNTIME] ShapeTuple Container and Re-organize for Containers

Posted by GitBox <gi...@apache.org>.
tqchen commented on a change in pull request #8183:
URL: https://github.com/apache/tvm/pull/8183#discussion_r645535054



##########
File path: include/tvm/runtime/container/shape_tuple.h
##########
@@ -0,0 +1,99 @@
+/*
+ * 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 tvm/runtime/container/shape_tuple.h
+ * \brief Runtime ShapeTuple container types.
+ */
+#ifndef TVM_RUNTIME_CONTAINER_SHAPE_TUPLE_H_
+#define TVM_RUNTIME_CONTAINER_SHAPE_TUPLE_H_
+
+#include <utility>
+#include <vector>
+
+#include "./base.h"
+
+namespace tvm {
+namespace runtime {
+
+class ShapeTupleObj : public Object {

Review comment:
       need document of the classes

##########
File path: include/tvm/runtime/container/shape_tuple.h
##########
@@ -0,0 +1,99 @@
+/*
+ * 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 tvm/runtime/container/shape_tuple.h
+ * \brief Runtime ShapeTuple container types.
+ */
+#ifndef TVM_RUNTIME_CONTAINER_SHAPE_TUPLE_H_
+#define TVM_RUNTIME_CONTAINER_SHAPE_TUPLE_H_
+
+#include <utility>
+#include <vector>
+
+#include "./base.h"
+
+namespace tvm {
+namespace runtime {
+
+class ShapeTupleObj : public Object {
+ public:
+  using index_type = int64_t;
+  index_type* data;
+  uint64_t ndim;
+
+  static constexpr const uint32_t _type_index = runtime::TypeIndex::kRuntimeShapeTuple;
+  static constexpr const char* _type_key = "runtime.ShapeTuple";
+  TVM_DECLARE_FINAL_OBJECT_INFO(ShapeTupleObj, Object);
+
+ private:
+  class FromStd;
+  friend class ShapeTuple;
+};
+
+class ShapeTupleObj::FromStd : public ShapeTupleObj {
+ public:
+  using index_type = ShapeTupleObj::index_type;
+  explicit FromStd(std::vector<index_type> other) : data_container{other} {}
+
+ private:
+  /*! \brief Container that holds the memory. */
+  std::vector<index_type> data_container;
+
+  friend class ShapeTuple;
+};
+
+class ShapeTuple : public ObjectRef {
+ public:
+  using index_type = ShapeTupleObj::index_type;
+  ShapeTuple() : ShapeTuple(std::vector<index_type>()) {}
+  template <typename Iterator>
+  ShapeTuple(Iterator begin, Iterator end) : ShapeTuple(std::vector<index_type>(begin, end)) {}
+  ShapeTuple(std::initializer_list<index_type> shape) : ShapeTuple(shape.begin(), shape.end()) {}
+
+  ShapeTuple(std::vector<index_type> shape);  // NOLINT(*)
+
+  index_type operator[](size_t idx) const { return get()->data[idx]; }
+  index_type at(size_t idx) const { return get()->data[idx]; }
+  index_type* data() { return get()->data; }

Review comment:
       only support constant index_type to keep shape tuple immutable

##########
File path: include/tvm/runtime/container/shape_tuple.h
##########
@@ -0,0 +1,99 @@
+/*
+ * 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 tvm/runtime/container/shape_tuple.h
+ * \brief Runtime ShapeTuple container types.
+ */
+#ifndef TVM_RUNTIME_CONTAINER_SHAPE_TUPLE_H_
+#define TVM_RUNTIME_CONTAINER_SHAPE_TUPLE_H_
+
+#include <utility>
+#include <vector>
+
+#include "./base.h"
+
+namespace tvm {
+namespace runtime {
+
+class ShapeTupleObj : public Object {
+ public:
+  using index_type = int64_t;
+  index_type* data;
+  uint64_t ndim;
+
+  static constexpr const uint32_t _type_index = runtime::TypeIndex::kRuntimeShapeTuple;
+  static constexpr const char* _type_key = "runtime.ShapeTuple";
+  TVM_DECLARE_FINAL_OBJECT_INFO(ShapeTupleObj, Object);
+
+ private:
+  class FromStd;
+  friend class ShapeTuple;
+};
+
+class ShapeTupleObj::FromStd : public ShapeTupleObj {
+ public:
+  using index_type = ShapeTupleObj::index_type;
+  explicit FromStd(std::vector<index_type> other) : data_container{other} {}
+
+ private:
+  /*! \brief Container that holds the memory. */
+  std::vector<index_type> data_container;
+
+  friend class ShapeTuple;
+};
+
+class ShapeTuple : public ObjectRef {
+ public:
+  using index_type = ShapeTupleObj::index_type;
+  ShapeTuple() : ShapeTuple(std::vector<index_type>()) {}
+  template <typename Iterator>
+  ShapeTuple(Iterator begin, Iterator end) : ShapeTuple(std::vector<index_type>(begin, end)) {}
+  ShapeTuple(std::initializer_list<index_type> shape) : ShapeTuple(shape.begin(), shape.end()) {}
+
+  ShapeTuple(std::vector<index_type> shape);  // NOLINT(*)
+
+  index_type operator[](size_t idx) const { return get()->data[idx]; }
+  index_type at(size_t idx) const { return get()->data[idx]; }
+  index_type* data() { return get()->data; }
+  size_t ndim() const { return get()->ndim; }
+  size_t size() const { return get()->ndim; }

Review comment:
       Only use size is fine.




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

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



[GitHub] [tvm] tqchen commented on a change in pull request #8183: [RUNTIME] ShapeTuple Container and Re-organize for Containers

Posted by GitBox <gi...@apache.org>.
tqchen commented on a change in pull request #8183:
URL: https://github.com/apache/tvm/pull/8183#discussion_r645534963



##########
File path: include/tvm/runtime/container/shape_tuple.h
##########
@@ -0,0 +1,99 @@
+/*
+ * 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 tvm/runtime/container/shape_tuple.h
+ * \brief Runtime ShapeTuple container types.
+ */
+#ifndef TVM_RUNTIME_CONTAINER_SHAPE_TUPLE_H_
+#define TVM_RUNTIME_CONTAINER_SHAPE_TUPLE_H_
+
+#include <utility>
+#include <vector>
+
+#include "./base.h"
+
+namespace tvm {
+namespace runtime {
+
+class ShapeTupleObj : public Object {
+ public:
+  using index_type = int64_t;
+  index_type* data;
+  uint64_t ndim;

Review comment:
       use size and make interface as consistent with STL vector<int> as ppossible.




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

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