Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[BUGFIX] fix npi_concatenate quantization dim/axis #20383

Merged
merged 2 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/operator/quantization/quantized_concat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/

#include "../nn/concat-inl.h"
#include "../numpy/np_matrix_op-inl.h"

namespace mxnet {
namespace op {
Expand Down Expand Up @@ -157,5 +158,27 @@ NNVM_REGISTER_OP(Concat)
return node;
});

NNVM_REGISTER_OP(_npi_concatenate)
.set_attr<FQuantizedOp>("FQuantizedOp", [](const NodeAttrs& attrs) {
const NumpyConcatenateParam& param = nnvm::get<NumpyConcatenateParam>(attrs.parsed);
nnvm::ObjectPtr node = nnvm::Node::Create();
if (param.axis.has_value() && param.axis.value() > 0) {
node->attrs.op = Op::Get("_contrib_quantized_concat");
node->attrs.name = "quantized_" + attrs.name;
} else {
LOG(INFO) << "Currently, quantized numpy concatenate only supports axis>0, exclude "
<< attrs.name << " which axis is " << param.axis;
node->attrs.op = nullptr;
node->attrs.name = attrs.name;
}
node->attrs.dict = attrs.dict;
node->attrs.dict["dim"] = node->attrs.dict["axis"];
node->attrs.dict.erase("axis");
if (node->op() != nullptr && node->op()->attr_parser != nullptr) {
node->op()->attr_parser(&(node->attrs));
}
return node;
});

} // namespace op
} // namespace mxnet
1 change: 0 additions & 1 deletion tests/python/mkl/subgraphs/test_conv_subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ def forward(self, x):
@mx.util.use_np
@pytest.mark.parametrize('data_shape', DATA_SHAPE)
@pytest.mark.parametrize('out_type', ['int8', 'auto'])
@pytest.mark.skip("Scale doesn't align in numpy for numpy operators")
def test_pos_concat_scale_align(data_shape, out_type):
# concat scale alignment case
class ConcatScaleAlign(nn.HybridBlock):
Expand Down