Coverage for mlprodict/asv_benchmark/template/skl_model_trainable_transform.py: 100%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2A template to benchmark a model
3with :epkg:`asv`. The benchmark can be run through
4file :epkg:`run_asv.sh` on Linux or :epkg:`run_asv.bat` on
5Windows.
7.. warning::
8 On Windows, you should avoid cloning the repository
9 on a folder with a long full name. Visual Studio tends to
10 abide by the rule of the maximum path length even though
11 the system is told otherwise.
12"""
13import numpy # pylint: disable=W0611
14from mlprodict import __max_supported_opset__
15# Import specific to this model.
16from sklearn.cross_decomposition import PLSCanonical # pylint: disable=C0411
18from mlprodict.asv_benchmark import _CommonAsvSklBenchmarkTrainableTransform # pylint: disable=C0412
19from mlprodict.onnx_conv import to_onnx # pylint: disable=W0611, C0412
20from mlprodict.onnxrt import OnnxInference # pylint: disable=W0611, C0412
23class TemplateBenchmarkTrainableTransform(_CommonAsvSklBenchmarkTrainableTransform):
24 """
25 :epkg:`asv` example for a trainable transform,
26 Full template can be found in
27 `common_asv_skl.py <https://github.com/sdpython/mlprodict/
28 blob/master/mlprodict/asv_benchmark/common_asv_skl.py>`_.
29 """
30 params = [
31 ['skl', 'pyrtc', 'ort'], # values for runtime
32 [1, 10, 100, 1000, 10000], # values for N
33 [4, 20], # values for nf
34 [__max_supported_opset__], # values for opset
35 ['float', 'double'], # values for dtype
36 [None], # values for optim
37 ]
39 # additional parameters
41 def setup_cache(self): # pylint: disable=W0235
42 super().setup_cache()
44 def _create_model(self):
45 return PLSCanonical(n_components=1)