2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
buildPythonPackage,
|
|
|
|
cmake,
|
|
|
|
fetchFromGitHub,
|
|
|
|
gtest,
|
|
|
|
nbval,
|
|
|
|
numpy,
|
|
|
|
parameterized,
|
|
|
|
protobuf_21,
|
|
|
|
pybind11,
|
|
|
|
pytestCheckHook,
|
|
|
|
pythonOlder,
|
|
|
|
tabulate,
|
|
|
|
typing-extensions,
|
|
|
|
abseil-cpp,
|
|
|
|
google-re2,
|
|
|
|
pillow,
|
|
|
|
protobuf,
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
let
|
|
|
|
gtestStatic = gtest.override { static = true; };
|
2024-06-05 15:53:02 +00:00
|
|
|
in
|
|
|
|
buildPythonPackage rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "onnx";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "1.16.2";
|
2021-12-06 16:07:01 +00:00
|
|
|
format = "setuptools";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
disabled = pythonOlder "3.8";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
|
|
|
rev = "refs/tags/v${version}";
|
2024-09-19 14:19:46 +00:00
|
|
|
hash = "sha256-JmxnsHRrzj2QzPz3Yndw0MmgZJ8MDYxHjuQ7PQkQsDg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
build-system = [
|
2021-12-06 16:07:01 +00:00
|
|
|
cmake
|
2023-02-16 17:41:37 +00:00
|
|
|
pybind11
|
2021-12-06 16:07:01 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
buildInputs = [
|
|
|
|
abseil-cpp
|
2024-01-25 14:12:00 +00:00
|
|
|
protobuf
|
|
|
|
google-re2
|
2024-07-27 06:49:29 +00:00
|
|
|
gtestStatic
|
2024-01-25 14:12:00 +00:00
|
|
|
pillow
|
2023-10-09 19:29:22 +00:00
|
|
|
];
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
dependencies = [
|
2024-01-25 14:12:00 +00:00
|
|
|
protobuf_21
|
2020-04-24 23:36:52 +00:00
|
|
|
protobuf
|
|
|
|
numpy
|
|
|
|
typing-extensions
|
2021-04-26 19:14:03 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2020-04-24 23:36:52 +00:00
|
|
|
nbval
|
2023-05-24 13:37:59 +00:00
|
|
|
parameterized
|
2021-12-06 16:07:01 +00:00
|
|
|
pytestCheckHook
|
2020-04-24 23:36:52 +00:00
|
|
|
tabulate
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
2021-03-20 04:20:00 +00:00
|
|
|
chmod +x tools/protoc-gen-mypy.sh.in
|
2023-02-09 11:40:11 +00:00
|
|
|
patchShebangs tools/protoc-gen-mypy.sh.in
|
2023-02-16 17:41:37 +00:00
|
|
|
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace 'setup_requires.append("pytest-runner")' ""
|
|
|
|
|
|
|
|
# prevent from fetching & building own gtest
|
|
|
|
substituteInPlace CMakeLists.txt \
|
|
|
|
--replace 'include(googletest)' ""
|
|
|
|
substituteInPlace cmake/unittest.cmake \
|
|
|
|
--replace 'googletest)' ')'
|
2023-02-09 11:40:11 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
preConfigure = ''
|
2023-02-16 17:41:37 +00:00
|
|
|
# Set CMAKE_INSTALL_LIBDIR to lib explicitly, because otherwise it gets set
|
|
|
|
# to lib64 and cmake incorrectly looks for the protobuf library in lib64
|
2023-02-09 11:40:11 +00:00
|
|
|
export CMAKE_ARGS="-DCMAKE_INSTALL_LIBDIR=lib -DONNX_USE_PROTOBUF_SHARED_LIBS=ON"
|
2023-02-16 17:41:37 +00:00
|
|
|
export CMAKE_ARGS+=" -Dgoogletest_STATIC_LIBRARIES=${gtestStatic}/lib/libgtest.a -Dgoogletest_INCLUDE_DIRS=${lib.getDev gtestStatic}/include"
|
|
|
|
export ONNX_BUILD_TESTS=1
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
preBuild = ''
|
|
|
|
export MAX_JOBS=$NIX_BUILD_CORES
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# The executables are just utility scripts that aren't too important
|
|
|
|
postInstall = ''
|
|
|
|
rm -r $out/bin
|
|
|
|
'';
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
# The setup.py does all the configuration
|
|
|
|
dontUseCmakeConfigure = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
preCheck = ''
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
|
|
|
|
# detecting source dir as a python package confuses pytest
|
|
|
|
mv onnx/__init__.py onnx/__init__.py.hidden
|
|
|
|
'';
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
pytestFlagsArray = [
|
|
|
|
"onnx/test"
|
|
|
|
"onnx/examples"
|
|
|
|
];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
disabledTests =
|
|
|
|
[
|
|
|
|
# attempts to fetch data from web
|
|
|
|
"test_bvlc_alexnet_cpu"
|
|
|
|
"test_densenet121_cpu"
|
|
|
|
"test_inception_v1_cpu"
|
|
|
|
"test_inception_v2_cpu"
|
|
|
|
"test_resnet50_cpu"
|
|
|
|
"test_shufflenet_cpu"
|
|
|
|
"test_squeezenet_cpu"
|
|
|
|
"test_vgg19_cpu"
|
|
|
|
"test_zfnet512_cpu"
|
|
|
|
]
|
2024-09-26 11:04:55 +00:00
|
|
|
++ lib.optionals stdenv.hostPlatform.isAarch64 [
|
2024-06-05 15:53:02 +00:00
|
|
|
# AssertionError: Output 0 of test 0 in folder
|
|
|
|
"test__pytorch_converted_Conv2d_depthwise_padded"
|
|
|
|
"test__pytorch_converted_Conv2d_dilated"
|
|
|
|
"test_dft"
|
|
|
|
"test_dft_axis"
|
|
|
|
# AssertionError: Mismatch in test 'test_Conv2d_depthwise_padded'
|
|
|
|
"test_xor_bcast4v4d"
|
|
|
|
# AssertionError: assert 1 == 0
|
|
|
|
"test_ops_tested"
|
|
|
|
];
|
2023-05-24 13:37:59 +00:00
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
disabledTestPaths = [
|
|
|
|
# Unexpected output fields from running code: {'stderr'}
|
|
|
|
"onnx/examples/np_array_tensorproto.ipynb"
|
|
|
|
];
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
__darwinAllowLocalNetworking = true;
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
postCheck = ''
|
|
|
|
# run "cpp" tests
|
|
|
|
.setuptools-cmake-build/onnx_gtests
|
|
|
|
'';
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
pythonImportsCheck = [ "onnx" ];
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Open Neural Network Exchange";
|
2022-01-03 16:56:52 +00:00
|
|
|
homepage = "https://onnx.ai";
|
2021-12-06 16:07:01 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ acairncross ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|