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

unexpected results of concat on blocking tensor #606

Closed
pinzhenx opened this issue Nov 28, 2019 · 3 comments
Closed

unexpected results of concat on blocking tensor #606

pinzhenx opened this issue Nov 28, 2019 · 3 comments
Assignees
Labels
bug A confirmed library bug
Milestone

Comments

@pinzhenx
Copy link
Contributor

pinzhenx commented Nov 28, 2019

#include <stdio.h>
#include "dnnl.hpp"

using namespace dnnl;
using tag = memory::format_tag;
using dt = memory::data_type;

int main() {
    engine eng(engine::kind::cpu, 0);
    stream strm(eng);

    float src1_buf[8] = {1, 0, 0, 0, 0, 0, 0, 0};
    float src2_buf[16] = {2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0};

    memory src1({{1, 1, 1, 1}, dt::f32, tag::aBcd8b}, eng, src1_buf);
    memory src2({{1, 1, 2, 1}, dt::f32, tag::aBcd8b}, eng, src2_buf);

    auto axis = 2;
    auto pd =
        concat::primitive_desc(axis, {src1.get_desc(), src2.get_desc()}, eng);

    auto dst = memory(pd.dst_desc(), eng);
    concat(pd).execute(strm,
                       {{DNNL_ARG_MULTIPLE_SRC + 0, src1},
                        {DNNL_ARG_MULTIPLE_SRC + 1, src2},
                        {DNNL_ARG_DST, dst}});

    for (size_t i = 0; i < dst.get_desc().get_size() / sizeof(float); i++)
        printf("%g\n", ((float*)dst.get_data_handle())[i]);

    return 0;
}

benchdnn to reproduce:

# ./benchdnn --concat --stag=aBcd16b:aBcd16b --dtag=aBcd16b --axis=2 1x1x1x1:1x1x2x1
[   0][0x0x0x0] fp0:    -411 fp:    -411 dt:    -nan
[   1][0x0x1x0] fp0:    -428 fp:    -428 dt:    -nan
[   2][0x0x2x0] fp0:    -331 fp:    -331 dt:    -nan
@@@ error [int concat::doit(const concat::prb_t*, res_t*):171]: 'compare(p, dst_data_type, dst_fp, dst, r)' -> 1
0:FAILED (errors:3 total:3) __REPRO: --concat --stag=aBcd16b:aBcd16b --dtag=aBcd16b --axis=2 1x1x1x1:1x1x2x1
tests:1 passed:0 skipped:0 mistrusted:0 unimplemented:0 failed:1 listed:

From my understanding, the result should be {1, 2, 3} in aBcd8b format

The example above is completely contrived to reproduce the issue, and I've had the same problem in the real world with other arbitrary dimensions.

@pinzhenx pinzhenx added the sighting Suspicious library behavior. Should be promoted to a bug when confirmed label Nov 28, 2019
@emfomenk
Copy link

Hi @pinzhenx,

Thanks a lot for the detailed report!
Yes, this is absolutely a bug on DNNL side (namely in simple concat implementation).
Could you please verify the fix?

@emfomenk emfomenk self-assigned this Nov 29, 2019
@emfomenk emfomenk added bug A confirmed library bug and removed sighting Suspicious library behavior. Should be promoted to a bug when confirmed labels Nov 29, 2019
@pinzhenx
Copy link
Contributor Author

Hi @emfomenk
It works like a charm!
Thank you for your quick response. Wish you a happy and blessed Thanksgiving.

@emfomenk
Copy link

Thanks for the confirmation!
I will try to promote the fix early next week!

@vpirogov vpirogov added this to the v1.2 milestone Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A confirmed library bug
Projects
None yet
Development

No branches or pull requests

3 participants