tvm icon indicating copy to clipboard operation
tvm copied to clipboard

[WIP][Pylint] Making frontend tests pylint compliant

Open blackkker opened this issue 2 years ago • 9 comments

Fix pylint issues in https://github.com/apache/tvm/issues/11414 List of files to complete:

  • [x] tests/python/frontend/caffe/test_forward.py
  • [x] tests/python/frontend/caffe2/model_zoo/init.py
  • [x] tests/python/frontend/caffe2/test_forward.py
  • [x] tests/python/frontend/coreml/model_zoo/init.py
  • [x] tests/python/frontend/coreml/test_forward.py
  • [x] tests/python/frontend/darknet/test_forward.py
  • [x] tests/python/frontend/keras/test_forward.py
  • [ ] tests/python/frontend/mxnet/model_zoo/init.py
  • [ ] tests/python/frontend/mxnet/model_zoo/dqn.py
  • [ ] tests/python/frontend/mxnet/model_zoo/inception_v3.py
  • [ ] tests/python/frontend/mxnet/model_zoo/mlp.py
  • [ ] tests/python/frontend/mxnet/model_zoo/resnet.py
  • [ ] tests/python/frontend/mxnet/model_zoo/squeezenet.py
  • [ ] tests/python/frontend/mxnet/model_zoo/vgg.py
  • [ ] tests/python/frontend/mxnet/test_forward.py
  • [ ] tests/python/frontend/mxnet/test_graph.py
  • [ ] tests/python/frontend/mxnet/test_qnn_ops_utils.py
  • [x] tests/python/frontend/oneflow/test_forward.py
  • [x] tests/python/frontend/oneflow/test_vision_models.py
  • [x] tests/python/frontend/onnx/test_forward.py
  • [ ] tests/python/frontend/paddlepaddle/test_forward.py
  • [ ] tests/python/frontend/pytorch/qnn_test.py
  • [x] tests/python/frontend/pytorch/test_forward.py
  • [ ] tests/python/frontend/pytorch/test_fx_quant.py
  • [ ] tests/python/frontend/pytorch/test_lstm.py
  • [ ] tests/python/frontend/pytorch/test_object_detection.py
  • [ ] tests/python/frontend/pytorch/test_rnns.py
  • [ ] tests/python/frontend/tensorflow/test_bn_dynamic.py
  • [ ] tests/python/frontend/tensorflow/test_control_flow.py
  • [ ] tests/python/frontend/tensorflow/test_debugging.py
  • [x] tests/python/frontend/tensorflow/test_forward.py
  • [ ] tests/python/frontend/tensorflow/test_no_op.py
  • [ ] tests/python/frontend/tensorflow2/common.py
  • [ ] tests/python/frontend/tensorflow2/test_functional_models.py
  • [ ] tests/python/frontend/tensorflow2/test_sequential_models.py
  • [ ] tests/python/frontend/test_common.py
  • [x] tests/python/frontend/tflite/test_forward.py

Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.

blackkker avatar Jul 07 '22 08:07 blackkker

I have some minor suggestions but all in all this look good. Especially the conditions "!= None" should be changed to "is not None" in my opinion however.

LGTM! Thanks for your advice.

blackkker avatar Jul 07 '22 10:07 blackkker

@areusch basically completed, there are still a few questions that need to be confirmed with you.

blackkker avatar Jul 27 '22 05:07 blackkker

Got some problem when fixing dangerous-default-value in pytorch/test_forward.py. https://github.com/apache/tvm/blob/39ffe0a5ce14c2105b7d48ee420e82e194787d8f/tests/python/frontend/pytorch/test_forward.py#L122-L124 I've tried several ways but none of them fully solve the problem as 64 62 show. Any idea? @areusch @SebastianBoblest

blackkker avatar Aug 03 '22 12:08 blackkker

Got some problem when fixing dangerous-default-value in pytorch/test_forward.py.

https://github.com/apache/tvm/blob/39ffe0a5ce14c2105b7d48ee420e82e194787d8f/tests/python/frontend/pytorch/test_forward.py#L122-L124

I've tried several ways but none of them fully solve the problem as 64 62 show. Any idea? @areusch @SebastianBoblest

Hi, this function ''verify_model'' is really complicated and the relation between the arguments is quite complex. For example, if model_name is not a string, what should it be then? None or is something else also possible. This function alone actually requires extensive testing in my opinion. But I think this is a separate issue. Why does input_data = input_data or [] not work in this case? It should be as close as possible to an empty list as default argument.

SebastianBoblest avatar Aug 03 '22 13:08 SebastianBoblest

Not work casue it will result in RuntimeError: Boolean value of Tensor with more than one value is ambiguous as ci_60 show.

blackkker avatar Aug 03 '22 13:08 blackkker

Not work casue it will result in RuntimeError: Boolean value of Tensor with more than one value is ambiguous as ci_60 show.

Ok in this case you might need the more explicit form of this: input_data = [] if input_data is None else input_data

Often, the shortened version input_data = input_data or [] is used, however, it has a problem with complex expressions like tensors or numpy arrays that cannot be simply evaluated to True or False. Sorry for that, that was actually my fault.

SebastianBoblest avatar Aug 03 '22 13:08 SebastianBoblest

Not work casue it will result in RuntimeError: Boolean value of Tensor with more than one value is ambiguous as ci_60 show.

Ok in this case you might need the more explicit form of this: input_data = [] if input_data is None else input_data

Often, the shortened version input_data = input_data or [] is used, however, it has a problem with complex expressions like tensors or numpy arrays that cannot be simply evaluated to True or False. Sorry for that, that was actually my fault.

Haha, my fault too. My first version is something like this input_data = [] if input_data is None else input_data. But I took your version because it looks cooler and simpler

blackkker avatar Aug 03 '22 14:08 blackkker

@areusch

blackkker avatar Aug 04 '22 15:08 blackkker

cc @areusch

blackkker avatar Aug 08 '22 06:08 blackkker

thanks @blackkker and sorry for yet another delay. i tried to resolve the merge conflicts myself here, hopefully it goes green and can merge.

areusch avatar Aug 11 '22 00:08 areusch

Unfortunately, it doesn't go green and i fix the conflicts. This time, I hope you can merge as soon as possible beacuse solving conflicts is annoying. Cry with joy. @areusch

blackkker avatar Aug 11 '22 10:08 blackkker

@tvm-bot merge

blackkker avatar Aug 11 '22 10:08 blackkker

thanks @blackkker ! and so sorry for the delays here.

areusch avatar Aug 12 '22 23:08 areusch