Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
fix unit test on mac osx, update clip operator, update history
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Dec 13, 2019
1 parent bd4f4ec commit 401753d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
9 changes: 5 additions & 4 deletions HISTORY.rst
Expand Up @@ -5,18 +5,19 @@
History
=======

current - 2019-12-08 - 0.00Mb
current - 2019-12-13 - 0.00Mb
=============================

* `87`: Add converter for HistGradientBoostRegressor (2019-12-09)
* `85`: Implements a precompiled run method in OnnxInference (runtime='python_compiled') (2019-12-07)
* `84`: Automatically creates files to profile time_predict function in the benchmark with py-spy (2019-12-04)
* `82`: Function translate_fct2onnx: use of opset_version (2019-12-04)
* `83`: ONNX: includes experimental operators in the benchmark (2019-12-04)
* `82`: Function translate_fct2onnx: use of opset_version (2019-12-04)
* `81`: ONNX benchmark: track_score returns scores equal to 0 or 1 (unexpected) (2019-12-04)
* `77`: Improves ONNX benchmark to measure zipmap impact. (2019-12-03)
* `80`: ONNX: extend benchmark to decision_function for some models (2019-12-03)
* `75`: ONNX: fix random_state whevever it is available when running benchmark (2019-11-27)
* `77`: Improves ONNX benchmark to measure zipmap impact. (2019-12-03)
* `76`: Implements ArgMax 12, ArgMax 12 (python onnx runtime) (2019-11-27)
* `75`: ONNX: fix random_state whevever it is available when running benchmark (2019-11-27)

0.3.765 - 2019-11-21 - 0.22Mb
=============================
Expand Down
21 changes: 6 additions & 15 deletions _unittests/ut_onnxrt/test_onnxrt_python_runtime_ml_svm.py
Expand Up @@ -3,7 +3,6 @@
"""
import unittest
from logging import getLogger
import platform
import warnings
import numpy
import sklearn
Expand Down Expand Up @@ -36,25 +35,17 @@ def test_openmp_compilation_float(self):
from mlprodict.onnxrt.ops_cpu.op_svm_regressor_ import RuntimeSVMRegressorFloat # pylint: disable=E0611
ru = RuntimeSVMRegressorFloat()
r = ru.runtime_options()
if platform.system().lower() == 'darwin':
# openmp disabled
self.assertEqual('', r)
else:
self.assertEqual('OPENMP', r)
nb = ru.omp_get_max_threads()
self.assertGreater(nb, 0)
self.assertEqual('OPENMP', r)
nb = ru.omp_get_max_threads()
self.assertGreater(nb, 0)

def test_openmp_compilation_double(self):
from mlprodict.onnxrt.ops_cpu.op_svm_regressor_ import RuntimeSVMRegressorDouble # pylint: disable=E0611
ru = RuntimeSVMRegressorDouble()
r = ru.runtime_options()
if platform.system().lower() == 'darwin':
# openmp disabled
self.assertEqual('', r)
else:
self.assertEqual('OPENMP', r)
nb = ru.omp_get_max_threads()
self.assertGreater(nb, 0)
self.assertEqual('OPENMP', r)
nb = ru.omp_get_max_threads()
self.assertGreater(nb, 0)

@ignore_warnings(category=(UserWarning, ConvergenceWarning, RuntimeWarning))
def test_onnxrt_python_SVR(self):
Expand Down
8 changes: 5 additions & 3 deletions _unittests/ut_onnxrt/test_onnxrt_python_runtime_ml_tree_rf.py
Expand Up @@ -81,8 +81,9 @@ def onnxrt_python_RandomForestRegressor_dtype(
def test_onnxrt_python_RandomForestRegressor32(self):
self.onnxrt_python_RandomForestRegressor_dtype(numpy.float32)

@ignore_warnings(category=(UserWarning, RuntimeWarning, DeprecationWarning))
@skipif_circleci('too long')
@skipif_appveyor("issue with opset 11")
@ignore_warnings(category=(UserWarning, RuntimeWarning, DeprecationWarning))
def test_onnxrt_python_RandomForestRegressor64(self):
self.onnxrt_python_RandomForestRegressor_dtype(numpy.float64)

Expand All @@ -91,15 +92,16 @@ def test_onnxrt_python_HistGradientBoostingRegressor32_hist(self):
self.onnxrt_python_RandomForestRegressor_dtype(
numpy.float32, use_hist=True)

@ignore_warnings(category=(UserWarning, RuntimeWarning, DeprecationWarning))
@skipif_circleci('too long')
@skipif_appveyor("issue with opset 11")
@ignore_warnings(category=(UserWarning, RuntimeWarning, DeprecationWarning))
def test_onnxrt_python_HistGradientBoostingRegressor64_hist(self):
self.onnxrt_python_RandomForestRegressor_dtype(
numpy.float64, use_hist=True)

@ignore_warnings(category=(UserWarning, RuntimeWarning, DeprecationWarning))
@skipif_appveyor("issue with opset 11")
@skipif_circleci('too long')
@ignore_warnings(category=(UserWarning, RuntimeWarning, DeprecationWarning))
def test_onnxrt_python_HistGradientBoostingRegressor64_hist_compiled(self):
self.onnxrt_python_RandomForestRegressor_dtype(
numpy.float64, use_hist=True, runtime="python_compiled")
Expand Down
17 changes: 12 additions & 5 deletions mlprodict/onnxrt/ops_cpu/op_clip.py
Expand Up @@ -60,14 +60,21 @@ def run(self, x, *minmax): # pylint: disable=E0202,W0221
return res

def _run(self, data, *minmax): # pylint: disable=W0221
amin = minmax[0] if len(minmax) > 0 else -3.4028234663852886e+38
amax = minmax[1] if len(minmax) > 1 else 3.4028234663852886e+38
if self.inplaces.get(0, False):
res = numpy.clip(data, amin, amax, out=data)
else:
res = numpy.clip(data, amin, amax)
return self._run_inplace(data, *minmax)
le = len(minmax)
amin = minmax[0] if le > 0 else None # -3.4028234663852886e+38
amax = minmax[1] if le > 1 else None # 3.4028234663852886e+38
res = numpy.clip(data, amin, amax)
return (res, ) if res.dtype == data.dtype else (res.astype(data.dtype), )

def _run_inplace(self, data, *minmax): # pylint: disable=W0221
le = len(minmax)
amin = minmax[0] if le > 0 else None # -3.4028234663852886e+38
amax = minmax[1] if le > 1 else None # 3.4028234663852886e+38
res = numpy.clip(data, amin, amax, out=data)
return (res, )

def infer_shapes(self, x, *minmax): # pylint: disable=E0202,W0221
try:
return self._infer_shapes(x)
Expand Down

0 comments on commit 401753d

Please sign in to comment.