wweic commented on a change in pull request #4346: [Runtime] Make ADTObject POD 
container type
URL: https://github.com/apache/incubator-tvm/pull/4346#discussion_r347595585
 
 

 ##########
 File path: include/tvm/runtime/container.h
 ##########
 @@ -0,0 +1,220 @@
+/*
+ * 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.h
+ * \brief Common POD(plain old data) container types.
+ */
+#ifndef TVM_RUNTIME_CONTAINER_H_
+#define TVM_RUNTIME_CONTAINER_H_
+#include <tvm/runtime/object.h>
+#include <initializer_list>
+#include <type_traits>
+#include <vector>
+
+namespace tvm {
+namespace runtime {
+
+/**
+ * @brief Base template for classes with array like memory layout.
+ *
+ *        It provides general methods to access the memory. The memory
+ *        layout is ArrayType + [ElemType]. The alignment of ArrayType
+ *        and ElemType is handled by the memory allocator.
+ *
+ * @tparam ArrayType
+ * @tparam ElemType
+ */
+template <typename ArrayType, typename ElemType>
+class InplaceArrayBase {
+ public:
+  /**
+   * @brief Initialize the elements in the array.
+   */
+  void Init() {
 
 Review comment:
   Oh, I was not aware of this use case. I think it would be great if we can 
just provide `std::vector` interface(`operator[]`, `push_back`, `size`) in 
`InplaceArrayBase`. 
   
   To support dynamic insertion, it can query child class with `size()` and 
`capacity()` in `push_back` implementation. And I won't support dynamically 
grow the underlying storage since the actual memory management is done by child 
class, it's also difficult to grow this memory. 

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


With regards,
Apache Git Services

Reply via email to