Download lib/python3.9/site-packages/caffe2/python/mkl/mkl_conv_op_test.py from camenduru/slahmr-test: direct link, hf CLI and curl.
- Browser
- Download file 1.68 kB
-
https://huggingface.co/camenduru/slahmr-test/resolve/main/lib/python3.9/site-packages/caffe2/python/mkl/mkl_conv_op_test.py
- Command line
-
hf download hf://camenduru/slahmr-test/lib/python3.9/site-packages/caffe2/python/mkl/mkl_conv_op_test.py
-
curl -L -o mkl_conv_op_test.py https://huggingface.co/camenduru/slahmr-test/resolve/main/lib/python3.9/site-packages/caffe2/python/mkl/mkl_conv_op_test.py
1.68 kB
| import unittest | |
| import hypothesis.strategies as st | |
| from hypothesis import given | |
| import numpy as np | |
| from caffe2.python import core, workspace | |
| import caffe2.python.hypothesis_test_util as hu | |
| import caffe2.python.mkl_test_util as mu | |
| class MKLConvTest(hu.HypothesisTestCase): | |
| def test_mkl_convolution(self, stride, pad, kernel, size, | |
| input_channels, output_channels, | |
| batch_size, use_bias, group, gc, dc): | |
| op = core.CreateOperator( | |
| "Conv", | |
| ["X", "w", "b"] if use_bias else ["X", "w"], | |
| ["Y"], | |
| stride=stride, | |
| pad=pad, | |
| kernel=kernel, | |
| group=group | |
| ) | |
| X = np.random.rand( | |
| batch_size, input_channels * group, size, size).astype(np.float32) - 0.5 | |
| w = np.random.rand( | |
| output_channels * group, input_channels, kernel, kernel) \ | |
| .astype(np.float32) - 0.5 | |
| b = np.random.rand(output_channels * group).astype(np.float32) - 0.5 | |
| inputs = [X, w, b] if use_bias else [X, w] | |
| self.assertDeviceChecks(dc, op, inputs, [0]) | |
| if __name__ == "__main__": | |
| import unittest | |
| unittest.main() | |