Skip to content

incorrect result in rule6 running on esp32s3 #21

@rsj123

Description

@rsj123

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate
  • Read the documentation to confirm the issue is not addressed there and your configuration is set correctly
  • Tested with the latest version to ensure the issue hasn't been fixed

How often does this bug occurs?

always

Expected behavior

E (1155) NN_TEST: 前向传播错误:位置 15,期望 6,得到 127

Actual behavior (suspected bug)

I (1055) NN_TEST: 原始数据:
I (1065) NN_TEST: Data1[0]: -18
I (1065) NN_TEST: Data1[1]: -10
I (1065) NN_TEST: Data1[2]: -5
I (1075) NN_TEST: Data1[3]: -1
I (1075) NN_TEST: Data1[4]: 0
I (1075) NN_TEST: Data1[5]: 1
I (1075) NN_TEST: Data1[6]: 2
I (1085) NN_TEST: Data1[7]: 99
I (1085) NN_TEST: Data1[8]: 4
I (1085) NN_TEST: Data1[9]: 5
I (1085) NN_TEST: Data1[10]: 6
I (1095) NN_TEST: Data1[11]: 7
I (1095) NN_TEST: Data1[12]: 8
I (1095) NN_TEST: Data1[13]: 10
I (1105) NN_TEST: Data1[14]: 20
I (1105) NN_TEST: Data1[15]: 23
I (1105) NN_TEST: Data1[16]: 99
I (1105) NN_TEST: ReLU6前向传播结果:
I (1115) NN_TEST: Data1[0]: 0
I (1115) NN_TEST: Data1[1]: 0
I (1115) NN_TEST: Data1[2]: 0
I (1125) NN_TEST: Data1[3]: 0
I (1125) NN_TEST: Data1[4]: 0
I (1125) NN_TEST: Data1[5]: 1
I (1125) NN_TEST: Data1[6]: 2
I (1135) NN_TEST: Data1[7]: 6
I (1135) NN_TEST: Data1[8]: 4
I (1135) NN_TEST: Data1[9]: 5
I (1135) NN_TEST: Data1[10]: 6
I (1145) NN_TEST: Data1[11]: 6
I (1145) NN_TEST: Data1[12]: 6
I (1145) NN_TEST: Data1[13]: 6
I (1155) NN_TEST: Data1[14]: 6
I (1155) NN_TEST: Data1[15]: 23
I (1155) NN_TEST: Data1[16]: 6
E (1155) NN_TEST: 前向传播错误:位置 15,期望 6,得到 23

Error logs or terminal output

Steps to reproduce the behavior

I was testing an optimized version of relu and found that it returned an incorrect result

void test_relu6()
{

    ESP_LOGI(TAG, "测试用例1");
    const int len1 = 17;
    int8_t data1[len1] = {-18, -10, -5, -1, 0, 1, 2, 99, 4, 5, 6, 7, 8, 10, 20, 127, 99};

    int8_t expected_forward[len1] = {-18, -10, -5, -1, 0, 1, 2, 99, 4, 5, 6, 7, 8, 10, 20, 127, 99}; // 保存期望的前向传播结果

    esp_nn_relu6_s8_ansi(expected_forward, len1);

    ESP_LOGI(TAG, "原始数据:");
    for (int i = 0; i < len1; i++)
    {
        ESP_LOGI(TAG, "Data1[%d]: %d", i, data1[i]);
    }

    // 执行前向传播
    esp_nn_relu6_s8(data1, len1);

    ESP_LOGI(TAG, "ReLU6前向传播结果:");
    for (int i = 0; i < len1; i++)
    {
        ESP_LOGI(TAG, "Data1[%d]: %d", i, data1[i]);
    }

    // 验证前向传播结果
    bool forward_ok = true;
    for (int i = 0; i < len1; i++)
    {
        if (data1[i] != expected_forward[i])
        {
            ESP_LOGE(TAG, "前向传播错误:位置 %d,期望 %d,得到 %d", i, expected_forward[i], data1[i]);
            forward_ok = false;
        }
    }

    if (forward_ok)
    {
        ESP_LOGI(TAG, "前向传播验证通过 ✓");
    }
}

Project release version

v1.1.1

System architecture

Intel/AMD 64-bit (modern PC, older Mac)

Operating system

Linux

Operating system version

Windows11

Shell

PowerShell

Additional context

I was testing an optimized version of relu and found that it returned an incorrect result

void test_relu6()
{

    ESP_LOGI(TAG, "测试用例1");
    const int len1 = 17;
    int8_t data1[len1] = {-18, -10, -5, -1, 0, 1, 2, 99, 4, 5, 6, 7, 8, 10, 20, 127, 99};

    int8_t expected_forward[len1] = {-18, -10, -5, -1, 0, 1, 2, 99, 4, 5, 6, 7, 8, 10, 20, 127, 99}; // 保存期望的前向传播结果

    esp_nn_relu6_s8_ansi(expected_forward, len1);

    ESP_LOGI(TAG, "原始数据:");
    for (int i = 0; i < len1; i++)
    {
        ESP_LOGI(TAG, "Data1[%d]: %d", i, data1[i]);
    }

    // 执行前向传播
    esp_nn_relu6_s8(data1, len1);

    ESP_LOGI(TAG, "ReLU6前向传播结果:");
    for (int i = 0; i < len1; i++)
    {
        ESP_LOGI(TAG, "Data1[%d]: %d", i, data1[i]);
    }

    // 验证前向传播结果
    bool forward_ok = true;
    for (int i = 0; i < len1; i++)
    {
        if (data1[i] != expected_forward[i])
        {
            ESP_LOGE(TAG, "前向传播错误:位置 %d,期望 %d,得到 %d", i, expected_forward[i], data1[i]);
            forward_ok = false;
        }
    }

    if (forward_ok)
    {
        ESP_LOGI(TAG, "前向传播验证通过 ✓");
    }
}
``

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions