You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by Chris Nuernberger via Apache TVM Discuss <no...@discuss.tvm.ai> on 2020/11/15 18:07:32 UTC

[Apache TVM Discuss] [Questions] Multiple right hand sides for reduction


Hey, I am testing out various TVM pathways for doing general data processing tasks.

One thing that seemed like low hanging fruit was kmeans++.  I fairly quickly hit an interesting snag that I am curious about.

I was going to attempt to do the diff-squared calculation in the reduction itself and hit an error.  In order to do this I attempted to declare a commreducer that had 1 lhs argument (the summation) and 2 rhs arguments (the two elemwise items of the two vectors):

```clojure
        expanded-distances-op (ast/compute
                               [n-rows n-centers]
                               (ast/tvm-fn
                                [row-idx center-idx]
                                (ast/commutative-reduce
                                 (ast/tvm-fn->commutative-reducer
                                  (ast/tvm-fn
                                   [sum row-elem center-elem]
                                   (ast/tvm-let [diff (ast-op/- row-elem center-elem)]
                                                (ast-op/+ sum (ast-op/mul diff diff))))
                                  [(float 0.0)])

                                 [{:domain [0 n-cols] :name "elem-idx"}]

                                 [(fn [elem-idx]
                                    (ast/tget dataset [row-idx elem-idx]))
                                  (fn [elem-idx]
                                    (ast/tget dataset [(ast/tget center-indexes [center-idx])
                                                       elem-idx]))]))
                               "expanded-distances")
``` 
This hit an error in expr.cc that I was very curious about:
https://github.com/apache/incubator-tvm/blob/728b829575e5e690870b111ae2256cbe0f3dbe6f/src/tir/ir/expr.cc#L827

I can in this case and in general lift a compound statement out into an intermediary but I thought the restriction that I had to have an equal number of accumulators and inputs to a reduction was very odd.

Is perhaps this first check not necessary?  Are there other work arounds (such as creating a tuple) I could try beside simply creating another compute operation?

Thanks for your time, I really like the work done on the object model and am having a great time playing with TVM.





---
[Visit Topic](https://discuss.tvm.apache.org/t/multiple-right-hand-sides-for-reduction/8457/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/6c74acd77f1bc2ad0f3e120c0ee8eb1688bc0c1d88a9222f4352800f745872bd).