ArmNN
 21.08
Clip.cpp File Reference

Go to the source code of this file.

Functions

 TEST_SUITE ("OnnxParser_Clip")
 

Function Documentation

◆ TEST_SUITE()

TEST_SUITE ( "OnnxParser_Clip"  )

Definition at line 9 of file Clip.cpp.

References ParserPrototxtFixture< TParser >::Setup(), and TEST_CASE_FIXTURE().

10 {
11 struct ClipMainFixture : public armnnUtils::ParserPrototxtFixture<armnnOnnxParser::IOnnxParser>
12 {
13  ClipMainFixture(std::string min, std::string max)
14  {
15  m_Prototext = R"(
16  ir_version: 3
17  producer_name: "CNTK"
18  producer_version: "2.5.1"
19  domain: "ai.cntk"
20  model_version: 1
21  graph {
22  name: "CNTKGraph"
23  input {
24  name: "Input"
25  type {
26  tensor_type {
27  elem_type: 1
28  shape {
29  dim {
30  dim_value: 5
31  }
32  }
33  }
34  }
35  }
36  node {
37  input: "Input"
38  input:")" + min + R"("
39  input:")" + max + R"("
40  output: "Output"
41  name: "ActivationLayer"
42  op_type: "Clip"
43  }
44  output {
45  name: "Output"
46  type {
47  tensor_type {
48  elem_type: 1
49  shape {
50  dim {
51  dim_value: 5
52  }
53  }
54  }
55  }
56  }
57  }
58  opset_import {
59  version: 7
60  })";
61  Setup();
62  }
63 };
64 
65 struct ClipFixture : ClipMainFixture
66 {
67  ClipFixture() : ClipMainFixture("2", "3.5") {}
68 };
69 
70 TEST_CASE_FIXTURE(ClipFixture, "ValidClipTest")
71 {
72  RunTest<1>({{"Input", { -1.5f, 1.25f, 3.5f, 8.0, 2.5}}},
73  {{ "Output", { 2.0f, 2.0f, 3.5f, 3.5, 2.5}}});
74 }
75 
76 struct ClipNoMaxInputFixture : ClipMainFixture
77 {
78  ClipNoMaxInputFixture() : ClipMainFixture("0", std::string()) {}
79 };
80 
81 TEST_CASE_FIXTURE(ClipNoMaxInputFixture, "ValidNoMaxInputClipTest")
82 {
83  RunTest<1>({{"Input", { -1.5f, -5.25f, -0.5f, 8.0f, std::numeric_limits<float>::max() }}},
84  {{ "Output", { 0.0f, 0.0f, 0.0f, 8.0f, std::numeric_limits<float>::max() }}});
85 }
86 
87 struct ClipNoMinInputFixture : ClipMainFixture
88 {
89  ClipNoMinInputFixture() : ClipMainFixture(std::string(), "6") {}
90 };
91 
92 TEST_CASE_FIXTURE(ClipNoMinInputFixture, "ValidNoMinInputClipTest")
93 {
94  RunTest<1>({{"Input", { std::numeric_limits<float>::lowest(), -5.25f, -0.5f, 8.0f, 200.0f }}},
95  {{ "Output", { std::numeric_limits<float>::lowest(), -5.25f, -0.5f, 6.0f, 6.0f }}});
96 }
97 
98 struct ClipNoInputFixture : ClipMainFixture
99 {
100  ClipNoInputFixture() : ClipMainFixture(std::string(), std::string()) {}
101 };
102 
103 TEST_CASE_FIXTURE(ClipNoInputFixture, "ValidNoInputClipTest")
104 {
105  RunTest<1>({{"Input", { std::numeric_limits<float>::lowest(), -1.25f, 3.5f, 8.0f,
106  std::numeric_limits<float>::max()}}},
107  {{ "Output", { std::numeric_limits<float>::lowest(), -1.25f, 3.5f, 8.0f,
108  std::numeric_limits<float>::max()}}});
109 }
110 
111 }
TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu")