2020-04-24 23:36:52 +00:00
|
|
|
{ lib
|
2023-05-24 13:37:59 +00:00
|
|
|
, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, buildPythonPackage
|
2021-12-06 16:07:01 +00:00
|
|
|
, cmake
|
2023-02-16 17:41:37 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, gtest
|
2021-12-06 16:07:01 +00:00
|
|
|
, nbval
|
2020-04-24 23:36:52 +00:00
|
|
|
, numpy
|
2023-05-24 13:37:59 +00:00
|
|
|
, parameterized
|
2021-12-06 16:07:01 +00:00
|
|
|
, protobuf
|
2023-02-16 17:41:37 +00:00
|
|
|
, pybind11
|
2021-04-26 19:14:03 +00:00
|
|
|
, pytestCheckHook
|
2023-05-24 13:37:59 +00:00
|
|
|
, pythonOlder
|
2020-04-24 23:36:52 +00:00
|
|
|
, tabulate
|
2021-12-06 16:07:01 +00:00
|
|
|
, typing-extensions
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
let
|
|
|
|
gtestStatic = gtest.override { static = true; };
|
|
|
|
in buildPythonPackage rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "onnx";
|
2023-05-24 13:37:59 +00:00
|
|
|
version = "1.14.0";
|
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}";
|
2023-05-24 13:37:59 +00:00
|
|
|
hash = "sha256-f+s25Y/jGosaSdoZY6PE3j6pENkfDcD+IQndrbtuzWg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
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
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
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"
|
|
|
|
];
|
|
|
|
|
2023-02-16 17:41:37 +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"
|
2023-05-24 13:37:59 +00:00
|
|
|
] ++ lib.optionals stdenv.isAarch64 [
|
|
|
|
# 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-02-16 17:41:37 +00:00
|
|
|
];
|
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
|
|
|
|
'';
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"onnx"
|
|
|
|
];
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
}
|