Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test failure: TypeError: EndVector() missing 1 required positional argument: 'vectorNumElems' #2047

Closed
buddhapuneeth opened this issue Sep 23, 2022 · 2 comments
Labels
bug An unexpected problem or unintended behavior

Comments

@buddhapuneeth
Copy link
Contributor

Describe the bug

Running the tf2onnx tests on TF 2.10 failing the below Unit test

tests/test_tflite_utils.py::TFListUtilsTests::test_parse_tflite_graph - TypeError: EndVector() missing 1 required positional argument: 'vectorNumElems'

Urgency

not a immediate blocker. But look for fix by 10/15.

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 18.04*): Cent OS, Kernel: Linux 5.4.207-126.363.amzn2int.x86_6
  • TensorFlow Version: 2.10 (installed from pip)
  • Python version: 3.8 (conda env)
  • ONNX version (if applicable, e.g. 1.11*):1.10.2
  • ONNXRuntime version (if applicable, e.g. 1.11*):

To Reproduce

Followed steps from https://github.com/onnx/tensorflow-onnx#build-and-install-latest-from-source-for-development
Then

python setup.py test

Screenshots

Additional context

tests/test_tflite_utils.py:50:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/user/anaconda3/envs/tf210_open_tf2onnx/lib/python3.8/site-packages/tensorflow/lite/python/lite.py:2808: in convert
    return super(TFLiteConverter, self).convert()
/home/user/anaconda3/envs/tf210_open_tf2onnx/lib/python3.8/site-packages/tensorflow/lite/python/lite.py:930: in wrapper
    return self._convert_and_export_metrics(convert_func, *args, **kwargs)
/home/user/anaconda3/envs/tf210_open_tf2onnx/lib/python3.8/site-packages/tensorflow/lite/python/lite.py:922: in _convert_and_export_metrics
    return flatbuffer_utils.convert_object_to_bytearray(model_object)
/home/user/anaconda3/envs/tf210_open_tf2onnx/lib/python3.8/site-packages/tensorflow/lite/tools/flatbuffer_utils.py:84: in convert_object_to_bytearray
    model_offset = model_object.Pack(builder)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tensorflow.lite.python.schema_py_generated.ModelT object at 0x7f94221d7c40>, builder = <flatbuffers.builder.Builder object at 0x7f94e1ff94a0>

    def Pack(self, builder):
        if self.operatorCodes is not None:
            operatorCodeslist = []
            for i in range(len(self.operatorCodes)):
                operatorCodeslist.append(self.operatorCodes[i].Pack(builder))
            ModelStartOperatorCodesVector(builder, len(self.operatorCodes))
            for i in reversed(range(len(self.operatorCodes))):
                builder.PrependUOffsetTRelative(operatorCodeslist[i])
>           operatorCodes = builder.EndVector()
E           TypeError: EndVector() missing 1 required positional argument: 'vectorNumElems'

@buddhapuneeth buddhapuneeth added the bug An unexpected problem or unintended behavior label Sep 23, 2022
@yan12125
Copy link
Contributor

That appears caused by old FlatBuffers.

  • FlatBuffers < 2.0: EndVector() requires an argument vectorNumElems
  • FlatBuffers 2.0.0 ~ 2.0.6: EndVector() accepts no argument [1]
  • FlatBuffers >= 2.0.7: EndVector() accepts optional vectorNumElems again, while it's deprecated [2]

From the error message, I assume you're using FlatBuffers < 2.0. On the other hand, TensorFlow 2.10 appears to use FlatBuffers >= 2.0. Installing newer FlatBuffers should fix the issue.

Note that current tensorflow-onnx pins FlatBuffers < 2.0 [3][4]. You will need to ignore that version constraint.

[1] google/flatbuffers#6328
[2] google/flatbuffers#7246
[3] #1841
[4] #1977

@buddhapuneeth
Copy link
Contributor Author

Yes, it worked after updating flatbuffers to 2.0.0 and relaxing the constraint on flatbuffers in setup.py. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants