## Coverage Report

#### Created: 2026-05-04 15:30

next uncovered line (L), next uncovered region (R), next uncovered branch (B)

    /home/liu/actions-runner/_work/ccv/ccv/test/unit/nnc/sort.tests.c

    Line
    Count
    Source
    1
    #include "case.h"
    2
    #include "ccv_case.h"
    3
    #include "ccv_nnc_case.h"
    4
    #include <ccv.h>
    5
    #include <nnc/ccv_nnc.h>
    6
    #include <nnc/ccv_nnc_easy.h>
    7
    8
    TEST_SETUP()
    9
    {
    10
      ccv_nnc_init();
    11
    }
    12
    13
    TEST_CASE("sort a tensor by first axis")
    14
    1
    {
    15
    1
      float ap[] = {
    16
    1
        1, 3,
    17
    1
        2, 5,
    18
    1
        3, 4,
    19
    1
      };
    20
    1
      ccv_nnc_tensor_t* const a = ccv_nnc_tensor_new(ap, CPU_TENSOR_NHWC(32F, 3, 2), 0);
    21
    1
      ccv_nnc_tensor_t* const b = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32F, 3, 2), 0);
    22
    1
      ccv_nnc_tensor_t* const indices = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    23
    1
      ccv_nnc_cmd_exec(CMD_SORT_FORWARD(0, 0), ccv_nnc_no_hint, 0, TENSOR_LIST(a), TENSOR_LIST(b, indices), 0);
    24
    1
      float btp[] = {
    25
    1
        1, 3,
    26
    1
        2, 4,
    27
    1
        3, 5,
    28
    1
      };
    29
    1
      ccv_nnc_tensor_t const bt = ccv_nnc_tensor(btp, CPU_TENSOR_NHWC(32F, 3, 2), 0);
    30
    1
      REQUIRE_TENSOR_EQ(b, &bt, "should be equal");
    31
    1
      int indicestp[] = {
    32
    1
        0, 0,
    33
    1
        1, 2,
    34
    1
        2, 1,
    35
    1
      };
    36
    1
      ccv_nnc_tensor_t const indicest = ccv_nnc_tensor(indicestp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    37
    1
      REQUIRE_TENSOR_EQ(indices, &indicest, "should be equal");
    38
    1
      ccv_nnc_tensor_free(a);
    39
    1
      ccv_nnc_tensor_free(b);
    40
    1
      ccv_nnc_tensor_free(indices);
    41
    1
    }
    42
    43
    TEST_CASE("sort a tensor by last axis")
    44
    1
    {
    45
    1
      float ap[] = {
    46
    1
        1, 3,
    47
    1
        2, 1,
    48
    1
        3, 4,
    49
    1
      };
    50
    1
      ccv_nnc_tensor_t* const a = ccv_nnc_tensor_new(ap, CPU_TENSOR_NHWC(32F, 3, 2), 0);
    51
    1
      ccv_nnc_tensor_t* const b = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32F, 3, 2), 0);
    52
    1
      ccv_nnc_tensor_t* const indices = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    53
    1
      ccv_nnc_cmd_exec(CMD_SORT_FORWARD(1, 0), ccv_nnc_no_hint, 0, TENSOR_LIST(a), TENSOR_LIST(b, indices), 0);
    54
    1
      float btp[] = {
    55
    1
        1, 3,
    56
    1
        1, 2,
    57
    1
        3, 4,
    58
    1
      };
    59
    1
      ccv_nnc_tensor_t const bt = ccv_nnc_tensor(btp, CPU_TENSOR_NHWC(32F, 3, 2), 0);
    60
    1
      REQUIRE_TENSOR_EQ(b, &bt, "should be equal");
    61
    1
      int indicestp[] = {
    62
    1
        0, 1,
    63
    1
        1, 0,
    64
    1
        0, 1,
    65
    1
      };
    66
    1
      ccv_nnc_tensor_t const indicest = ccv_nnc_tensor(indicestp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    67
    1
      REQUIRE_TENSOR_EQ(indices, &indicest, "should be equal");
    68
    1
      ccv_nnc_tensor_free(a);
    69
    1
      ccv_nnc_tensor_free(b);
    70
    1
      ccv_nnc_tensor_free(indices);
    71
    1
    }
    72
    73
    TEST_CASE("sort a 1d tensor")
    74
    1
    {
    75
    1
      float ap[] = {
    76
    1
        1, 3, 2, 4, 5
    77
    1
      };
    78
    1
      ccv_nnc_tensor_t* const a = ccv_nnc_tensor_new(ap, CPU_TENSOR_NHWC(32F, 5), 0);
    79
    1
      ccv_nnc_tensor_t* const b = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32F, 5), 0);
    80
    1
      ccv_nnc_tensor_t* const indices = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 5), 0);
    81
    1
      ccv_nnc_cmd_exec(CMD_SORT_FORWARD(0, 0), ccv_nnc_no_hint, 0, TENSOR_LIST(a), TENSOR_LIST(b, indices), 0);
    82
    1
      float btp[] = {
    83
    1
        1, 2, 3, 4, 5
    84
    1
      };
    85
    1
      ccv_nnc_tensor_t const bt = ccv_nnc_tensor(btp, CPU_TENSOR_NHWC(32F, 5), 0);
    86
    1
      REQUIRE_TENSOR_EQ(b, &bt, "should be equal");
    87
    1
      int indicestp[] = {
    88
    1
        0, 2, 1, 3, 4
    89
    1
      };
    90
    1
      ccv_nnc_tensor_t const indicest = ccv_nnc_tensor(indicestp, CPU_TENSOR_NHWC(32S, 5), 0);
    91
    1
      REQUIRE_TENSOR_EQ(indices, &indicest, "should be equal");
    92
    1
      ccv_nnc_tensor_free(a);
    93
    1
      ccv_nnc_tensor_free(b);
    94
    1
      ccv_nnc_tensor_free(indices);
    95
    1
    }
    96
    97
    TEST_CASE("sort a tensor by first axis in int")
    98
    1
    {
    99
    1
      int ap[] = {
    100
    1
        1, 3,
    101
    1
        2, 5,
    102
    1
        3, 4,
    103
    1
      };
    104
    1
      ccv_nnc_tensor_t* const a = ccv_nnc_tensor_new(ap, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    105
    1
      ccv_nnc_tensor_t* const b = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    106
    1
      ccv_nnc_tensor_t* const indices = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    107
    1
      ccv_nnc_cmd_exec(CMD_SORT_FORWARD(0, 0), ccv_nnc_no_hint, 0, TENSOR_LIST(a), TENSOR_LIST(b, indices), 0);
    108
    1
      int btp[] = {
    109
    1
        1, 3,
    110
    1
        2, 4,
    111
    1
        3, 5,
    112
    1
      };
    113
    1
      ccv_nnc_tensor_t const bt = ccv_nnc_tensor(btp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    114
    1
      REQUIRE_TENSOR_EQ(b, &bt, "should be equal");
    115
    1
      int indicestp[] = {
    116
    1
        0, 0,
    117
    1
        1, 2,
    118
    1
        2, 1,
    119
    1
      };
    120
    1
      ccv_nnc_tensor_t const indicest = ccv_nnc_tensor(indicestp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    121
    1
      REQUIRE_TENSOR_EQ(indices, &indicest, "should be equal");
    122
    1
      ccv_nnc_tensor_free(a);
    123
    1
      ccv_nnc_tensor_free(b);
    124
    1
      ccv_nnc_tensor_free(indices);
    125
    1
    }
    126
    127
    TEST_CASE("sort a tensor by last axis in int")
    128
    1
    {
    129
    1
      int ap[] = {
    130
    1
        1, 3,
    131
    1
        2, 1,
    132
    1
        3, 4,
    133
    1
      };
    134
    1
      ccv_nnc_tensor_t* const a = ccv_nnc_tensor_new(ap, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    135
    1
      ccv_nnc_tensor_t* const b = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    136
    1
      ccv_nnc_tensor_t* const indices = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    137
    1
      ccv_nnc_cmd_exec(CMD_SORT_FORWARD(1, 0), ccv_nnc_no_hint, 0, TENSOR_LIST(a), TENSOR_LIST(b, indices), 0);
    138
    1
      int btp[] = {
    139
    1
        1, 3,
    140
    1
        1, 2,
    141
    1
        3, 4,
    142
    1
      };
    143
    1
      ccv_nnc_tensor_t const bt = ccv_nnc_tensor(btp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    144
    1
      REQUIRE_TENSOR_EQ(b, &bt, "should be equal");
    145
    1
      int indicestp[] = {
    146
    1
        0, 1,
    147
    1
        1, 0,
    148
    1
        0, 1,
    149
    1
      };
    150
    1
      ccv_nnc_tensor_t const indicest = ccv_nnc_tensor(indicestp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    151
    1
      REQUIRE_TENSOR_EQ(indices, &indicest, "should be equal");
    152
    1
      ccv_nnc_tensor_free(a);
    153
    1
      ccv_nnc_tensor_free(b);
    154
    1
      ccv_nnc_tensor_free(indices);
    155
    1
    }
    156
    157
    TEST_CASE("sort a 1d tensor in int")
    158
    1
    {
    159
    1
      int ap[] = {
    160
    1
        1, 3, 2, 4, 5
    161
    1
      };
    162
    1
      ccv_nnc_tensor_t* const a = ccv_nnc_tensor_new(ap, CPU_TENSOR_NHWC(32S, 5), 0);
    163
    1
      ccv_nnc_tensor_t* const b = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 5), 0);
    164
    1
      ccv_nnc_tensor_t* const indices = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 5), 0);
    165
    1
      ccv_nnc_cmd_exec(CMD_SORT_FORWARD(0, 0), ccv_nnc_no_hint, 0, TENSOR_LIST(a), TENSOR_LIST(b, indices), 0);
    166
    1
      int btp[] = {
    167
    1
        1, 2, 3, 4, 5
    168
    1
      };
    169
    1
      ccv_nnc_tensor_t const bt = ccv_nnc_tensor(btp, CPU_TENSOR_NHWC(32S, 5), 0);
    170
    1
      REQUIRE_TENSOR_EQ(b, &bt, "should be equal");
    171
    1
      int indicestp[] = {
    172
    1
        0, 2, 1, 3, 4
    173
    1
      };
    174
    1
      ccv_nnc_tensor_t const indicest = ccv_nnc_tensor(indicestp, CPU_TENSOR_NHWC(32S, 5), 0);
    175
    1
      REQUIRE_TENSOR_EQ(indices, &indicest, "should be equal");
    176
    1
      ccv_nnc_tensor_free(a);
    177
    1
      ccv_nnc_tensor_free(b);
    178
    1
      ccv_nnc_tensor_free(indices);
    179
    1
    }
    180
    181
    TEST_CASE("sort a tensor by first axis, descending")
    182
    1
    {
    183
    1
      float ap[] = {
    184
    1
        1, 3,
    185
    1
        2, 5,
    186
    1
        3, 4,
    187
    1
      };
    188
    1
      ccv_nnc_tensor_t* const a = ccv_nnc_tensor_new(ap, CPU_TENSOR_NHWC(32F, 3, 2), 0);
    189
    1
      ccv_nnc_tensor_t* const b = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32F, 3, 2), 0);
    190
    1
      ccv_nnc_tensor_t* const indices = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    191
    1
      ccv_nnc_cmd_exec(CMD_SORT_FORWARD(0, 1), ccv_nnc_no_hint, 0, TENSOR_LIST(a), TENSOR_LIST(b, indices), 0);
    192
    1
      float btp[] = {
    193
    1
        3, 5,
    194
    1
        2, 4,
    195
    1
        1, 3,
    196
    1
      };
    197
    1
      ccv_nnc_tensor_t const bt = ccv_nnc_tensor(btp, CPU_TENSOR_NHWC(32F, 3, 2), 0);
    198
    1
      REQUIRE_TENSOR_EQ(b, &bt, "should be equal");
    199
    1
      int indicestp[] = {
    200
    1
        2, 1,
    201
    1
        1, 2,
    202
    1
        0, 0,
    203
    1
      };
    204
    1
      ccv_nnc_tensor_t const indicest = ccv_nnc_tensor(indicestp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    205
    1
      REQUIRE_TENSOR_EQ(indices, &indicest, "should be equal");
    206
    1
      ccv_nnc_tensor_free(a);
    207
    1
      ccv_nnc_tensor_free(b);
    208
    1
      ccv_nnc_tensor_free(indices);
    209
    1
    }
    210
    211
    TEST_CASE("sort a tensor by last axis, descending")
    212
    1
    {
    213
    1
      float ap[] = {
    214
    1
        1, 3,
    215
    1
        2, 1,
    216
    1
        3, 4,
    217
    1
      };
    218
    1
      ccv_nnc_tensor_t* const a = ccv_nnc_tensor_new(ap, CPU_TENSOR_NHWC(32F, 3, 2), 0);
    219
    1
      ccv_nnc_tensor_t* const b = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32F, 3, 2), 0);
    220
    1
      ccv_nnc_tensor_t* const indices = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    221
    1
      ccv_nnc_cmd_exec(CMD_SORT_FORWARD(1, 1), ccv_nnc_no_hint, 0, TENSOR_LIST(a), TENSOR_LIST(b, indices), 0);
    222
    1
      float btp[] = {
    223
    1
        3, 1,
    224
    1
        2, 1,
    225
    1
        4, 3,
    226
    1
      };
    227
    1
      ccv_nnc_tensor_t const bt = ccv_nnc_tensor(btp, CPU_TENSOR_NHWC(32F, 3, 2), 0);
    228
    1
      REQUIRE_TENSOR_EQ(b, &bt, "should be equal");
    229
    1
      int indicestp[] = {
    230
    1
        1, 0,
    231
    1
        0, 1,
    232
    1
        1, 0,
    233
    1
      };
    234
    1
      ccv_nnc_tensor_t const indicest = ccv_nnc_tensor(indicestp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    235
    1
      REQUIRE_TENSOR_EQ(indices, &indicest, "should be equal");
    236
    1
      ccv_nnc_tensor_free(a);
    237
    1
      ccv_nnc_tensor_free(b);
    238
    1
      ccv_nnc_tensor_free(indices);
    239
    1
    }
    240
    241
    TEST_CASE("sort a 1d tensor, descending")
    242
    1
    {
    243
    1
      float ap[] = {
    244
    1
        1, 3, 2, 4, 5
    245
    1
      };
    246
    1
      ccv_nnc_tensor_t* const a = ccv_nnc_tensor_new(ap, CPU_TENSOR_NHWC(32F, 5), 0);
    247
    1
      ccv_nnc_tensor_t* const b = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32F, 5), 0);
    248
    1
      ccv_nnc_tensor_t* const indices = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 5), 0);
    249
    1
      ccv_nnc_cmd_exec(CMD_SORT_FORWARD(0, 1), ccv_nnc_no_hint, 0, TENSOR_LIST(a), TENSOR_LIST(b, indices), 0);
    250
    1
      float btp[] = {
    251
    1
        5, 4, 3, 2, 1,
    252
    1
      };
    253
    1
      ccv_nnc_tensor_t const bt = ccv_nnc_tensor(btp, CPU_TENSOR_NHWC(32F, 5), 0);
    254
    1
      REQUIRE_TENSOR_EQ(b, &bt, "should be equal");
    255
    1
      int indicestp[] = {
    256
    1
        4, 3, 1, 2, 0,
    257
    1
      };
    258
    1
      ccv_nnc_tensor_t const indicest = ccv_nnc_tensor(indicestp, CPU_TENSOR_NHWC(32S, 5), 0);
    259
    1
      REQUIRE_TENSOR_EQ(indices, &indicest, "should be equal");
    260
    1
      ccv_nnc_tensor_free(a);
    261
    1
      ccv_nnc_tensor_free(b);
    262
    1
      ccv_nnc_tensor_free(indices);
    263
    1
    }
    264
    265
    TEST_CASE("sort a tensor by first axis in int, descending")
    266
    1
    {
    267
    1
      int ap[] = {
    268
    1
        1, 3,
    269
    1
        2, 5,
    270
    1
        3, 4,
    271
    1
      };
    272
    1
      ccv_nnc_tensor_t* const a = ccv_nnc_tensor_new(ap, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    273
    1
      ccv_nnc_tensor_t* const b = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    274
    1
      ccv_nnc_tensor_t* const indices = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    275
    1
      ccv_nnc_cmd_exec(CMD_SORT_FORWARD(0, 1), ccv_nnc_no_hint, 0, TENSOR_LIST(a), TENSOR_LIST(b, indices), 0);
    276
    1
      int btp[] = {
    277
    1
        3, 5,
    278
    1
        2, 4,
    279
    1
        1, 3,
    280
    1
      };
    281
    1
      ccv_nnc_tensor_t const bt = ccv_nnc_tensor(btp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    282
    1
      REQUIRE_TENSOR_EQ(b, &bt, "should be equal");
    283
    1
      int indicestp[] = {
    284
    1
        2, 1,
    285
    1
        1, 2,
    286
    1
        0, 0,
    287
    1
      };
    288
    1
      ccv_nnc_tensor_t const indicest = ccv_nnc_tensor(indicestp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    289
    1
      REQUIRE_TENSOR_EQ(indices, &indicest, "should be equal");
    290
    1
      ccv_nnc_tensor_free(a);
    291
    1
      ccv_nnc_tensor_free(b);
    292
    1
      ccv_nnc_tensor_free(indices);
    293
    1
    }
    294
    295
    TEST_CASE("sort a tensor by last axis in int, descending")
    296
    1
    {
    297
    1
      int ap[] = {
    298
    1
        1, 3,
    299
    1
        2, 1,
    300
    1
        3, 4,
    301
    1
      };
    302
    1
      ccv_nnc_tensor_t* const a = ccv_nnc_tensor_new(ap, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    303
    1
      ccv_nnc_tensor_t* const b = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    304
    1
      ccv_nnc_tensor_t* const indices = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    305
    1
      ccv_nnc_cmd_exec(CMD_SORT_FORWARD(1, 1), ccv_nnc_no_hint, 0, TENSOR_LIST(a), TENSOR_LIST(b, indices), 0);
    306
    1
      int btp[] = {
    307
    1
        3, 1,
    308
    1
        2, 1,
    309
    1
        4, 3,
    310
    1
      };
    311
    1
      ccv_nnc_tensor_t const bt = ccv_nnc_tensor(btp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    312
    1
      REQUIRE_TENSOR_EQ(b, &bt, "should be equal");
    313
    1
      int indicestp[] = {
    314
    1
        1, 0,
    315
    1
        0, 1,
    316
    1
        1, 0,
    317
    1
      };
    318
    1
      ccv_nnc_tensor_t const indicest = ccv_nnc_tensor(indicestp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    319
    1
      REQUIRE_TENSOR_EQ(indices, &indicest, "should be equal");
    320
    1
      ccv_nnc_tensor_free(a);
    321
    1
      ccv_nnc_tensor_free(b);
    322
    1
      ccv_nnc_tensor_free(indices);
    323
    1
    }
    324
    325
    TEST_CASE("sort a 1d tensor in int, descending")
    326
    1
    {
    327
    1
      int ap[] = {
    328
    1
        1, 3, 2, 4, 5
    329
    1
      };
    330
    1
      ccv_nnc_tensor_t* const a = ccv_nnc_tensor_new(ap, CPU_TENSOR_NHWC(32S, 5), 0);
    331
    1
      ccv_nnc_tensor_t* const b = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 5), 0);
    332
    1
      ccv_nnc_tensor_t* const indices = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 5), 0);
    333
    1
      ccv_nnc_cmd_exec(CMD_SORT_FORWARD(0, 1), ccv_nnc_no_hint, 0, TENSOR_LIST(a), TENSOR_LIST(b, indices), 0);
    334
    1
      int btp[] = {
    335
    1
        5, 4, 3, 2, 1,
    336
    1
      };
    337
    1
      ccv_nnc_tensor_t const bt = ccv_nnc_tensor(btp, CPU_TENSOR_NHWC(32S, 5), 0);
    338
    1
      REQUIRE_TENSOR_EQ(b, &bt, "should be equal");
    339
    1
      int indicestp[] = {
    340
    1
        4, 3, 1, 2, 0,
    341
    1
      };
    342
    1
      ccv_nnc_tensor_t const indicest = ccv_nnc_tensor(indicestp, CPU_TENSOR_NHWC(32S, 5), 0);
    343
    1
      REQUIRE_TENSOR_EQ(indices, &indicest, "should be equal");
    344
    1
      ccv_nnc_tensor_free(a);
    345
    1
      ccv_nnc_tensor_free(b);
    346
    1
      ccv_nnc_tensor_free(indices);
    347
    1
    }
    348
    349
    TEST_CASE("sort a tensor by last axis in int, descending with model")
    350
    1
    {
    351
    1
      int ap[] = {
    352
    1
        1, 3,
    353
    1
        2, 1,
    354
    1
        3, 4,
    355
    1
      };
    356
    1
      ccv_nnc_tensor_t* const a = ccv_nnc_tensor_new(ap, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    357
    1
      ccv_nnc_tensor_t* const b = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    358
    1
      ccv_nnc_tensor_t* const indices = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    359
    1
      ccv_cnnp_model_t* const sort = ccv_cnnp_sort(1, 1, "sort");
    360
    1
      ccv_cnnp_model_compile(sort, TENSOR_PARAM_LIST(a->info), CMD_NOOP(), CMD_NOOP());
    361
    1
      ccv_cnnp_model_evaluate(sort, (ccv_cnnp_evaluate_param_t){
    362
    1
        .requires_grad = 0,
    363
    1
      }, TENSOR_LIST(a), TENSOR_LIST(b, indices), 0, 0);
    364
    1
      int btp[] = {
    365
    1
        3, 1,
    366
    1
        2, 1,
    367
    1
        4, 3,
    368
    1
      };
    369
    1
      ccv_nnc_tensor_t const bt = ccv_nnc_tensor(btp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    370
    1
      REQUIRE_TENSOR_EQ(b, &bt, "should be equal");
    371
    1
      int indicestp[] = {
    372
    1
        1, 0,
    373
    1
        0, 1,
    374
    1
        1, 0,
    375
    1
      };
    376
    1
      ccv_nnc_tensor_t const indicest = ccv_nnc_tensor(indicestp, CPU_TENSOR_NHWC(32S, 3, 2), 0);
    377
    1
      REQUIRE_TENSOR_EQ(indices, &indicest, "should be equal");
    378
    1
      ccv_nnc_tensor_free(a);
    379
    1
      ccv_nnc_tensor_free(b);
    380
    1
      ccv_nnc_tensor_free(indices);
    381
    1
      ccv_cnnp_model_free(sort);
    382
    1
    }
    383
    384
    #include "case_main.h"