ONE - On-device Neural Engine
Loading...
Searching...
No Matches
TestUtil Namespace Reference

Functions

 assertTrue (cond, msg)
 
 checkPadding (pad, exp_pad)
 
 checkActivation (act, exp_act)
 
 checkOpcode (opcode, exp_opcode)
 
 checkBuiltinOptionType (option, exp_option)
 

Function Documentation

◆ assertTrue()

TestUtil.assertTrue (   cond,
  msg 
)

Definition at line 21 of file TestUtil.py.

21def assertTrue(cond, msg):
22 assert cond, msg
23
24

Referenced by checkActivation(), checkBuiltinOptionType(), checkOpcode(), and checkPadding().

◆ checkActivation()

TestUtil.checkActivation (   act,
  exp_act 
)

Definition at line 34 of file TestUtil.py.

34def checkActivation(act, exp_act):
35 act_functions = {
36 'relu': ActivationFunctionType.ActivationFunctionType.RELU,
37 'relu6': ActivationFunctionType.ActivationFunctionType.RELU6,
38 'relu_n1_to_1': ActivationFunctionType.ActivationFunctionType.RELU_N1_TO_1,
39 'tanh': ActivationFunctionType.ActivationFunctionType.TANH,
40 'none': ActivationFunctionType.ActivationFunctionType.NONE,
41 'sign_bit': ActivationFunctionType.ActivationFunctionType.SIGN_BIT,
42 }
43
44 try:
45 assertTrue(act_functions[act] == exp_act, "Activation function mismatches")
46 except KeyError:
47 raise SystemExit('Unsupported activation functions')
48
49

References assertTrue().

◆ checkBuiltinOptionType()

TestUtil.checkBuiltinOptionType (   option,
  exp_option 
)

Definition at line 55 of file TestUtil.py.

55def checkBuiltinOptionType(option, exp_option):
56 assertTrue(
57 option == exp_option,
58 "Built-in option type mismatches (" + str(option) + ", " + str(exp_option) + ")")

References assertTrue().

◆ checkOpcode()

TestUtil.checkOpcode (   opcode,
  exp_opcode 
)

Definition at line 50 of file TestUtil.py.

50def checkOpcode(opcode, exp_opcode):
51 assertTrue(opcode == exp_opcode,
52 "Opcode mismatches (" + str(opcode) + ", " + str(exp_opcode) + ")")
53
54

References assertTrue().

◆ checkPadding()

TestUtil.checkPadding (   pad,
  exp_pad 
)

Definition at line 25 of file TestUtil.py.

25def checkPadding(pad, exp_pad):
26 if pad == 'SAME':
27 assertTrue(exp_pad == Padding.Padding.SAME, "Padding mismatches")
28 elif pad == 'VALID':
29 assertTrue(exp_pad == Padding.Padding.VALID, "Padding mismatches")
30 else:
31 raise SystemExit('Unsupported padding')
32
33

References assertTrue().