-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Relay][Memory][VM] #3560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Relay][Memory][VM] #3560
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * 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/relay/attrs/memory.h | ||
| * \brief Attributes for memory operators. | ||
| */ | ||
| #ifndef TVM_RELAY_ATTRS_MEMORY_H_ | ||
| #define TVM_RELAY_ATTRS_MEMORY_H_ | ||
|
|
||
| #include <tvm/attrs.h> | ||
| #include <tvm/relay/expr.h> | ||
| #include <string> | ||
|
|
||
| namespace tvm { | ||
| namespace relay { | ||
|
|
||
| /*! | ||
| * \brief Options for allocating tensors. | ||
| */ | ||
| struct AllocTensorAttrs : public tvm::AttrsNode<AllocTensorAttrs> { | ||
| Constant const_shape; | ||
| Array<IndexExpr> assert_shape; | ||
| DataType dtype; | ||
|
|
||
| TVM_DECLARE_ATTRS(AllocTensorAttrs, "relay.attrs.AllocTensorAttrs") { | ||
| TVM_ATTR_FIELD(dtype) | ||
| .describe( | ||
| "The dtype of the tensor to allocate.") | ||
| .set_default(Float(32, 1)); | ||
| TVM_ATTR_FIELD(const_shape) | ||
| .describe( | ||
| "The shape of constant used to aid in type inference."); | ||
| TVM_ATTR_FIELD(assert_shape) | ||
| .describe( | ||
| "The shape to cast the return type of the allocation to, "\ | ||
| "used to specify the shape obtained via further analysis."); | ||
| } | ||
| }; | ||
|
|
||
| /*! | ||
| * \brief Options for the shape function operator. | ||
| */ | ||
| struct ShapeFuncAttrs : public tvm::AttrsNode<ShapeFuncAttrs> { | ||
| Array<Integer> is_input; | ||
|
|
||
| TVM_DECLARE_ATTRS(ShapeFuncAttrs, "relay.attrs.ShapeFuncAttrs") { | ||
| TVM_ATTR_FIELD(is_input) | ||
| .describe( | ||
| "A bool indicating whether the shape function should"\ | ||
| "expect shape or input in each position."); | ||
| } | ||
| }; | ||
|
|
||
| } // namespace relay | ||
| } // namespace tvm | ||
| #endif // TVM_RELAY_ATTRS_MEMORY_H_ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -283,6 +283,8 @@ class Object { | |
| * \note The deleter will be called when ref_counter_ becomes zero. | ||
| */ | ||
| inline void DecRef(); | ||
|
|
||
| private: | ||
| /*! | ||
| * \return The usage count of the cell. | ||
| * \note We use stl style naming to be consistent with known API in shared_ptr. | ||
|
|
@@ -675,6 +677,16 @@ struct ObjectEqual { | |
| operator bool() const { return data_ != nullptr; } \ | ||
| using ContainerType = ObjectName; | ||
|
|
||
| #define TVM_DEFINE_OBJECT_REF_METHODS_MUT(TypeName, ParentType, ObjectName) \ | ||
| TypeName() {} \ | ||
| explicit TypeName( \ | ||
| ::tvm::runtime::ObjectPtr<::tvm::runtime::Object> n) \ | ||
| : ParentType(n) {} \ | ||
| ObjectName* operator->() { \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The mutational def was a bit dangerous, can we explicitly use the define_ref_methods and add the mutationable ref methods directly? This will also reduce one macro
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can not do that as the definitions are incompatible overloads
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. they are compatible, because operator->() and operator->()const are two different functions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got an error about return type overload not working when I tried to do it. |
||
| return static_cast<ObjectName*>(data_.get()); \ | ||
| } \ | ||
| operator bool() const { return data_ != nullptr; } \ | ||
| using ContainerType = ObjectName; | ||
|
|
||
| // Implementations details below | ||
| // Object reference counting. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.