reminisce commented on a change in pull request #15984: [DO NOT REVIEW] [DO NOT 
MERGE] General reduce compute for tvm ops and TVM version of sum
URL: https://github.com/apache/incubator-mxnet/pull/15984#discussion_r317236329
 
 

 ##########
 File path: contrib/tvmop/basic/reduce.py
 ##########
 @@ -0,0 +1,96 @@
+# 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.
+
+# coding: utf-8
+import tvm
+from .. import defop, AllTypes, RealTypes
+from .. import assign_by_req, reduce_axes
+# AllTypes = ["float32", "float64", "float16", "uint8", "int8", "int32", 
"int64"]
+# RealTypes = ["float32", "float64", "float16"]
+# AccTypes = {'float16': 'float32', 'float32': 'float64', 'float64': 'float64'}
+
+
+# def assign_by_req(a, req, otype):
+#     b = tvm.placeholder(a.shape, name='assign_by_req_b', dtype=otype)
+#     if (req == "kAddTo"):
+#         c = tvm.compute(a.shape, lambda *idx: a[idx].astype(otype) + b[idx])
+#     else:
+#         c = tvm.compute(a.shape, lambda *idx: a[idx].astype(otype))
+#     return b, c
+# 
+# def reduce_axes(X, axes, reducer, atype=None):
+#     def get_index(idx, ridx):
+#         j = 0
+#         k = 0
+#         ret = []
+#         for val in axes:
+#             ret.append(idx[j] if val == 0 else ridx[k])
+#             j += (val == 0)
+#             k += (val != 0)
+#         return tuple(ret)
+# 
+#     ishape = X.shape
+#     odim = (len(ishape) + 1 - axes[0]) // 2
+#     oshape = [tvm.var('odim.%d' % i, 'int32') for i in range(odim)]
+#     if atype is None:
+#         atype = X.dtype
+#     ridx = [tvm.reduce_axis((0, ishape[i]), name='r%d' % i) for (i, val) in 
enumerate(axes) if val == 1]
+#     ret = tvm.compute(oshape, lambda *idx: reducer(X[get_index(idx, 
ridx)].astype(atype), axis=ridx), name='ret')
+#     return ret
+
+def compute_reduce(dtype, otype, reducer, initial, ndim, reduce1st, req):
 
 Review comment:
   We decided to follow the official numpy file hierarchy to implement these 
ops. See the discussion here: 
https://github.com/apache/incubator-mxnet/pull/15855.
   
   Please create `tvmop/core/fromnumeric.py` and put the implementation there.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to