"docs/archive_en_US/Compression/Pruner.md" did not exist on "0b9d6ce6d1cf6515c5b553a61f78cd333bf4700f"
test_rsqrt.cpp 954 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11

#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/operators.hpp>

struct test_rsqrt : verify_program<test_rsqrt>
{
    migraphx::program create_program() const
    {
        migraphx::program p;
12
        auto* mm = p.get_main_module();
13
14
        std::vector<size_t> input_lens{1, 3, 16, 16};
        migraphx::shape s{migraphx::shape::float_type, input_lens};
15
16
17
18
19
20
21
        auto x       = mm->add_parameter("x", s);
        auto min_val = mm->add_literal(1.0f);
        auto max_val = mm->add_literal(std::numeric_limits<float>::max());
        min_val      = mm->add_instruction(migraphx::op::multibroadcast{input_lens}, min_val);
        max_val      = mm->add_instruction(migraphx::op::multibroadcast{input_lens}, max_val);
        auto l0      = mm->add_instruction(migraphx::op::clip{}, x, min_val, max_val);
        mm->add_instruction(migraphx::op::rsqrt{}, l0);
22
23
24
        return p;
    };
};