Unverified Commit 543c4240 by Tianqi Chen Committed by GitHub

[NNVM] Recover reduction behavir, fix CI (#1740)

parent ac7b4205
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
* \file reduce.cc * \file reduce.cc
* \brief reduce operator. * \brief reduce operator.
*/ */
// Enforce TOPI to use old behavior that reduces to at least 1d
#define TOPI_REDUCE_ATLEAST1D 1
#include <nnvm/op.h> #include <nnvm/op.h>
#include <nnvm/node.h> #include <nnvm/node.h>
#include <nnvm/op_attr_types.h> #include <nnvm/op_attr_types.h>
...@@ -17,6 +20,8 @@ ...@@ -17,6 +20,8 @@
#include "topi/reduction.h" #include "topi/reduction.h"
#include "topi/transform.h" #include "topi/transform.h"
static_assert(TOPI_REDUCE_ATLEAST1D, "need to use legacy reduce behavior");
namespace nnvm { namespace nnvm {
namespace top { namespace top {
using namespace tvm; using namespace tvm;
......
...@@ -20,6 +20,14 @@ ...@@ -20,6 +20,14 @@
#include "topi/detail/constant_utils.h" #include "topi/detail/constant_utils.h"
#include "tvm/tvm.h" #include "tvm/tvm.h"
/*!
* \brief macro flag to enable some legacy behavior which requires
* reduction result to be at least 1d.
*/
#ifndef TOPI_REDUCE_ATLEAST1D
#define TOPI_REDUCE_ATLEAST1D 0
#endif
namespace topi { namespace topi {
using namespace tvm; using namespace tvm;
...@@ -96,6 +104,9 @@ inline Array<Expr> MakeReduceTargetShape(const std::vector<int>& real_axis, ...@@ -96,6 +104,9 @@ inline Array<Expr> MakeReduceTargetShape(const std::vector<int>& real_axis,
} }
} }
} }
if (target_shape.size() == 0 && TOPI_REDUCE_ATLEAST1D) {
target_shape.push_back(1);
}
return target_shape; return target_shape;
} }
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
* \brief Registration of TVM operators and schedules * \brief Registration of TVM operators and schedules
* \file topi.cc * \file topi.cc
*/ */
#define TOPI_REDUCE_ATLEAST1D 0
#include <tvm/runtime/packed_func.h> #include <tvm/runtime/packed_func.h>
#include <tvm/runtime/module.h> #include <tvm/runtime/module.h>
#include <tvm/runtime/registry.h> #include <tvm/runtime/registry.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment