You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/02/26 09:17:02 UTC

[GitHub] [tvm] vinceab opened a new pull request #7537: [PYTHON][Target] add stm32mp1 target helper

vinceab opened a new pull request #7537:
URL: https://github.com/apache/tvm/pull/7537


   This helper ease the support of the STM32MP1 by providing the target for
   host tvm/relay build and the cross compiler function based on the STM32MP1
   SDK to allow the generation of the target shared library.
   
   Example on how to use it will come later
   
   Signed-off-by: Vincent ABRIOU <vi...@st.com>
   
   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](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @ them in the pull request thread.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] u99127 commented on a change in pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
u99127 commented on a change in pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#discussion_r596955561



##########
File path: python/tvm/target/target.py
##########
@@ -324,6 +324,31 @@ def arm_cpu(model="unknown", options=None):
     return Target(" ".join(["llvm"] + opts))
 
 
+def stm32mp1(options=None):
+    """Return stm32mp1 target and the associated cross compiler based on the SDK.
+
+    Parameters
+    ----------
+    options : str or list of str
+        Additional options
+    """
+
+    from tvm.contrib import cc
+
+    if "TVM_STM32MP_SDK_PATH" not in os.environ or  os.getenv("TVM_STM32MP_SDK_PATH") == "":
+        raise RuntimeError("Require environment variable TVM_STM32MP_SDK_PATH providing the SDK path directory\n"
+                           "example: export TVM_STM32MP_SDK_PATH=<your path>/STM32MP15-Ecosystem-v2.1.0/Developer-Package/SDK")
+
+    sdk_path = os.environ["TVM_STM32MP_SDK_PATH"]
+    cc = cc.cross_compiler(sdk_path + '/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++',
+                           options=['-mthumb',
+                                    '-mfpu=neon-vfpv4',
+                                    '-mfloat-abi=hard',
+                                    '-mcpu=cortex-a7',
+                                    '--sysroot=' + sdk_path + '/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi'])
+
+    return arm_cpu("stm32mp1", options), cc

Review comment:
       This doesn't feel like not something I'm comfortable checking in as is as it encapsulates something beyond what you would find in the most standard cross-compiler toolchains in the stack. 
   
   Ramana




-- 
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:
users@infra.apache.org



[GitHub] [tvm] vinceab commented on a change in pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
vinceab commented on a change in pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#discussion_r596852365



##########
File path: python/tvm/target/target.py
##########
@@ -324,6 +324,31 @@ def arm_cpu(model="unknown", options=None):
     return Target(" ".join(["llvm"] + opts))
 
 
+def stm32mp1(options=None):
+    """Return stm32mp1 target and the associated cross compiler based on the SDK.
+
+    Parameters
+    ----------
+    options : str or list of str
+        Additional options
+    """
+
+    from tvm.contrib import cc
+
+    if "TVM_STM32MP_SDK_PATH" not in os.environ or  os.getenv("TVM_STM32MP_SDK_PATH") == "":
+        raise RuntimeError("Require environment variable TVM_STM32MP_SDK_PATH providing the SDK path directory\n"
+                           "example: export TVM_STM32MP_SDK_PATH=<your path>/STM32MP15-Ecosystem-v2.1.0/Developer-Package/SDK")
+
+    sdk_path = os.environ["TVM_STM32MP_SDK_PATH"]
+    cc = cc.cross_compiler(sdk_path + '/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++',
+                           options=['-mthumb',
+                                    '-mfpu=neon-vfpv4',
+                                    '-mfloat-abi=hard',
+                                    '-mcpu=cortex-a7',
+                                    '--sysroot=' + sdk_path + '/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi'])
+
+    return arm_cpu("stm32mp1", options), cc

Review comment:
       Hi @areusch @zxybazh,
   
   I understand your point.
   What I can propose at least is to provide an example on how to use STM32MP1 with current TVM API by adding the SDK cross compiler function into this example (It was my first though but I wanted to go one step further by integrating this mechanism inside the TVM python code because I spent some week to understand how I can generate a .so library compatible with my target).
   Then I can open a discussion on how cross compiler for ad hoc settings could easily supported.
   
   BR
   Vincent




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] zxybazh commented on a change in pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
zxybazh commented on a change in pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#discussion_r596525449



##########
File path: python/tvm/target/target.py
##########
@@ -324,6 +324,31 @@ def arm_cpu(model="unknown", options=None):
     return Target(" ".join(["llvm"] + opts))
 
 
+def stm32mp1(options=None):
+    """Return stm32mp1 target and the associated cross compiler based on the SDK.
+
+    Parameters
+    ----------
+    options : str or list of str
+        Additional options
+    """
+
+    from tvm.contrib import cc
+
+    if "TVM_STM32MP_SDK_PATH" not in os.environ or  os.getenv("TVM_STM32MP_SDK_PATH") == "":
+        raise RuntimeError("Require environment variable TVM_STM32MP_SDK_PATH providing the SDK path directory\n"
+                           "example: export TVM_STM32MP_SDK_PATH=<your path>/STM32MP15-Ecosystem-v2.1.0/Developer-Package/SDK")
+
+    sdk_path = os.environ["TVM_STM32MP_SDK_PATH"]
+    cc = cc.cross_compiler(sdk_path + '/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++',
+                           options=['-mthumb',
+                                    '-mfpu=neon-vfpv4',
+                                    '-mfloat-abi=hard',
+                                    '-mcpu=cortex-a7',
+                                    '--sysroot=' + sdk_path + '/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi'])
+
+    return arm_cpu("stm32mp1", options), cc

Review comment:
       Hi, thanks @vinceab for the patch and I shared the same concern as @areusch. I think it's worth discussing on the forum to figure out the best way to organize all kinds of corss compiler for ad hoc hardware settings. We have to make sure the code we merged into tvm is maintainable and testable with current hardware resource.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] areusch commented on a change in pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
areusch commented on a change in pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#discussion_r586850375



##########
File path: python/tvm/target/target.py
##########
@@ -324,6 +324,31 @@ def arm_cpu(model="unknown", options=None):
     return Target(" ".join(["llvm"] + opts))
 
 
+def stm32mp1(options=None):
+    """Return stm32mp1 target and the associated cross compiler based on the SDK.
+
+    Parameters
+    ----------
+    options : str or list of str
+        Additional options
+    """
+
+    from tvm.contrib import cc
+
+    if "TVM_STM32MP_SDK_PATH" not in os.environ or  os.getenv("TVM_STM32MP_SDK_PATH") == "":
+        raise RuntimeError("Require environment variable TVM_STM32MP_SDK_PATH providing the SDK path directory\n"
+                           "example: export TVM_STM32MP_SDK_PATH=<your path>/STM32MP15-Ecosystem-v2.1.0/Developer-Package/SDK")
+
+    sdk_path = os.environ["TVM_STM32MP_SDK_PATH"]
+    cc = cc.cross_compiler(sdk_path + '/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++',
+                           options=['-mthumb',
+                                    '-mfpu=neon-vfpv4',
+                                    '-mfloat-abi=hard',
+                                    '-mcpu=cortex-a7',
+                                    '--sysroot=' + sdk_path + '/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi'])
+
+    return arm_cpu("stm32mp1", options), cc

Review comment:
       for functions that live in this module, convention is to just return the target rather than `(target, cross_compiler)`. i'd like to see more about how this is used and perhaps I could suggest an alternate location to place the cross-compiler config.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] areusch commented on a change in pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
areusch commented on a change in pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#discussion_r597102389



##########
File path: python/tvm/target/target.py
##########
@@ -324,6 +324,31 @@ def arm_cpu(model="unknown", options=None):
     return Target(" ".join(["llvm"] + opts))
 
 
+def stm32mp1(options=None):
+    """Return stm32mp1 target and the associated cross compiler based on the SDK.
+
+    Parameters
+    ----------
+    options : str or list of str
+        Additional options
+    """
+
+    from tvm.contrib import cc
+
+    if "TVM_STM32MP_SDK_PATH" not in os.environ or  os.getenv("TVM_STM32MP_SDK_PATH") == "":
+        raise RuntimeError("Require environment variable TVM_STM32MP_SDK_PATH providing the SDK path directory\n"
+                           "example: export TVM_STM32MP_SDK_PATH=<your path>/STM32MP15-Ecosystem-v2.1.0/Developer-Package/SDK")
+
+    sdk_path = os.environ["TVM_STM32MP_SDK_PATH"]
+    cc = cc.cross_compiler(sdk_path + '/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++',
+                           options=['-mthumb',
+                                    '-mfpu=neon-vfpv4',
+                                    '-mfloat-abi=hard',
+                                    '-mcpu=cortex-a7',
+                                    '--sysroot=' + sdk_path + '/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi'])
+
+    return arm_cpu("stm32mp1", options), cc

Review comment:
       @hogepodge is working on a fairly extensive refactor of the TVM tutorials--I think we should ensure there is a place for stuff like this. it would still be helpful to see your tutorial or perhaps the python scripts you're using with this code! perhaps there are other pieces we are missing or should checkin, or perhaps there is a particular way we should structure our docs to make this use case more straightforward.




-- 
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:
users@infra.apache.org



[GitHub] [tvm] vinceab commented on a change in pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
vinceab commented on a change in pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#discussion_r587259459



##########
File path: python/tvm/target/target.py
##########
@@ -324,6 +324,31 @@ def arm_cpu(model="unknown", options=None):
     return Target(" ".join(["llvm"] + opts))
 
 
+def stm32mp1(options=None):
+    """Return stm32mp1 target and the associated cross compiler based on the SDK.
+
+    Parameters
+    ----------
+    options : str or list of str
+        Additional options
+    """
+
+    from tvm.contrib import cc
+
+    if "TVM_STM32MP_SDK_PATH" not in os.environ or  os.getenv("TVM_STM32MP_SDK_PATH") == "":
+        raise RuntimeError("Require environment variable TVM_STM32MP_SDK_PATH providing the SDK path directory\n"
+                           "example: export TVM_STM32MP_SDK_PATH=<your path>/STM32MP15-Ecosystem-v2.1.0/Developer-Package/SDK")
+
+    sdk_path = os.environ["TVM_STM32MP_SDK_PATH"]
+    cc = cc.cross_compiler(sdk_path + '/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++',
+                           options=['-mthumb',
+                                    '-mfpu=neon-vfpv4',
+                                    '-mfloat-abi=hard',
+                                    '-mcpu=cortex-a7',
+                                    '--sysroot=' + sdk_path + '/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi'])
+
+    return arm_cpu("stm32mp1", options), cc

Review comment:
       Hi @areusch I was questioning myself for the best way to achieve the STM32MP1 SDK path integration to get a cross-compiler configuration.
   The STM32MP1 MPU from STMicroelectronics is provided with and OpenSTLinux distribution base on Yocto build system.
   I can not afford to embed the full armv7 gcc tool chain in the distribution and therefore can not relink on the target the object file generated by TVM. 
   So my goal is to build on the host the shared library itself so that I can load it through RPC on the target without the need to relink.
   That why I would like to create an helper to get the cross-compiler based on the OpenSTLinux SDK path. The things are working well but it is maybe done at the wrong place.
   First of all I was thinking to add this fonctionnality in python/tvm/contrib/stm32mp.py but I changed my mind.
   
   Please advise and I will update accordingly.
   
   BR
   Vincent




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] areusch commented on pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
areusch commented on pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#issuecomment-825035090


   hi @vinceab, thanks for posting! here's what I think:
   - it would indeed be great to place this somewhere central so that other users could benefit from this
   - it's not clear to me it makes sense that this place should be inside the TVM repo--this is mostly configuration rather than TVM code itself
   - something else like a central wiki where people could post up e.g. this configuration or pointers to repos which use TVM may be helpful
   - the problem with doing this is API drift. we can't really solve that now given tvm's slow release schedule when people are using python scripts to drive tvm. however, there are a couple of ways this could get addressed in the future:
        1. your use case is pretty standard (build shared library, upload for remote exection). it's likely as part of `tvmc` work we should introduce an e.g. yaml format for this data
        2. as tvm releases become more frequent, repos can state the version of TVM they depend on in e.g. `requirements.txt`, and could be linked from a central place.
   
   cc @jwfromm @tqchen 


-- 
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:
users@infra.apache.org



[GitHub] [tvm] areusch edited a comment on pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
areusch edited a comment on pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#issuecomment-825035090


   hi @vinceab, thanks for posting! here's what I think:
   - it would indeed be great to place this somewhere central so that other users could benefit from this
   - it's not clear to me it makes sense that this place should be inside the TVM repo--this is mostly configuration rather than TVM code itself
   - something else like a central wiki where people could post up e.g. this configuration or pointers to repos which use TVM may be helpful
   - the problem with doing this is API drift. we can't really solve that now given tvm's slow release schedule when people are using python scripts to drive tvm. however, there are a couple of ways this could get addressed in the future:
        1. your use case is pretty standard (build shared library, upload for remote exection). it's likely as part of `tvmc` work we should introduce an e.g. yaml format for this data
        2. as tvm releases become more frequent, repos can state the version of TVM they depend on in e.g. `requirements.txt`, and could be linked from a central place.
   
   cc @jwfromm @tqchen @leandron


-- 
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:
users@infra.apache.org



[GitHub] [tvm] vinceab commented on a change in pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
vinceab commented on a change in pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#discussion_r617479382



##########
File path: python/tvm/target/target.py
##########
@@ -324,6 +324,31 @@ def arm_cpu(model="unknown", options=None):
     return Target(" ".join(["llvm"] + opts))
 
 
+def stm32mp1(options=None):
+    """Return stm32mp1 target and the associated cross compiler based on the SDK.
+
+    Parameters
+    ----------
+    options : str or list of str
+        Additional options
+    """
+
+    from tvm.contrib import cc
+
+    if "TVM_STM32MP_SDK_PATH" not in os.environ or  os.getenv("TVM_STM32MP_SDK_PATH") == "":
+        raise RuntimeError("Require environment variable TVM_STM32MP_SDK_PATH providing the SDK path directory\n"
+                           "example: export TVM_STM32MP_SDK_PATH=<your path>/STM32MP15-Ecosystem-v2.1.0/Developer-Package/SDK")
+
+    sdk_path = os.environ["TVM_STM32MP_SDK_PATH"]
+    cc = cc.cross_compiler(sdk_path + '/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++',
+                           options=['-mthumb',
+                                    '-mfpu=neon-vfpv4',
+                                    '-mfloat-abi=hard',
+                                    '-mcpu=cortex-a7',
+                                    '--sysroot=' + sdk_path + '/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi'])
+
+    return arm_cpu("stm32mp1", options), cc

Review comment:
       Hi @areusch,
   
   Sorry for the long answer delay... here is the Python script I use to test TVM on STM32MP1.
    
   [stm32mp15x_deploy_mobilenet-v1_0.5_128_quant.zip](https://github.com/apache/tvm/files/6350671/stm32mp15x_deploy_mobilenet-v1_0.5_128_quant.zip)
   




-- 
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:
users@infra.apache.org



[GitHub] [tvm] tqchen edited a comment on pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
tqchen edited a comment on pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#issuecomment-790107679


   @vinceab Thanks for contributing, please fix the lint errors
   
   cc @areusch please help to review this PR


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] vinceab closed pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
vinceab closed pull request #7537:
URL: https://github.com/apache/tvm/pull/7537


   


-- 
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:
users@infra.apache.org



[GitHub] [tvm] vinceab commented on pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
vinceab commented on pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#issuecomment-826587938


   Hi @areusch,
   
   I understand you point.
   On my side, the integration and testing of TVM is on going for STM32 product. And at least, the python script I shared will be available on STMicroelectornics GitHub once a consistent delivery will be made integrating TVM.
   Maybe a cross reference in the TVM documentation could be a solution.
   
   Regarding TVMC I have identified an improvement to better support cross compilation toolchain by adding the options.
   I will post a pull request soon for this.


-- 
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:
users@infra.apache.org



[GitHub] [tvm] areusch commented on a change in pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
areusch commented on a change in pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#discussion_r596947302



##########
File path: python/tvm/target/target.py
##########
@@ -324,6 +324,31 @@ def arm_cpu(model="unknown", options=None):
     return Target(" ".join(["llvm"] + opts))
 
 
+def stm32mp1(options=None):
+    """Return stm32mp1 target and the associated cross compiler based on the SDK.
+
+    Parameters
+    ----------
+    options : str or list of str
+        Additional options
+    """
+
+    from tvm.contrib import cc
+
+    if "TVM_STM32MP_SDK_PATH" not in os.environ or  os.getenv("TVM_STM32MP_SDK_PATH") == "":
+        raise RuntimeError("Require environment variable TVM_STM32MP_SDK_PATH providing the SDK path directory\n"
+                           "example: export TVM_STM32MP_SDK_PATH=<your path>/STM32MP15-Ecosystem-v2.1.0/Developer-Package/SDK")
+
+    sdk_path = os.environ["TVM_STM32MP_SDK_PATH"]
+    cc = cc.cross_compiler(sdk_path + '/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++',
+                           options=['-mthumb',
+                                    '-mfpu=neon-vfpv4',
+                                    '-mfloat-abi=hard',
+                                    '-mcpu=cortex-a7',
+                                    '--sysroot=' + sdk_path + '/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi'])
+
+    return arm_cpu("stm32mp1", options), cc

Review comment:
       @vinceab it would be great to better understand your pain points. i'm still concerned about checking in untestable code to python/, particularly in target.py. but perhaps if we have a more complete example it would help us to understand the shortcomings with our existing docs. in particular, so far i'm wondering whether we should have some type of wiki or page where implementers on a particular device could provide snippets such as these and discuss any wrinkles or problems they had.
   
   cc @hogepodge 




-- 
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:
users@infra.apache.org



[GitHub] [tvm] tqchen commented on pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
tqchen commented on pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#issuecomment-790107679


   cc @areusch please help to review this PR


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] areusch commented on a change in pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
areusch commented on a change in pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#discussion_r596521808



##########
File path: python/tvm/target/target.py
##########
@@ -324,6 +324,31 @@ def arm_cpu(model="unknown", options=None):
     return Target(" ".join(["llvm"] + opts))
 
 
+def stm32mp1(options=None):
+    """Return stm32mp1 target and the associated cross compiler based on the SDK.
+
+    Parameters
+    ----------
+    options : str or list of str
+        Additional options
+    """
+
+    from tvm.contrib import cc
+
+    if "TVM_STM32MP_SDK_PATH" not in os.environ or  os.getenv("TVM_STM32MP_SDK_PATH") == "":
+        raise RuntimeError("Require environment variable TVM_STM32MP_SDK_PATH providing the SDK path directory\n"
+                           "example: export TVM_STM32MP_SDK_PATH=<your path>/STM32MP15-Ecosystem-v2.1.0/Developer-Package/SDK")
+
+    sdk_path = os.environ["TVM_STM32MP_SDK_PATH"]
+    cc = cc.cross_compiler(sdk_path + '/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++',
+                           options=['-mthumb',
+                                    '-mfpu=neon-vfpv4',
+                                    '-mfloat-abi=hard',
+                                    '-mcpu=cortex-a7',
+                                    '--sysroot=' + sdk_path + '/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi'])
+
+    return arm_cpu("stm32mp1", options), cc

Review comment:
       hi @vinceab sorry for the delay here. my main concern with this PR is how we can test it and document which version of the SDK it works with so we can ensure it continues to work after it is merged. I think the best we could do in the TVM CI is assert that the compilation flow works--we don't have any non-cloud hardware in the loop for the TVM CI, so we couldn't assert against real hardware. even with this level of testing though, i'm not sure the approach would scale to arbitrary cross-compiler.
   
   i'm wondering if it might make sense to invert the dependency here--would it be better to put this kind of convenience function in a separate git repo, since it depends only on public TVM APIs? It would also be easier to organize related things such as examples.
   
   I do think if we take this approach, it would be helpful for us to consider how we could deal with the discoverability problem (I.e. could we index or link to such repos from a TVM site). it would be helpful to discuss this in the discuss.tvm.ai forum as well.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] vinceab commented on a change in pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
vinceab commented on a change in pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#discussion_r596100707



##########
File path: python/tvm/target/target.py
##########
@@ -324,6 +324,31 @@ def arm_cpu(model="unknown", options=None):
     return Target(" ".join(["llvm"] + opts))
 
 
+def stm32mp1(options=None):
+    """Return stm32mp1 target and the associated cross compiler based on the SDK.
+
+    Parameters
+    ----------
+    options : str or list of str
+        Additional options
+    """
+
+    from tvm.contrib import cc
+
+    if "TVM_STM32MP_SDK_PATH" not in os.environ or  os.getenv("TVM_STM32MP_SDK_PATH") == "":
+        raise RuntimeError("Require environment variable TVM_STM32MP_SDK_PATH providing the SDK path directory\n"
+                           "example: export TVM_STM32MP_SDK_PATH=<your path>/STM32MP15-Ecosystem-v2.1.0/Developer-Package/SDK")
+
+    sdk_path = os.environ["TVM_STM32MP_SDK_PATH"]
+    cc = cc.cross_compiler(sdk_path + '/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++',
+                           options=['-mthumb',
+                                    '-mfpu=neon-vfpv4',
+                                    '-mfloat-abi=hard',
+                                    '-mcpu=cortex-a7',
+                                    '--sysroot=' + sdk_path + '/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi'])
+
+    return arm_cpu("stm32mp1", options), cc

Review comment:
       @junrushao1994 @zxybazh @areusch
   
   Any update regarding where this patch could land?
   
   Thanks
   Vincent




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [tvm] vinceab commented on a change in pull request #7537: [PYTHON][Target] add stm32mp1 target helper

Posted by GitBox <gi...@apache.org>.
vinceab commented on a change in pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#discussion_r596981362



##########
File path: python/tvm/target/target.py
##########
@@ -324,6 +324,31 @@ def arm_cpu(model="unknown", options=None):
     return Target(" ".join(["llvm"] + opts))
 
 
+def stm32mp1(options=None):
+    """Return stm32mp1 target and the associated cross compiler based on the SDK.
+
+    Parameters
+    ----------
+    options : str or list of str
+        Additional options
+    """
+
+    from tvm.contrib import cc
+
+    if "TVM_STM32MP_SDK_PATH" not in os.environ or  os.getenv("TVM_STM32MP_SDK_PATH") == "":
+        raise RuntimeError("Require environment variable TVM_STM32MP_SDK_PATH providing the SDK path directory\n"
+                           "example: export TVM_STM32MP_SDK_PATH=<your path>/STM32MP15-Ecosystem-v2.1.0/Developer-Package/SDK")
+
+    sdk_path = os.environ["TVM_STM32MP_SDK_PATH"]
+    cc = cc.cross_compiler(sdk_path + '/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++',
+                           options=['-mthumb',
+                                    '-mfpu=neon-vfpv4',
+                                    '-mfloat-abi=hard',
+                                    '-mcpu=cortex-a7',
+                                    '--sysroot=' + sdk_path + '/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi'])
+
+    return arm_cpu("stm32mp1", options), cc

Review comment:
       @areusch following different documentation on tvm.apache.org/docs it was not describe how to execute a relay object on a target that dos not have the toolchain embedded in its rootfs (most of device with small memory footprint does not embed its gcc toolchain).
   I have to dig to understand that a shared library is sufficient.
   The existing doc is focus on device like Rpi or desktop but for other kind of device, it is not straight forward as it should be.
   
   I guess that the extension of the documentation could be sufficient to explain how to do with device like STM32MP1.
   Maybe having also a python script example integrated into the TVM git could be the solution has it is for the other target like RPi.
   
   Vincent
   




-- 
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:
users@infra.apache.org