".github/vscode:/vscode.git/clone" did not exist on "649489dc67d0122a0b30e6ff982c488540bc1c84"
generate.cpp 712 Bytes
Newer Older
Paul's avatar
Paul committed
1
#include <migraph/generate.hpp>
Paul's avatar
Paul committed
2

Paul's avatar
Paul committed
3
namespace migraph {
Paul's avatar
Paul committed
4

Paul's avatar
Paul committed
5
argument generate_argument(shape s, std::mt19937::result_type seed)
Paul's avatar
Paul committed
6
{
Paul's avatar
Paul committed
7
    argument result;
Paul's avatar
Paul committed
8
    s.visit_type([&](auto as) {
Paul's avatar
Paul committed
9
        using type = typename decltype(as)::type;
Paul's avatar
Paul committed
10
11
        auto v     = generate_tensor_data<type>(s, seed);
        result     = {s, [v]() mutable { return reinterpret_cast<char*>(v.data()); }};
Paul's avatar
Paul committed
12
13
14
15
    });
    return result;
}

Paul's avatar
Paul committed
16
17
18
19
20
21
22
23
24
25
26
literal generate_literal(shape s, std::mt19937::result_type seed)
{
    literal result;
    s.visit_type([&](auto as) {
        using type = typename decltype(as)::type;
        auto v     = generate_tensor_data<type>(s, seed);
        result     = {s, v};
    });
    return result;
}

Paul's avatar
Paul committed
27
} // namespace migraph