@@ -52,20 +52,23 @@ The current parse interface looks like:
5252 parser = tvm.hybrid.parse(outer_product, [a, b]) # return the parser of this function
5353
5454
55- If we pass these tvm tensors to this function, it returns a op node:
55+ If we pass these tvm data structures, like ``Tensor ``, ``Var ``, ``Expr.*Imm ``,
56+ or ``tvm.container.Array ``, to this function, it returns a op node:
5657
5758.. code-block :: python
5859
5960 a = tvm.placeholder((100 , ), name = ' a' )
6061 b = tvm.placeholder((99 , ), name = ' b' )
6162 c = outer_product(a, b, c) # return the output tensor(s) of the operator
6263
63- **Under construction, we are still deciding what kind of node should be returned. **
64+ You can use any methods that can be applied on a TVM ``OpNode ``, like create_schedule, although
65+ so far, the functionality of schedule is as limited as ``ExternOpNode ``. At least, it can be built
66+ to LLVM module.
6467
6568Tuning
6669~~~~~~
6770
68- **Under construction, not truly supported yet. **
71+ **Under construction, not supported yet. **
6972
7073Follow up the example above, you can use some tvm like interfaces to tune the code:
7174
@@ -86,6 +89,21 @@ Here we use ``range`` aka ``serial``, ``unroll``, ``parallel``, and ``vectorize`
8689these **4 ** keywords to annotate the corresponding types of for loops.
8790The the usage is roughly the same as Python standard ``range ``.
8891
92+ Besides all the loop types supported in Halide, ``const_range `` is supported for some specific conditions.
93+ Sometimes, ``tvm.container.Array `` is desired to pass as an argument, but in TVM-HalideIR, there is no
94+ such support that converts ``tvm.container.Array `` to an ``Expr ``. Thus, a limited feature is supported.
95+ Users can access containers by either constants or constants loops annotated.
96+
97+ .. code-block :: python
98+
99+ @tvm.hybrid.script
100+ def foo (a , b ): # b is a tvm.container.Array
101+ c = output_tensor(a.shape, a.dtype)
102+ for i in const_range(len (a)): # because you have b access, i should be explicitly annotated as const_range
103+ c[i] = a[i] + b[i]
104+ return c
105+
106+
89107 Variables
90108~~~~~~~~~
91109
@@ -111,14 +129,14 @@ It regards the first store of a variable as its declaration.
111129 s += a[i, j] # do something with sum
112130 b[i] = sum # you can still use sum in this level
113131 a[0 ] = s # you CANNOT use s here, even though it is allowed in conventional Python
114- b = (1 , 2 ) # this has NOT been supported yet!
115132
116133
117134 Attributes
118135~~~~~~~~~~
119136
120- So far, ONLY tensors' ``shape `` attribute is supported! The ``shape `` atrribute is essentailly a
121- tuple, so you MUST access it as an array. Also, currently, only constant-indexed access is supported.
137+ So far, ONLY tensors' ``shape `` and ``dtype `` attribute are supported!
138+ The ``shape `` atrribute is essentailly a tuple, so you MUST access it as an array.
139+ Currently, only constant-indexed access is supported.
122140
123141.. code-block :: python
124142
@@ -133,8 +151,11 @@ Conditional Statement and Expression
133151
134152.. code-block :: python
135153
136- if condition:
137- # do something
154+ if condition1 and condition2 and condition3:
155+ # do something
156+ else :
157+ # do something else
158+ # Select
138159 a = b if condition else c
139160
140161 However, NO ``True `` and ``False `` keyword supported yet.
@@ -153,7 +174,9 @@ Array Allocation
153174**Under construction, this function will be supported later! **
154175
155176Use a function call ``allocation(shape, type, share/local) `` to declare an array buffer.
156- The basic usage is roughly the same as a normal array.
177+ The basic usage is roughly the same as a normal ``numpy.array ``, and you should access
178+ high-dim array in ``a[i, j, k] `` fashion instead of ``a[i][j][k] ``,
179+ even for ``tvm.container.Array `` for compilation.
157180
158181
159182Thread Bind
@@ -170,5 +193,5 @@ You can also do loop-thread bind by writing code like this:
170193
171194 Keywords
172195~~~~~~~~
173- - For keywords: ``serial ``, ``range ``, ``unroll ``, ``parallel ``, ``vectorize ``, ``bind ``
196+ - For keywords: ``serial ``, ``range ``, ``unroll ``, ``parallel ``, ``vectorize ``, ``bind ``, `` const_expr ``
174197- Math keywords: ``log ``, ``exp ``, ``sigmoid ``, ``tanh ``, ``power ``, ``popcount ``
0 commit comments