1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pytest-runner,
6 # runtime dependencies
7 numpy,
8 onnx,
9 requests,
10 six,
11 flatbuffers,
12 protobuf,
13 tensorflow,
14 # check dependencies
15 pytestCheckHook,
16 graphviz,
17 parameterized,
18 pytest-cov,
19 pyyaml,
20 timeout-decorator,
21 onnxruntime,
22 keras,
23}:
24
25buildPythonPackage rec {
26 pname = "tf2onnx";
27 version = "1.16.1";
28 format = "setuptools";
29
30 src = fetchFromGitHub {
31 owner = "onnx";
32 repo = "tensorflow-onnx";
33 rev = "refs/tags/v${version}";
34 hash = "sha256-qtRzckw/KHWm3gjFwF+cPuBhGbfktjhYIwImwHn2CFk=";
35 };
36
37 nativeBuildInputs = [
38 pytest-runner
39 ];
40
41 pythonRelaxDeps = [ "flatbuffers" ];
42
43 propagatedBuildInputs = [
44 numpy
45 onnx
46 requests
47 six
48 flatbuffers
49 protobuf
50 tensorflow
51 onnxruntime
52 ];
53
54 pythonImportsCheck = [ "tf2onnx" ];
55
56 nativeCheckInputs = [
57 pytestCheckHook
58 graphviz
59 parameterized
60 pytest-cov
61 pyyaml
62 timeout-decorator
63 keras
64 ];
65
66 # TODO investigate the failures
67 disabledTestPaths = [
68 "tests/test_backend.py"
69 "tests/test_einsum_helper.py"
70 "tests/test_einsum_optimizers.py"
71 ];
72
73 disabledTests = [ "test_profile_conversion_time" ];
74
75 meta = with lib; {
76 description = "Convert TensorFlow, Keras, Tensorflow.js and Tflite models to ONNX";
77 homepage = "https://github.com/onnx/tensorflow-onnx";
78 license = licenses.asl20;
79 maintainers = with maintainers; [ happysalada ];
80 # Duplicated `protobuf` in the derivation:
81 # - version 4.24.4 (from onnx), the default version of protobuf in nixpkgs
82 # - version 4.21.12 (from tensorflow), pinned as such because tensorflow is outdated and does
83 # not support more recent versions of protobuf
84 broken = true;
85 };
86}