File: onnx_converter_generator_test.cc

package info (click to toggle)
halide 21.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,752 kB
  • sloc: cpp: 289,334; ansic: 22,751; python: 7,486; makefile: 4,299; sh: 2,508; java: 1,549; javascript: 282; pascal: 207; xml: 127; asm: 9
file content (31 lines) | stat: -rw-r--r-- 851 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "HalideBuffer.h"
#include "HalideRuntime.h"
#include "test_model.h"
#include <iostream>
#include <random>

int main(int argc, char **argv) {
    std::cout << "Running onnx_converter_generator_test...\n";
    Halide::Runtime::Buffer<float, 2> A(3, 4);
    Halide::Runtime::Buffer<float, 2> B(3, 4);
    Halide::Runtime::Buffer<float, 2> C(3, 4);

    std::mt19937 rnd(123);
    A.for_each_value([&](float &v) {
        v = rnd();
    });
    B.for_each_value([&](float &v) {
        v = rnd();
    });
    test_model(A, B, C);
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 4; ++j) {
            if (C(i, j) != A(i, j) + B(i, j)) {
                std::cerr << "Unexpected value for inputs at (" << i << "," << j << ") \n";
                return -1;
            }
        }
    }
    std::cout << "Success!\n";
    return 0;
}