tvm
memory.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
24 #ifndef TVM_RELAY_ATTRS_MEMORY_H_
25 #define TVM_RELAY_ATTRS_MEMORY_H_
26 
27 #include <tvm/ir/attrs.h>
28 #include <tvm/relay/expr.h>
29 
30 #include <string>
31 #include <vector>
32 
33 namespace tvm {
34 namespace relay {
35 
36 std::vector<TensorType> FlattenTupleType(const Type& type);
37 std::vector<Expr> FromTupleType(const Type& type, const Expr& expr);
38 Expr ToTupleType(const Type& t, const std::vector<Expr>& exprs);
39 
43 struct AllocStorageAttrs : public tvm::AttrsNode<AllocStorageAttrs> {
45  int device_id;
47 
48  TVM_DECLARE_ATTRS(AllocStorageAttrs, "relay.attrs.AllocStorageAttrs") {
49  TVM_ATTR_FIELD(dtype)
50  .describe("The dtype of the tensor to allocate.")
51  .set_default(DataType::Float(32, 1));
52  TVM_ATTR_FIELD(device_id).describe("The device id on which to allocate memory.");
53  TVM_ATTR_FIELD(device_type).describe("The device type on which to allocate memory.");
54  }
55 };
56 
60 struct AllocTensorAttrs : public tvm::AttrsNode<AllocTensorAttrs> {
64 
65  TVM_DECLARE_ATTRS(AllocTensorAttrs, "relay.attrs.AllocTensorAttrs") {
66  TVM_ATTR_FIELD(dtype)
67  .describe("The dtype of the tensor to allocate.")
68  .set_default(DataType::Float(32, 1));
69  TVM_ATTR_FIELD(const_shape).describe("The shape of constant used to aid in type inference.");
70  TVM_ATTR_FIELD(assert_shape)
71  .describe(
72  "The shape to cast the return type of the allocation to, "
73  "used to specify the shape obtained via further analysis.");
74  }
75 };
76 
77 } // namespace relay
78 } // namespace tvm
79 #endif // TVM_RELAY_ATTRS_MEMORY_H_
std::vector< TensorType > FlattenTupleType(const Type &type)
TVM_DECLARE_ATTRS(AllocStorageAttrs, "relay.attrs.AllocStorageAttrs")
Definition: memory.h:48
Relay expression language.
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:36
DataType dtype
Definition: memory.h:44
int device_id
Definition: memory.h:45
Array< IndexExpr > assert_shape
Definition: memory.h:62
std::vector< Expr > FromTupleType(const Type &type, const Expr &expr)
Definition: expr.h:88
Helpers for attribute objects.
Options for allocating tensors.
Definition: memory.h:60
Runtime primitive data type.
Definition: data_type.h:41
DataType dtype
Definition: memory.h:63
int device_type
Definition: memory.h:46
static DataType Float(int bits, int lanes=1)
Construct an float type.
Definition: data_type.h:168
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:270
#define TVM_ATTR_FIELD(FieldName)
Declare an attribute field.
Definition: attrs.h:76
tvm::Type Type
Definition: type.h:47
Options for allocating storage.
Definition: memory.h:43
tvm::RelayExpr Expr
Definition: expr.h:43
Constant const_shape
Definition: memory.h:61
The base class of the all the Use "curiously recurring template pattern".
Definition: attrs.h:793
TVM_DECLARE_ATTRS(AllocTensorAttrs, "relay.attrs.AllocTensorAttrs")
Definition: memory.h:65
Expr ToTupleType(const Type &t, const std::vector< Expr > &exprs)