镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

division crashed "bad allocation" #2850

Open

Description

@argman

I am using a 4D tensor, like

typedef xt::xtensor<float, 4, xt::layout_type::row_major> T4;

when i am doing divsion like:

T4 a, b; // with some initialization
and

a = a/b; (i make sure no zeros in b);

this expression crashed;

Activity

  1. Alex-PLACET commented on May 5, 2026

    @Alex-PLACET
    Contributor

    I tried to reproduce the issue with this test:

    TEST_CASE("divide_4d")
    {
        using T4 = xt::xtensor<float, 4, xt::layout_type::row_major>;
        using shape_type = typename T4::shape_type;
    
        shape_type shape = {2, 3, 2, 2};
        T4 a(shape, 4.5f);
        T4 b(shape, 1.3f);
    
        EXPECT_EQ((a / b)(0, 0, 0, 0), a(0, 0, 0, 0) / b(0, 0, 0, 0));
    
        float sb = 1.2f;
        EXPECT_EQ((a / sb)(0, 0, 0, 0), a(0, 0, 0, 0) / sb);
    
        float sa = 4.6f;
        EXPECT_EQ((sa / b)(0, 0, 0, 0), sa / b(0, 0, 0, 0));
    
        // self-divide assignment: a = a / b (no zeros in b)
        auto a_before = a(1, 2, 1, 1);
        a = a / b;
        EXPECT_EQ(a(1, 2, 1, 1), a_before / b(1, 2, 1, 1));
    }

    I don't reproduce the issue.
    Can you give me your environment ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions