Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix in BinaryBroadcastLayout + unit test #6513

Merged
merged 1 commit into from Sep 21, 2020

Conversation

d-smirnov
Copy link
Contributor

An attempt to fix an issue which appeared when ConverLayout pass
runs on quantized binary operations like qnn.add:
def before():
x = relay.var("x", shape=(2, 2))
y = relay.var("y", shape=(1, 2))
return relay.Function(
[x, y],
relay.qnn.op.add(
x,
y,
lhs_scale=relay.const(0.0156863, "float32"),
lhs_zero_point=relay.const(127, "int32"),
rhs_scale=relay.const(0.0117647, "float32"),
rhs_zero_point=relay.const(85, "int32"),
output_scale=relay.const(0.0235294, "float32"),
output_zero_point=relay.const(128, "int32"),
),
)

The issue manifested itself as
[bt] (2) ./src/tvm/build/libtvm.so(tvm::relay::qnn::QnnBinaryBroadcastLayout(tvm::Attrs const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::Type, void> const&)+0xa9) [0x7fadc080d949]
[bt] (1) ./src/tvm/build/libtvm.so(tvm::runtime::Array<tvm::tir::Layout, void>::operator const+0xb6) [0x7fadc0382996]
[bt] (0) ./src/tvm/build/libtvm.so(+0xb50c12) [0x7fadc037cc12]
File "/workspace/include/tvm/runtime/container.h", line 681
IndexError: Check failed: 0 <= i && i < p->size_: indexing 1 on an array of size 1

Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.

An attempt to fix an issue which appeared when ConverLayout pass
runs on quantized binary operations like qnn.add:
def before():
    x = relay.var("x", shape=(2, 2))
    y = relay.var("y", shape=(1, 2))
    return relay.Function(
        [x, y],
        relay.qnn.op.add(
            x,
            y,
            lhs_scale=relay.const(0.0156863, "float32"),
            lhs_zero_point=relay.const(127, "int32"),
            rhs_scale=relay.const(0.0117647, "float32"),
            rhs_zero_point=relay.const(85, "int32"),
            output_scale=relay.const(0.0235294, "float32"),
            output_zero_point=relay.const(128, "int32"),
        ),
    )

The issue manifested itself as
  [bt] (2) ./src/tvm/build/libtvm.so(tvm::relay::qnn::QnnBinaryBroadcastLayout(tvm::Attrs const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::Type, void> const&)+0xa9) [0x7fadc080d949]
  [bt] (1) ./src/tvm/build/libtvm.so(tvm::runtime::Array<tvm::tir::Layout, void>::operator[](long) const+0xb6) [0x7fadc0382996]
  [bt] (0) ./src/tvm/build/libtvm.so(+0xb50c12) [0x7fadc037cc12]
  File "/workspace/include/tvm/runtime/container.h", line 681
IndexError: Check failed: 0 <= i && i < p->size_: indexing 1 on an array of size 1
@zhiics
Copy link
Member

zhiics commented Sep 18, 2020

cc @anijain2305

Copy link
Contributor

@anijain2305 anijain2305 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding and fixing the bug! LGTM.

@anijain2305 anijain2305 merged commit 8de10e3 into apache:master Sep 21, 2020
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 13, 2020
An attempt to fix an issue which appeared when ConverLayout pass
runs on quantized binary operations like qnn.add:
def before():
    x = relay.var("x", shape=(2, 2))
    y = relay.var("y", shape=(1, 2))
    return relay.Function(
        [x, y],
        relay.qnn.op.add(
            x,
            y,
            lhs_scale=relay.const(0.0156863, "float32"),
            lhs_zero_point=relay.const(127, "int32"),
            rhs_scale=relay.const(0.0117647, "float32"),
            rhs_zero_point=relay.const(85, "int32"),
            output_scale=relay.const(0.0235294, "float32"),
            output_zero_point=relay.const(128, "int32"),
        ),
    )

The issue manifested itself as
  [bt] (2) ./src/tvm/build/libtvm.so(tvm::relay::qnn::QnnBinaryBroadcastLayout(tvm::Attrs const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::Type, void> const&)+0xa9) [0x7fadc080d949]
  [bt] (1) ./src/tvm/build/libtvm.so(tvm::runtime::Array<tvm::tir::Layout, void>::operator[](long) const+0xb6) [0x7fadc0382996]
  [bt] (0) ./src/tvm/build/libtvm.so(+0xb50c12) [0x7fadc037cc12]
  File "/workspace/include/tvm/runtime/container.h", line 681
IndexError: Check failed: 0 <= i && i < p->size_: indexing 1 on an array of size 1
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 14, 2020
An attempt to fix an issue which appeared when ConverLayout pass
runs on quantized binary operations like qnn.add:
def before():
    x = relay.var("x", shape=(2, 2))
    y = relay.var("y", shape=(1, 2))
    return relay.Function(
        [x, y],
        relay.qnn.op.add(
            x,
            y,
            lhs_scale=relay.const(0.0156863, "float32"),
            lhs_zero_point=relay.const(127, "int32"),
            rhs_scale=relay.const(0.0117647, "float32"),
            rhs_zero_point=relay.const(85, "int32"),
            output_scale=relay.const(0.0235294, "float32"),
            output_zero_point=relay.const(128, "int32"),
        ),
    )

The issue manifested itself as
  [bt] (2) ./src/tvm/build/libtvm.so(tvm::relay::qnn::QnnBinaryBroadcastLayout(tvm::Attrs const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::Type, void> const&)+0xa9) [0x7fadc080d949]
  [bt] (1) ./src/tvm/build/libtvm.so(tvm::runtime::Array<tvm::tir::Layout, void>::operator[](long) const+0xb6) [0x7fadc0382996]
  [bt] (0) ./src/tvm/build/libtvm.so(+0xb50c12) [0x7fadc037cc12]
  File "/workspace/include/tvm/runtime/container.h", line 681
IndexError: Check failed: 0 <= i && i < p->size_: indexing 1 on an array of size 1
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 15, 2020
An attempt to fix an issue which appeared when ConverLayout pass
runs on quantized binary operations like qnn.add:
def before():
    x = relay.var("x", shape=(2, 2))
    y = relay.var("y", shape=(1, 2))
    return relay.Function(
        [x, y],
        relay.qnn.op.add(
            x,
            y,
            lhs_scale=relay.const(0.0156863, "float32"),
            lhs_zero_point=relay.const(127, "int32"),
            rhs_scale=relay.const(0.0117647, "float32"),
            rhs_zero_point=relay.const(85, "int32"),
            output_scale=relay.const(0.0235294, "float32"),
            output_zero_point=relay.const(128, "int32"),
        ),
    )

The issue manifested itself as
  [bt] (2) ./src/tvm/build/libtvm.so(tvm::relay::qnn::QnnBinaryBroadcastLayout(tvm::Attrs const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::Type, void> const&)+0xa9) [0x7fadc080d949]
  [bt] (1) ./src/tvm/build/libtvm.so(tvm::runtime::Array<tvm::tir::Layout, void>::operator[](long) const+0xb6) [0x7fadc0382996]
  [bt] (0) ./src/tvm/build/libtvm.so(+0xb50c12) [0x7fadc037cc12]
  File "/workspace/include/tvm/runtime/container.h", line 681
IndexError: Check failed: 0 <= i && i < p->size_: indexing 1 on an array of size 1
TusharKanekiDey pushed a commit to TusharKanekiDey/tvm that referenced this pull request Oct 16, 2020
An attempt to fix an issue which appeared when ConverLayout pass
runs on quantized binary operations like qnn.add:
def before():
    x = relay.var("x", shape=(2, 2))
    y = relay.var("y", shape=(1, 2))
    return relay.Function(
        [x, y],
        relay.qnn.op.add(
            x,
            y,
            lhs_scale=relay.const(0.0156863, "float32"),
            lhs_zero_point=relay.const(127, "int32"),
            rhs_scale=relay.const(0.0117647, "float32"),
            rhs_zero_point=relay.const(85, "int32"),
            output_scale=relay.const(0.0235294, "float32"),
            output_zero_point=relay.const(128, "int32"),
        ),
    )

The issue manifested itself as
  [bt] (2) ./src/tvm/build/libtvm.so(tvm::relay::qnn::QnnBinaryBroadcastLayout(tvm::Attrs const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::Type, void> const&)+0xa9) [0x7fadc080d949]
  [bt] (1) ./src/tvm/build/libtvm.so(tvm::runtime::Array<tvm::tir::Layout, void>::operator[](long) const+0xb6) [0x7fadc0382996]
  [bt] (0) ./src/tvm/build/libtvm.so(+0xb50c12) [0x7fadc037cc12]
  File "/workspace/include/tvm/runtime/container.h", line 681
IndexError: Check failed: 0 <= i && i < p->size_: indexing 1 on an array of size 1
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Oct 19, 2020
An attempt to fix an issue which appeared when ConverLayout pass
runs on quantized binary operations like qnn.add:
def before():
    x = relay.var("x", shape=(2, 2))
    y = relay.var("y", shape=(1, 2))
    return relay.Function(
        [x, y],
        relay.qnn.op.add(
            x,
            y,
            lhs_scale=relay.const(0.0156863, "float32"),
            lhs_zero_point=relay.const(127, "int32"),
            rhs_scale=relay.const(0.0117647, "float32"),
            rhs_zero_point=relay.const(85, "int32"),
            output_scale=relay.const(0.0235294, "float32"),
            output_zero_point=relay.const(128, "int32"),
        ),
    )

The issue manifested itself as
  [bt] (2) ./src/tvm/build/libtvm.so(tvm::relay::qnn::QnnBinaryBroadcastLayout(tvm::Attrs const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::tir::Layout, void> const&, tvm::runtime::Array<tvm::Type, void> const&)+0xa9) [0x7fadc080d949]
  [bt] (1) ./src/tvm/build/libtvm.so(tvm::runtime::Array<tvm::tir::Layout, void>::operator[](long) const+0xb6) [0x7fadc0382996]
  [bt] (0) ./src/tvm/build/libtvm.so(+0xb50c12) [0x7fadc037cc12]
  File "/workspace/include/tvm/runtime/container.h", line 681
IndexError: Check failed: 0 <= i && i < p->size_: indexing 1 on an array of size 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants