Caffe2 - Python API
A deep learning, cross platform ML framework
ideep_test_util.py
1 ## @package ideep_test_util
2 # Module caffe2.python.ideep_test_util
3 """
4 The IDEEP test utils is a small addition on top of the hypothesis test utils
5 under caffe2/python, which allows one to more easily test IDEEP related
6 operators.
7 """
8 
9 from __future__ import absolute_import
10 from __future__ import division
11 from __future__ import print_function
12 from __future__ import unicode_literals
13 
14 import hypothesis.strategies as st
15 
16 from caffe2.proto import caffe2_pb2
17 from caffe2.python import workspace
18 from caffe2.python import hypothesis_test_util as hu
19 
20 cpu_do = hu.cpu_do
21 ideep_do = caffe2_pb2.DeviceOption(device_type=caffe2_pb2.IDEEP)
22 device_options = hu.device_options + ([ideep_do])
23 
24 
25 def device_checker_device_options():
26  return st.just(device_options)
27 
28 
29 def gradient_checker_device_option():
30  return st.sampled_from(device_options)
31 
32 
33 gcs = dict(
34  gc=gradient_checker_device_option(),
35  dc=device_checker_device_options()
36 )
37 
38 gcs_cpu_only = dict(gc=st.sampled_from([cpu_do]), dc=st.just([cpu_do]))
39 gcs_ideep_only = dict(gc=st.sampled_from([ideep_do]), dc=st.just([ideep_do]))
40 gcs_cpu_ideep = dict(gc=st.sampled_from([cpu_do, ideep_do]), dc=st.just([cpu_do, ideep_do]))