Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
mlprodict
=========

.. image:: https://travis-ci.org/sdpython/mlprodict.svg?branch=master
:target: https://travis-ci.org/sdpython/mlprodict
.. image:: https://travis-ci.com/sdpython/mlprodict.svg?branch=master
:target: https://travis-ci.com/sdpython/mlprodict
:alt: Build status

.. image:: https://ci.appveyor.com/api/projects/status/g8chk1ufyk1m8uep?svg=true
Expand Down
7 changes: 2 additions & 5 deletions _doc/sphinxdoc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
import os
import alabaster
from pyquickhelper.helpgen.default_conf import set_sphinx_variables, get_default_stylesheet
from pyquickhelper.helpgen.default_conf import set_sphinx_variables
from sklearn.experimental import enable_hist_gradient_boosting
try:
from mlprodict.onnx_conv import register_converters, register_rewritten_operators
Expand Down Expand Up @@ -47,10 +47,7 @@
'generate_visual_graphs',
])

html_context = {
'css_files': get_default_stylesheet([
'_static/my-styles.css', '_static/gallery.css']),
}
html_css_files = ['my-styles.css']

html_logo = "phdoc_static/project_ico.png"

Expand Down
4 changes: 2 additions & 2 deletions _doc/sphinxdoc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ mlprodict
:ref:`l-README`,
:ref:`blog <ap-main-0>`

.. image:: https://travis-ci.org/sdpython/mlprodict.svg?branch=master
:target: https://travis-ci.org/sdpython/mlprodict
.. image:: https://travis-ci.com/sdpython/mlprodict.svg?branch=master
:target: https://travis-ci.com/sdpython/mlprodict
:alt: Build status

.. image:: https://ci.appveyor.com/api/projects/status/g8chk1ufyk1m8uep?svg=true
Expand Down
51 changes: 49 additions & 2 deletions _unittests/ut_onnxrt/test_onnxrt_python_runtime_.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
OnnxNeg, OnnxNot,
OnnxOr,
OnnxPad, OnnxPow,
OnnxQuantizeLinear,
OnnxQLinearConv, OnnxQuantizeLinear,
OnnxReciprocal,
OnnxReduceL1, OnnxReduceL2,
OnnxReduceLogSumExp, OnnxReduceMax, OnnxReduceMean, OnnxReduceMin,
Expand Down Expand Up @@ -2252,6 +2252,53 @@ def test_onnxt_runtime_pad2(self):
def test_onnxt_runtime_pow(self):
self.common_test_onnxt_runtime_binary(OnnxPow, numpy.power)

@wraplog()
def test_onnxt_runtime_qlinear_conv(self):
x = numpy.array(
[[255, 174, 162, 25, 203, 168, 58],
[15, 59, 237, 95, 129, 0, 64],
[56, 242, 153, 221, 168, 12, 166],
[232, 178, 186, 195, 237, 162, 237],
[188, 39, 124, 77, 80, 102, 43],
[127, 230, 21, 83, 41, 40, 134],
[255, 154, 92, 141, 42, 148, 247], ],
dtype=numpy.uint8).reshape((1, 1, 7, 7))

x_scale = numpy.float32(0.00369204697)
x_zero_point = numpy.uint8(132)

w = numpy.array([0], dtype=numpy.uint8).reshape((1, 1, 1, 1))

w_scale = numpy.array([0.00172794575], dtype=numpy.float32)
w_zero_point = numpy.array([255], dtype=numpy.uint8)

y_scale = numpy.float32(0.00162681262)
y_zero_point = numpy.uint8(123)

output = numpy.array(
[[0, 81, 93, 230, 52, 87, 197],
[240, 196, 18, 160, 126, 255, 191],
[199, 13, 102, 34, 87, 243, 89],
[23, 77, 69, 60, 18, 93, 18],
[67, 216, 131, 178, 175, 153, 212],
[128, 25, 234, 172, 214, 215, 121],
[0, 101, 163, 114, 213, 107, 8], ],
dtype=numpy.uint8).reshape((1, 1, 7, 7))

node = OnnxQLinearConv('x', 'x_scale', 'x_zero_point', 'w',
'w_scale', 'w_zero_point', 'y_scale',
'y_zero_point', output_names=['y'],
op_version=get_opset_number_from_onnx())
inputs = {'x': x, 'x_scale': x_scale, 'x_zero_point': x_zero_point,
'w': w, 'w_scale': w_scale, 'w_zero_point': w_zero_point,
'y_scale': y_scale, 'y_zero_point': y_zero_point}
model_def = node.to_onnx(inputs,
target_opset=get_opset_number_from_onnx())
oinf = OnnxInference(model_def)
got = oinf.run(inputs)['y']
self.assertEqualArray(output, got)
python_tested.append(OnnxQLinearConv)

@wraplog()
def test_onnxt_runtime_quantize_linear(self):
X = numpy.array([[[[-162, 10], [-100, 232], [-20, -50]],
Expand Down Expand Up @@ -3507,5 +3554,5 @@ def test_make_constant(self):


if __name__ == "__main__":
# TestOnnxrtPythonRuntime().test_onnxt_runtime_cast_in()
# TestOnnxrtPythonRuntime().test_onnxt_runtime_qlinear_conv()
unittest.main()
59 changes: 59 additions & 0 deletions bin/debug/debug.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// debug.cpp : Ce fichier contient la fonction 'main'. L'exécution du programme commence et se termine à cet endroit.
//

#include "op_qlinear_conv_.hpp"


void test_qlinear_conv() {
QLinearConv<uint8_t> conv;

const std::string auto_pad = "NOTSET";
py_array_t<int64_t> dilations;
py_array_t<int64_t> kernel_shape;
py_array_t<int64_t> pads;
py_array_t<int64_t> strides;

conv.init(auto_pad, dilations, 1, kernel_shape, pads, strides);

py_array_t<uint8_t> x({
255, 174, 162, 25, 203, 168, 58,
15, 59, 237, 95, 129, 0, 64,
56, 242, 153, 221, 168, 12, 166,
232, 178, 186, 195, 237, 162, 237,
188, 39, 124, 77, 80, 102, 43,
127, 230, 21, 83, 41, 40, 134,
255, 154, 92, 141, 42, 148, 247 },
{ 1, 1, 7, 7 });

float x_scale = (float)0.00369204697;
uint8_t x_zero_point = 132;

py_array_t<uint8_t> w({ 0 }, { 1, 1, 1, 1 });

py_array_t<float> w_scale({ (float)0.00172794575 }, {});
uint8_t w_zero_point = 255;

float y_scale = (float)0.00162681262;
uint8_t y_zero_point = 123;

py_array_t<uint8_t> B;

py_array_t<uint8_t> output({
0, 81, 93, 230, 52, 87, 197,
240, 196, 18, 160, 126, 255, 191,
199, 13, 102, 34, 87, 243, 89,
23, 77, 69, 60, 18, 93, 18,
67, 216, 131, 178, 175, 153, 212,
128, 25, 234, 172, 214, 215, 121,
0, 101, 163, 114, 213, 107, 8 },
{ 1, 1, 7, 7 });
py_array_t < uint8_t> res = conv.compute(
x, x_scale, x_zero_point, w, w_scale, w_zero_point, y_scale, y_zero_point, B);
if (!res.equal(output))
throw std::runtime_error("failed");
}


int main() {
test_qlinear_conv();
}
31 changes: 31 additions & 0 deletions bin/debug/debug.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31321.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "debug", "debug.vcxproj", "{714F6D8B-15D6-4E4E-940C-CC1AFA599EF1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{714F6D8B-15D6-4E4E-940C-CC1AFA599EF1}.Debug|x64.ActiveCfg = Debug|x64
{714F6D8B-15D6-4E4E-940C-CC1AFA599EF1}.Debug|x64.Build.0 = Debug|x64
{714F6D8B-15D6-4E4E-940C-CC1AFA599EF1}.Debug|x86.ActiveCfg = Debug|Win32
{714F6D8B-15D6-4E4E-940C-CC1AFA599EF1}.Debug|x86.Build.0 = Debug|Win32
{714F6D8B-15D6-4E4E-940C-CC1AFA599EF1}.Release|x64.ActiveCfg = Release|x64
{714F6D8B-15D6-4E4E-940C-CC1AFA599EF1}.Release|x64.Build.0 = Release|x64
{714F6D8B-15D6-4E4E-940C-CC1AFA599EF1}.Release|x86.ActiveCfg = Release|Win32
{714F6D8B-15D6-4E4E-940C-CC1AFA599EF1}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CC1B1913-0A0E-45AE-827F-C6D97913A40D}
EndGlobalSection
EndGlobal
154 changes: 154 additions & 0 deletions bin/debug/debug.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{714f6d8b-15d6-4e4e-940c-cc1afa599ef1}</ProjectGuid>
<RootNamespace>debug</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);SKIP_PYTHON</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>../../mlprodict/onnxrt/ops_cpu</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions);SKIP_PYTHON</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="debug.cpp" />
<ClCompile Include="../../mlprodict/onnxrt/ops_cpu/op_qlinear_conv_.cpp" />
<ClCompile Include="../../mlprodict/onnxrt/ops_cpu/op_qlinear_conv_.hpp" />
<ClCompile Include="../../mlprodict/onnxrt/ops_cpu/op_conv_matrices_.cpp" />
<ClCompile Include="../../mlprodict/onnxrt/ops_cpu/op_conv_matrices_.hpp" />
<ClCompile Include="../../mlprodict/onnxrt/ops_cpu/op_common_.cpp" />
<ClCompile Include="../../mlprodict/onnxrt/ops_cpu/op_common_.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
1 change: 1 addition & 0 deletions mlprodict/onnxrt/ops_cpu/_op_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
from .op_pad import Pad
from .op_pow import Pow
from .op_quantize_linear import QuantizeLinear
from .op_qlinear_conv import QLinearConv
from .op_reciprocal import Reciprocal
from .op_reduce_log_sum_exp import ReduceLogSumExp
from .op_reduce_l1 import ReduceL1
Expand Down
Loading