areusch commented on a change in pull request #7289: URL: https://github.com/apache/tvm/pull/7289#discussion_r558498794
########## File path: python/gen_requirements.py ########## @@ -0,0 +1,391 @@ +#!/usr/bin/env python3 +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""TVM Python requriements.txt generator. + +This script generates a set of requirements.txt files (stored in `./requirements`) that describe +TVM's Python dependencies. + +## Pieces + +TVM can be roughly broken into these named pieces along the lines of Python dependencies: + +- "core": A core piece, which is intended to be buildable with very few external dependencies. Users + can use Relay, compile models, and run autotuning with this part. +- "importer-<tool>": Model importers, which convert models defined in various other tools (i.e. + TensorFlow, PyTorch, etc) into Relay models. +- Extra features (i.e. XGBoost in AutoTVM). These enhance TVM's functionality, but aren't required + for basic operation. + +## What this tool does + +From these pieces, this tool builds: + - requirements/<name>.txt - Python dependencies for each named piece above, `<name>` is the same as + the quoted piece name. + - requirements/all.txt - Consolidated Python dependencies for all pieces, excluding dev below. + - requirements/dev.txt - Python dependencies needed to develop TVM, such as lint and test tools. + +The data representing each piece is contained in the two maps below. +""" + +import argparse +import collections +import os +import re +import textwrap +import sys + +# Maps named TVM piece (see description above) to a list of names of Python packages. Please use +# alphabetical order for each package list, and do not add version constraints here! +REQUIREMENTS_BY_PIECE = [ + # Base requirements needed to install tvm with no extras. + ("core", [ + "attrs", + "decorator", + "numpy", + "psutil", + "scipy", + "synr", + ]), + + # Relay frontends. + ("importer-caffe2", ["torch"]), + ("importer-coreml", ["coremltools"]), + ("importer-darknet", ["opencv-python"]), + ("importer-keras", ["tensorflow", "tensorflow-estimator"]), + ("importer-onnx", ["future", "onnx", "onnxruntime", "torch", "torchvision"]), + ("importer-pytorch", ["future", "torch", "torchvision"]), + ("importer-tensorflow", ["tensorflow", "tensorflow-estimator"]), + ("importer-tflite", ["tensorflow", "tensorflow-estimator", "tflite"]), + + ("tvmc", ["onnx", "onnxruntime", "tensorflow", "tflite", "torch", "torchvision"]), + + # XGBoost, useful for autotuning on some targets. + ("xgboost", ["torch"]), + + # Development requirements + ("dev", ["matplotlib", "pillow"]), +] + +# Maps a named Python package (which should appear in REQUIREMENTS_BY_PIECE above) to a +# semver or pip version constraint. Semver constraints are translated into requirements.txt +# constraints. +CONSTRAINTS = [ + ("onnx", ">=1.7.0"), + ("onnxruntime", ">=1.0.0"), + ("pillow", "<7"), + ("synr", ">=0.2.1"), + ("tensorflow", ">=2.1.0"), + ("tflite", ">=2.1.0"), + ("torch", "^1.7.0"), + ("torchvision", ">=0.5.0"), +] + +################################################################################ +# End of configuration options. +################################################################################ + + + + +# Required keys in REQUIREMENTS_BY_PIECE. +REQUIRED_PIECES = ["core", "dev"] + +# Regex to validates piece names. +PIECE_REGEX = re.compile(r"^[a-z0-9][a-z0-9-]*", re.IGNORECASE) + +# Regex to match a constraint specification. Multiple constraints are not supported. +CONSTRAINT_REGEX = re.compile(r"(?:\^|\<|(?:<=)|(?:==)|(?:>=)|\>)[^<>=\^,]+") Review comment: yeah no non-stdlib deps in the deps generator script ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org