4 The MKL test utils is a small addition on top of the hypothesis test utils 5 under caffe2/python, which allows one to more easily test MKL related 9 from __future__
import absolute_import
10 from __future__
import division
11 from __future__
import print_function
12 from __future__
import unicode_literals
14 import hypothesis.strategies
as st
16 from caffe2.proto
import caffe2_pb2
22 mkl_do = caffe2_pb2.DeviceOption(device_type=caffe2_pb2.MKLDNN)
23 device_options = hu.device_options + (
24 [mkl_do]
if workspace.C.has_mkldnn
else [])
27 def device_checker_device_options():
28 return st.just(device_options)
31 def gradient_checker_device_option():
32 return st.sampled_from(device_options)
36 gc=gradient_checker_device_option(),
37 dc=device_checker_device_options()
40 gcs_cpu_only = dict(gc=st.sampled_from([cpu_do]), dc=st.just([cpu_do]))
41 gcs_gpu_only = dict(gc=st.sampled_from([gpu_do]), dc=st.just([gpu_do]))
42 gcs_mkl_only = dict(gc=st.sampled_from([mkl_do]), dc=st.just([mkl_do]))
44 gcs_cpu_mkl = dict(gc=st.sampled_from([cpu_do, mkl_do]), dc=st.just([cpu_do, mkl_do]))