ONE - On-device Neural Engine
Loading...
Searching...
No Matches
SingleOperatorTest.SingleOperatorTest Class Reference
Collaboration diagram for SingleOperatorTest.SingleOperatorTest:

Public Member Functions

 StartAnalysis (self, args)
 
 DefaultOpPost (self, name, opcode, inputs, output)
 
 testConv2D (self, padding, stride, dilation, fused_act)
 
 Conv2DPre (self, name, input, filter, bias, padding, stride, dilation, fused_act)
 
 Conv2DPost (self, name, input, filter, bias, padding, stride, dilation, output, fused_act)
 
 testAdd (self, fused_act)
 
 AddPre (self, name, x, y, fused_act)
 
 AddPost (self, name, x, y, output, fused_act)
 
 testDepthwiseConv2D (self, padding, stride, depth_multiplier, dilation, fused_act)
 
 DepthwiseConv2DPre (self, name, input, filter, bias, padding, stride, depth_multiplier, dilation, fused_act)
 
 DepthwiseConv2DPost (self, name, input, filter, bias, padding, stride, depth_multiplier, dilation, output, fused_act)
 
 testFullyConnected (self, fused_act)
 
 FullyConnectedPre (self, name, input, weights, bias, fused_act)
 
 FullyConnectedPost (self, name, input, weights, bias, output, fused_act)
 
 testTransposeConv (self, padding, stride)
 
 TransposeConvPre (self, name, input, filter, output_shape, bias, padding, stride)
 
 TransposeConvPost (self, name, input, filter, output_shape, bias, padding, stride, output)
 
 testInstanceNorm (self, epsilon, fused_act)
 
 InstanceNormPre (self, name, input, gamma, beta, epsilon, fused_act)
 
 InstanceNormPost (self, name, input, gamma, beta, epsilon, output, fused_act)
 
 testSplit (self, num_split)
 
 SplitPre (self, name, split_dim, input, num_split)
 
 SplitPost (self, name, split_dim, input, num_split, outputs)
 

Protected Attributes

 _model
 
 _op
 
 _opt
 

Detailed Description

Definition at line 33 of file SingleOperatorTest.py.

Member Function Documentation

◆ AddPost()

SingleOperatorTest.SingleOperatorTest.AddPost (   self,
  name,
  x,
  y,
  output,
  fused_act 
)

Definition at line 94 of file SingleOperatorTest.py.

94 def AddPost(self, name, x, y, output, fused_act):
95 self.testAdd(fused_act)
96

◆ AddPre()

SingleOperatorTest.SingleOperatorTest.AddPre (   self,
  name,
  x,
  y,
  fused_act 
)

Definition at line 91 of file SingleOperatorTest.py.

91 def AddPre(self, name, x, y, fused_act):
92 self.testAdd(fused_act)
93

◆ Conv2DPost()

SingleOperatorTest.SingleOperatorTest.Conv2DPost (   self,
  name,
  input,
  filter,
  bias,
  padding,
  stride,
  dilation,
  output,
  fused_act 
)

Definition at line 73 of file SingleOperatorTest.py.

74 fused_act):
75 self.testConv2D(padding, stride, dilation, fused_act)
76

◆ Conv2DPre()

SingleOperatorTest.SingleOperatorTest.Conv2DPre (   self,
  name,
  input,
  filter,
  bias,
  padding,
  stride,
  dilation,
  fused_act 
)

Definition at line 70 of file SingleOperatorTest.py.

70 def Conv2DPre(self, name, input, filter, bias, padding, stride, dilation, fused_act):
71 self.testConv2D(padding, stride, dilation, fused_act)
72

◆ DefaultOpPost()

SingleOperatorTest.SingleOperatorTest.DefaultOpPost (   self,
  name,
  opcode,
  inputs,
  output 
)

Definition at line 48 of file SingleOperatorTest.py.

48 def DefaultOpPost(self, name, opcode, inputs, output):
49 raise SystemExit('NYI operator: ' + str(opcode))
50

◆ DepthwiseConv2DPost()

SingleOperatorTest.SingleOperatorTest.DepthwiseConv2DPost (   self,
  name,
  input,
  filter,
  bias,
  padding,
  stride,
  depth_multiplier,
  dilation,
  output,
  fused_act 
)

Definition at line 123 of file SingleOperatorTest.py.

124 depth_multiplier, dilation, output, fused_act):
125 self.testDepthwiseConv2D(padding, stride, depth_multiplier, dilation, fused_act)
126

◆ DepthwiseConv2DPre()

SingleOperatorTest.SingleOperatorTest.DepthwiseConv2DPre (   self,
  name,
  input,
  filter,
  bias,
  padding,
  stride,
  depth_multiplier,
  dilation,
  fused_act 
)

Definition at line 119 of file SingleOperatorTest.py.

120 depth_multiplier, dilation, fused_act):
121 self.testDepthwiseConv2D(padding, stride, depth_multiplier, dilation, fused_act)
122

◆ FullyConnectedPost()

SingleOperatorTest.SingleOperatorTest.FullyConnectedPost (   self,
  name,
  input,
  weights,
  bias,
  output,
  fused_act 
)

Definition at line 144 of file SingleOperatorTest.py.

144 def FullyConnectedPost(self, name, input, weights, bias, output, fused_act):
145 self.testFullyConnected(fused_act)
146

◆ FullyConnectedPre()

SingleOperatorTest.SingleOperatorTest.FullyConnectedPre (   self,
  name,
  input,
  weights,
  bias,
  fused_act 
)

Definition at line 141 of file SingleOperatorTest.py.

141 def FullyConnectedPre(self, name, input, weights, bias, fused_act):
142 self.testFullyConnected(fused_act)
143

◆ InstanceNormPost()

SingleOperatorTest.SingleOperatorTest.InstanceNormPost (   self,
  name,
  input,
  gamma,
  beta,
  epsilon,
  output,
  fused_act 
)

Definition at line 188 of file SingleOperatorTest.py.

188 def InstanceNormPost(self, name, input, gamma, beta, epsilon, output, fused_act):
189 self.testInstanceNorm(epsilon, fused_act)
190

◆ InstanceNormPre()

SingleOperatorTest.SingleOperatorTest.InstanceNormPre (   self,
  name,
  input,
  gamma,
  beta,
  epsilon,
  fused_act 
)

Definition at line 185 of file SingleOperatorTest.py.

185 def InstanceNormPre(self, name, input, gamma, beta, epsilon, fused_act):
186 self.testInstanceNorm(epsilon, fused_act)
187

◆ SplitPost()

SingleOperatorTest.SingleOperatorTest.SplitPost (   self,
  name,
  split_dim,
  input,
  num_split,
  outputs 
)

Definition at line 208 of file SingleOperatorTest.py.

208 def SplitPost(self, name, split_dim, input, num_split, outputs):
209 self.testSplit(num_split)
210 assertTrue(num_split == len(outputs), "num_split mismatches with outputs")

◆ SplitPre()

SingleOperatorTest.SingleOperatorTest.SplitPre (   self,
  name,
  split_dim,
  input,
  num_split 
)

Definition at line 205 of file SingleOperatorTest.py.

205 def SplitPre(self, name, split_dim, input, num_split):
206 self.testSplit(num_split)
207

◆ StartAnalysis()

SingleOperatorTest.SingleOperatorTest.StartAnalysis (   self,
  args 
)
Called when the analysis starts

Definition at line 34 of file SingleOperatorTest.py.

34 def StartAnalysis(self, args):
35 """Called when the analysis starts"""
36 with open(args, 'rb') as f:
37 buffer = f.read()
38 self._model = Model.Model.GetRootAsModel(buffer, 0)
39
40 # Check model has one subgraph
41 assertTrue(self._model.SubgraphsLength() == 1, "Model has more than one subgraph")
42 graph = self._model.Subgraphs(0)
43
44 # Check model has one operator
45 assertTrue(graph.OperatorsLength() == 1, "Model has more than one operator")
46 self._op = graph.Operators(0)
47

◆ testAdd()

SingleOperatorTest.SingleOperatorTest.testAdd (   self,
  fused_act 
)

Definition at line 77 of file SingleOperatorTest.py.

77 def testAdd(self, fused_act):
78 # Check opcode
79 opcode = self._model.OperatorCodes(self._op.OpcodeIndex())
80 checkOpcode(opcode.BuiltinCode(), BuiltinOperator.BuiltinOperator.ADD)
81
82 # Check option
83 checkBuiltinOptionType(self._op.BuiltinOptionsType(),
84 BuiltinOptions.BuiltinOptions.AddOptions)
85
86 self._opt = self._op.BuiltinOptions()
87 opt = AddOptions.AddOptions()
88 opt.Init(self._opt.Bytes, self._opt.Pos)
89 checkActivation(fused_act, opt.FusedActivationFunction())
90

◆ testConv2D()

SingleOperatorTest.SingleOperatorTest.testConv2D (   self,
  padding,
  stride,
  dilation,
  fused_act 
)

Definition at line 51 of file SingleOperatorTest.py.

51 def testConv2D(self, padding, stride, dilation, fused_act):
52 # Check opcode
53 opcode = self._model.OperatorCodes(self._op.OpcodeIndex())
54 checkOpcode(opcode.BuiltinCode(), BuiltinOperator.BuiltinOperator.CONV_2D)
55
56 # Check option
57 checkBuiltinOptionType(self._op.BuiltinOptionsType(),
58 BuiltinOptions.BuiltinOptions.Conv2DOptions)
59
60 self._opt = self._op.BuiltinOptions()
61 opt = Conv2DOptions.Conv2DOptions()
62 opt.Init(self._opt.Bytes, self._opt.Pos)
63 checkPadding(padding, opt.Padding())
64 assertTrue(opt.StrideW() == stride['w'], "Stride_w mismatches")
65 assertTrue(opt.StrideH() == stride['h'], "Stride_h mismatches")
66 assertTrue(opt.DilationWFactor() == dilation['w'], "Dilation_w mismatches")
67 assertTrue(opt.DilationHFactor() == dilation['h'], "Dilation_w mismatches")
68 checkActivation(fused_act, opt.FusedActivationFunction())
69

◆ testDepthwiseConv2D()

SingleOperatorTest.SingleOperatorTest.testDepthwiseConv2D (   self,
  padding,
  stride,
  depth_multiplier,
  dilation,
  fused_act 
)

Definition at line 97 of file SingleOperatorTest.py.

97 def testDepthwiseConv2D(self, padding, stride, depth_multiplier, dilation, fused_act):
98 # Check opcode
99 opcode = self._model.OperatorCodes(self._op.OpcodeIndex())
100 checkOpcode(opcode.BuiltinCode(),
101 BuiltinOperator.BuiltinOperator.DEPTHWISE_CONV_2D)
102
103 # Check option
104 checkBuiltinOptionType(self._op.BuiltinOptionsType(),
105 BuiltinOptions.BuiltinOptions.DepthwiseConv2DOptions)
106
107 self._opt = self._op.BuiltinOptions()
108 opt = DepthwiseConv2DOptions.DepthwiseConv2DOptions()
109 opt.Init(self._opt.Bytes, self._opt.Pos)
110 checkPadding(padding, opt.Padding())
111 assertTrue(opt.StrideW() == stride['w'], "Stride_w mismatches")
112 assertTrue(opt.StrideH() == stride['h'], "Stride_h mismatches")
113 assertTrue(opt.DepthMultiplier() == depth_multiplier,
114 "Depth multiplier mismatches")
115 assertTrue(opt.DilationWFactor() == dilation['w'], "Dilation_w mismatches")
116 assertTrue(opt.DilationHFactor() == dilation['h'], "Dilation_w mismatches")
117 checkActivation(fused_act, opt.FusedActivationFunction())
118

◆ testFullyConnected()

SingleOperatorTest.SingleOperatorTest.testFullyConnected (   self,
  fused_act 
)

Definition at line 127 of file SingleOperatorTest.py.

127 def testFullyConnected(self, fused_act):
128 # Check opcode
129 opcode = self._model.OperatorCodes(self._op.OpcodeIndex())
130 checkOpcode(opcode.BuiltinCode(), BuiltinOperator.BuiltinOperator.FULLY_CONNECTED)
131
132 # Check option
133 checkBuiltinOptionType(self._op.BuiltinOptionsType(),
134 BuiltinOptions.BuiltinOptions.FullyConnectedOptions)
135
136 self._opt = self._op.BuiltinOptions()
137 opt = FullyConnectedOptions.FullyConnectedOptions()
138 opt.Init(self._opt.Bytes, self._opt.Pos)
139 checkActivation(fused_act, opt.FusedActivationFunction())
140

◆ testInstanceNorm()

SingleOperatorTest.SingleOperatorTest.testInstanceNorm (   self,
  epsilon,
  fused_act 
)

Definition at line 170 of file SingleOperatorTest.py.

170 def testInstanceNorm(self, epsilon, fused_act):
171 # Check opcode
172 opcode = self._model.OperatorCodes(self._op.OpcodeIndex())
173 checkOpcode(opcode.BuiltinCode(), BuiltinOperator.BuiltinOperator.INSTANCE_NORM)
174
175 # Check option
176 checkBuiltinOptionType(self._op.BuiltinOptionsType(),
177 BuiltinOptions.BuiltinOptions.InstanceNormOptions)
178
179 self._opt = self._op.BuiltinOptions()
180 opt = InstanceNormOptions.InstanceNormOptions()
181 opt.Init(self._opt.Bytes, self._opt.Pos)
182 assertTrue(opt.Epsilon() == epsilon, "epsilon mismatches")
183 checkActivation(fused_act, opt.FusedActivationFunction())
184

◆ testSplit()

SingleOperatorTest.SingleOperatorTest.testSplit (   self,
  num_split 
)

Definition at line 191 of file SingleOperatorTest.py.

191 def testSplit(self, num_split):
192 # Check opcode
193 opcode = self._model.OperatorCodes(self._op.OpcodeIndex())
194 checkOpcode(opcode.BuiltinCode(), BuiltinOperator.BuiltinOperator.SPLIT)
195
196 # Check option
197 checkBuiltinOptionType(self._op.BuiltinOptionsType(),
198 BuiltinOptions.BuiltinOptions.SplitOptions)
199
200 self._opt = self._op.BuiltinOptions()
201 opt = SplitOptions.SplitOptions()
202 opt.Init(self._opt.Bytes, self._opt.Pos)
203 assertTrue(opt.NumSplits() == num_split, "num_split mismatches")
204

◆ testTransposeConv()

SingleOperatorTest.SingleOperatorTest.testTransposeConv (   self,
  padding,
  stride 
)

Definition at line 147 of file SingleOperatorTest.py.

147 def testTransposeConv(self, padding, stride):
148 # Check opcode
149 opcode = self._model.OperatorCodes(self._op.OpcodeIndex())
150 checkOpcode(opcode.BuiltinCode(), BuiltinOperator.BuiltinOperator.TRANSPOSE_CONV)
151
152 # Check option
153 checkBuiltinOptionType(self._op.BuiltinOptionsType(),
154 BuiltinOptions.BuiltinOptions.TransposeConvOptions)
155
156 self._opt = self._op.BuiltinOptions()
157 opt = TransposeConvOptions.TransposeConvOptions()
158 opt.Init(self._opt.Bytes, self._opt.Pos)
159 checkPadding(padding, opt.Padding())
160 assertTrue(opt.StrideW() == stride['w'], "Stride_w mismatches")
161 assertTrue(opt.StrideH() == stride['h'], "Stride_h mismatches")
162

◆ TransposeConvPost()

SingleOperatorTest.SingleOperatorTest.TransposeConvPost (   self,
  name,
  input,
  filter,
  output_shape,
  bias,
  padding,
  stride,
  output 
)

Definition at line 166 of file SingleOperatorTest.py.

167 output):
168 self.testTransposeConv(padding, stride)
169

◆ TransposeConvPre()

SingleOperatorTest.SingleOperatorTest.TransposeConvPre (   self,
  name,
  input,
  filter,
  output_shape,
  bias,
  padding,
  stride 
)

Definition at line 163 of file SingleOperatorTest.py.

163 def TransposeConvPre(self, name, input, filter, output_shape, bias, padding, stride):
164 self.testTransposeConv(padding, stride)
165

Field Documentation

◆ _model

◆ _op

SingleOperatorTest.SingleOperatorTest._op
protected

Definition at line 46 of file SingleOperatorTest.py.

◆ _opt

SingleOperatorTest.SingleOperatorTest._opt
protected

Definition at line 60 of file SingleOperatorTest.py.


The documentation for this class was generated from the following file: