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 2022/05/24 07:55:21 UTC

[GitHub] [tvm] dchauhan-arm opened a new pull request, #11427: [TVMC] Workspace Pools Parameters

dchauhan-arm opened a new pull request, #11427:
URL: https://github.com/apache/tvm/pull/11427

   Attributes from tvmc are now passable into the created PoolInfo objects
   inside WorkspaceMemoryPools. This is passed in to relay.build that get
   attached to IRModule attribute.
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] manupa-arm commented on pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
manupa-arm commented on PR #11427:
URL: https://github.com/apache/tvm/pull/11427#issuecomment-1177921487

   @tvm-bot rerun


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] areusch commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
areusch commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r912221103


##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(

Review Comment:
   ah yeah, maybe my question was bigger than this PR. just was curious if it would be possible to configure via e.g. yaml or json here. likely it would be a target-wide file, so perhaps we should table this question and come back to it in the future.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] areusch commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
areusch commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r888381583


##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(

Review Comment:
   is it possible to specify these in a file?



##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(
+        "--workspace-pools",
+        help="""The name of the memory pool
+                Example usage: --workspace-pools=flash""",
+    )
+    parser.add_argument(
+        "--workspace-pools-size-hint-bytes",
+        nargs="?",
+        help="""The expected size hint to be used by the allocator.
+                Example usage: --workspace-pools-size-hint-bytes=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-access",
+        help="""A dictionary where keys describe which targets could
+                access the pool where value could take the values :
+                a) "rw" : read-write access
+                b) "ro" : write-only access
+                Example usage: --workspace-pools-target-access=flash:accel:ro""",
+    )
+    parser.add_argument(
+        "--workspace-pools-clock-frequency-hz",
+        nargs="?",
+        help="""The clock frequency that the memory pool runs at in Hz.
+                Example usage: --workspace-pools-clock-frequency-hz=flash:70000000""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The read bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-read-bandwidth-bytes-per-cycle=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The write bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-write-bandwidth-bytes-per-cycle=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-latency-cycles",
+        nargs="?",
+        help="""The read latency of the memory pool in cycles.
+                Example usage: --workspace-pools-read-latency-cycles=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-latency-cycles",
+        nargs="?",
+        help="""The write latency of the memory pool in cycles.
+                Example usage: --workspace-pools-write-latency-cycles=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-burst-bytes",
+        help="""The burst length of the memory pool in bytes per target.
+                Example usage: --workspace-pools-target-burst-bytes=flash:accel:1""",
+    )
+
+
+def _parse_target_burst(attr, pool_name):
+    if pool_name not in attr:
+        return {}
+
+    return {target: int(attr[pool_name][target]) for target in attr[pool_name]}
+
+
+def _parse_target_access(attr, pool_name):
+    try:
+        return attr[pool_name]
+    except:
+        raise TVMCException(f'Workspace Pool "{pool_name}" using undefined Target.')
+
+
+def _split_pools(attr):
+    return re.split(",", attr) if attr else []
+
+
+def _target_attributes_to_pools(attr, targets):
+    if not targets or attr is None:
+        return {}
+
+    target_attributes = {}
+    for pool_values in re.split(",", attr):
+        pool_name, target_name, target_value = re.split(":", pool_values)
+        if pool_name not in target_attributes:
+            target_attributes[pool_name] = {}
+
+        matched_targets = [target for target in targets if target_name == target.kind.name]
+        if matched_targets:
+            target_attributes[pool_name][matched_targets[0]] = target_value
+        else:
+            raise TVMCException(
+                "The workspace pool target specification for target access "
+                "needs to be the same TVM target as when specifying targets to use."
+            )
+
+    return target_attributes
+
+
+def _attribute_to_pools(attr):
+    return dict(pool.split(":", maxsplit=1) for pool in re.split(",", attr)) if attr else {}
+
+
+def workspace_pools_recombobulate(parsed, targets):
+    """Reconstructs the Workspace Pools args and returns a WorkspaceMemoryPool object"""
+    WORKSPACE_POOL_PARAMS = [

Review Comment:
   could we mark where this list comes from and include "keep in sync with" comments in both places?



##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(
+        "--workspace-pools",
+        help="""The name of the memory pool
+                Example usage: --workspace-pools=flash""",
+    )
+    parser.add_argument(
+        "--workspace-pools-size-hint-bytes",
+        nargs="?",
+        help="""The expected size hint to be used by the allocator.
+                Example usage: --workspace-pools-size-hint-bytes=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-access",
+        help="""A dictionary where keys describe which targets could
+                access the pool where value could take the values :
+                a) "rw" : read-write access
+                b) "ro" : write-only access
+                Example usage: --workspace-pools-target-access=flash:accel:ro""",
+    )
+    parser.add_argument(
+        "--workspace-pools-clock-frequency-hz",
+        nargs="?",
+        help="""The clock frequency that the memory pool runs at in Hz.
+                Example usage: --workspace-pools-clock-frequency-hz=flash:70000000""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The read bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-read-bandwidth-bytes-per-cycle=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The write bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-write-bandwidth-bytes-per-cycle=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-latency-cycles",
+        nargs="?",
+        help="""The read latency of the memory pool in cycles.
+                Example usage: --workspace-pools-read-latency-cycles=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-latency-cycles",
+        nargs="?",
+        help="""The write latency of the memory pool in cycles.
+                Example usage: --workspace-pools-write-latency-cycles=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-burst-bytes",
+        help="""The burst length of the memory pool in bytes per target.
+                Example usage: --workspace-pools-target-burst-bytes=flash:accel:1""",
+    )
+
+
+def _parse_target_burst(attr, pool_name):
+    if pool_name not in attr:
+        return {}
+
+    return {target: int(attr[pool_name][target]) for target in attr[pool_name]}
+
+
+def _parse_target_access(attr, pool_name):
+    try:
+        return attr[pool_name]
+    except:
+        raise TVMCException(f'Workspace Pool "{pool_name}" using undefined Target.')
+
+
+def _split_pools(attr):
+    return re.split(",", attr) if attr else []
+
+
+def _target_attributes_to_pools(attr, targets):
+    if not targets or attr is None:
+        return {}
+
+    target_attributes = {}
+    for pool_values in re.split(",", attr):
+        pool_name, target_name, target_value = re.split(":", pool_values)
+        if pool_name not in target_attributes:
+            target_attributes[pool_name] = {}
+
+        matched_targets = [target for target in targets if target_name == target.kind.name]
+        if matched_targets:
+            target_attributes[pool_name][matched_targets[0]] = target_value
+        else:
+            raise TVMCException(
+                "The workspace pool target specification for target access "
+                "needs to be the same TVM target as when specifying targets to use."
+            )
+
+    return target_attributes
+
+
+def _attribute_to_pools(attr):
+    return dict(pool.split(":", maxsplit=1) for pool in re.split(",", attr)) if attr else {}
+
+
+def workspace_pools_recombobulate(parsed, targets):
+    """Reconstructs the Workspace Pools args and returns a WorkspaceMemoryPool object"""
+    WORKSPACE_POOL_PARAMS = [
+        "workspace_pools_size_hint_bytes",
+        "workspace_pools_target_access",
+        "workspace_pools_clock_frequency_hz",
+        "workspace_pools_read_bandwidth_bytes_per_cycle",
+        "workspace_pools_write_bandwidth_bytes_per_cycle",
+        "workspace_pools_read_latency_cycles",
+        "workspace_pools_write_latency_cycles",
+        "workspace_pools_target_burst_bytes",
+    ]
+    WORKSPACE_POOL_TARGET_PARAMS = [
+        "workspace_pools_target_access",
+        "workspace_pools_target_burst_bytes",
+    ]
+
+    workspace_pools = _split_pools(parsed.workspace_pools)
+    pool_to_attributes = {
+        workspace_pool_param: _attribute_to_pools(getattr(parsed, workspace_pool_param))
+        for workspace_pool_param in WORKSPACE_POOL_PARAMS
+    }
+    pool_to_target_attributes = {
+        workspace_pool_param: _target_attributes_to_pools(
+            getattr(parsed, workspace_pool_param), targets
+        )
+        for workspace_pool_param in WORKSPACE_POOL_TARGET_PARAMS
+    }
+
+    return WorkspaceMemoryPools(
+        [
+            PoolInfo(

Review Comment:
   alternatively if this thing complained when a parameters was missing or invalidly named, that would be ok as a way to resolve my earlier comment



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] manupa-arm commented on pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
manupa-arm commented on PR #11427:
URL: https://github.com/apache/tvm/pull/11427#issuecomment-1191263721

   @leandron as a codeowner, could take a final look ? 


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] manupa-arm commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
manupa-arm commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r903451308


##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(
+        "--workspace-pools",
+        help="""The name of the memory pool
+                Example usage: --workspace-pools=flash""",
+    )
+    parser.add_argument(
+        "--workspace-pools-size-hint-bytes",
+        nargs="?",
+        help="""The expected size hint to be used by the allocator.
+                Example usage: --workspace-pools-size-hint-bytes=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-access",
+        help="""A dictionary where keys describe which targets could
+                access the pool where value could take the values :
+                a) "rw" : read-write access
+                b) "ro" : write-only access
+                Example usage: --workspace-pools-target-access=flash:accel:ro""",
+    )
+    parser.add_argument(
+        "--workspace-pools-clock-frequency-hz",
+        nargs="?",
+        help="""The clock frequency that the memory pool runs at in Hz.
+                Example usage: --workspace-pools-clock-frequency-hz=flash:70000000""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The read bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-read-bandwidth-bytes-per-cycle=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The write bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-write-bandwidth-bytes-per-cycle=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-latency-cycles",
+        nargs="?",
+        help="""The read latency of the memory pool in cycles.
+                Example usage: --workspace-pools-read-latency-cycles=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-latency-cycles",
+        nargs="?",
+        help="""The write latency of the memory pool in cycles.
+                Example usage: --workspace-pools-write-latency-cycles=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-burst-bytes",
+        help="""The burst length of the memory pool in bytes per target.
+                Example usage: --workspace-pools-target-burst-bytes=flash:accel:1""",
+    )
+
+
+def _parse_target_burst(attr, pool_name):
+    if pool_name not in attr:
+        return {}
+
+    return {target: int(attr[pool_name][target]) for target in attr[pool_name]}
+
+
+def _parse_target_access(attr, pool_name):
+    try:
+        return attr[pool_name]
+    except:
+        raise TVMCException(f'Workspace Pool "{pool_name}" using undefined Target.')
+
+
+def _split_pools(attr):
+    return re.split(",", attr) if attr else []
+
+
+def _target_attributes_to_pools(attr, targets):
+    if not targets or attr is None:
+        return {}
+
+    target_attributes = {}
+    for pool_values in re.split(",", attr):
+        pool_name, target_name, target_value = re.split(":", pool_values)
+        if pool_name not in target_attributes:
+            target_attributes[pool_name] = {}
+
+        matched_targets = [target for target in targets if target_name == target.kind.name]
+        if matched_targets:
+            target_attributes[pool_name][matched_targets[0]] = target_value
+        else:
+            raise TVMCException(
+                "The workspace pool target specification for target access "
+                "needs to be the same TVM target as when specifying targets to use."
+            )
+
+    return target_attributes
+
+
+def _attribute_to_pools(attr):
+    return dict(pool.split(":", maxsplit=1) for pool in re.split(",", attr)) if attr else {}
+
+
+def workspace_pools_recombobulate(parsed, targets):
+    """Reconstructs the Workspace Pools args and returns a WorkspaceMemoryPool object"""
+    WORKSPACE_POOL_PARAMS = [
+        "workspace_pools_size_hint_bytes",
+        "workspace_pools_target_access",
+        "workspace_pools_clock_frequency_hz",
+        "workspace_pools_read_bandwidth_bytes_per_cycle",
+        "workspace_pools_write_bandwidth_bytes_per_cycle",
+        "workspace_pools_read_latency_cycles",
+        "workspace_pools_write_latency_cycles",
+        "workspace_pools_target_burst_bytes",
+    ]
+    WORKSPACE_POOL_TARGET_PARAMS = [
+        "workspace_pools_target_access",
+        "workspace_pools_target_burst_bytes",
+    ]
+
+    workspace_pools = _split_pools(parsed.workspace_pools)
+    pool_to_attributes = {
+        workspace_pool_param: _attribute_to_pools(getattr(parsed, workspace_pool_param))
+        for workspace_pool_param in WORKSPACE_POOL_PARAMS
+    }
+    pool_to_target_attributes = {
+        workspace_pool_param: _target_attributes_to_pools(
+            getattr(parsed, workspace_pool_param), targets
+        )
+        for workspace_pool_param in WORKSPACE_POOL_TARGET_PARAMS
+    }
+
+    return WorkspaceMemoryPools(
+        [
+            PoolInfo(

Review Comment:
   I think we still need to keep-in-sync comment because PoolInfo could be added with arguments with defaults and tvmc support for that could be missed out.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] dchauhan-arm commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
dchauhan-arm commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r917875318


##########
tests/python/driver/tvmc/test_workspace_pools.py:
##########
@@ -0,0 +1,359 @@
+# 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.
+
+import pytest
+import argparse
+
+from tvm.driver.tvmc.workspace_pools import (
+    generate_workspace_pools_args,
+    workspace_pools_recombobulate,
+)
+from tvm.target import Target
+from tvm.driver.tvmc import TVMCException
+
+
+def test_workspace_pools_argparse():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, unparsed = parser.parse_known_args(
+        [
+            "--workspace-pools=sram,flash",
+            "--workspace-pools-targets=sram:c",
+            "--workspace-pools-targets=sram:llvm",
+            "--workspace-pools-targets=flash:c",
+            "--workspace-pools-size-hint-bytes=sram:400",
+            "--workspace-pools-size-hint-bytes=sram:500",
+            "--workspace-pools-clock-frequency-hz=sram:500",
+            "--workspace-pools-read-bandwidth-bytes-per-cycle=sram:200",
+            "--workspace-pools-write-bandwidth-bytes-per-cycle=sram:100",
+            "--workspace-pools-read-latency-cycles=sram:50",
+            "--workspace-pools-read-latency-cycles=flash:30",
+            "--workspace-pools-write-latency-cycles=sram:9001",
+            "--workspace-pools-target-burst-bytes=sram:c:2",
+            "--workspace-pools-is-internal=sram:0",
+        ]
+    )
+
+    assert parsed.workspace_pools == "sram,flash"
+    assert parsed.workspace_pools_targets == ["sram:c", "sram:llvm", "flash:c"]
+    assert parsed.workspace_pools_size_hint_bytes == ["sram:400", "sram:500"]
+    assert parsed.workspace_pools_clock_frequency_hz == ["sram:500"]
+    assert parsed.workspace_pools_read_bandwidth_bytes_per_cycle == ["sram:200"]
+    assert parsed.workspace_pools_write_bandwidth_bytes_per_cycle == ["sram:100"]
+    assert parsed.workspace_pools_read_latency_cycles == ["sram:50", "flash:30"]
+    assert parsed.workspace_pools_write_latency_cycles == ["sram:9001"]
+    assert parsed.workspace_pools_target_burst_bytes == ["sram:c:2"]
+
+    assert unparsed == ["--workspace-pools-is-internal=sram:0"]
+
+
+def test_workspace_pools_recombobulate_empty():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args([])
+
+    targets = [Target("llvm")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert memory_pools is None
+
+
+def test_workspace_pools_recombobulate():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-targets=sram:llvm",
+            "--workspace-pools-size-hint-bytes=sram:400",
+            "--workspace-pools-clock-frequency-hz=sram:500",
+        ]
+    )
+
+    targets = [Target("llvm")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert len(memory_pools.pools) == 1
+    assert memory_pools.pools[0].pool_name == "sram"
+    assert memory_pools.pools[0].size_hint_bytes == 400
+    assert memory_pools.pools[0].clock_frequency_hz == 500
+
+
+def test_workspace_pools_defaults():
+    parser = argparse.ArgumentParser()
+    targets = [Target("llvm")]
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-targets=sram:llvm",
+        ]
+    )
+
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert len(memory_pools.pools) == 1
+    assert memory_pools.pools[0].pool_name == "sram"
+    assert memory_pools.pools[0].size_hint_bytes == -1
+    assert memory_pools.pools[0].clock_frequency_hz == -1
+    assert memory_pools.pools[0].read_bandwidth_bytes_per_cycle == -1
+    assert memory_pools.pools[0].write_bandwidth_bytes_per_cycle == -1
+    assert memory_pools.pools[0].read_latency_cycles == 0
+    assert memory_pools.pools[0].write_latency_cycles == 0
+    assert len(memory_pools.pools[0].target_burst_bytes) == 0
+
+
+def test_workspace_pools_recombobulate_multi_fields():
+    parser = argparse.ArgumentParser()
+    targets = [Target("c")]
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-targets=sram:c",
+            "--workspace-pools-size-hint-bytes=sram:400",
+            "--workspace-pools-clock-frequency-hz=sram:500",
+            "--workspace-pools-read-bandwidth-bytes-per-cycle=sram:200",
+            "--workspace-pools-write-bandwidth-bytes-per-cycle=sram:100",
+            "--workspace-pools-read-latency-cycles=sram:50",
+            "--workspace-pools-write-latency-cycles=sram:9001",
+            "--workspace-pools-target-burst-bytes=sram:c:2",
+        ]
+    )
+
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert len(memory_pools.pools) == 1
+    assert memory_pools.pools[0].pool_name == "sram"
+    assert memory_pools.pools[0].size_hint_bytes == 400
+    assert memory_pools.pools[0].clock_frequency_hz == 500
+    assert memory_pools.pools[0].read_bandwidth_bytes_per_cycle == 200
+    assert memory_pools.pools[0].write_bandwidth_bytes_per_cycle == 100
+    assert memory_pools.pools[0].read_latency_cycles == 50
+    assert memory_pools.pools[0].write_latency_cycles == 9001
+    assert len(memory_pools.pools[0].target_burst_bytes) == 1
+    assert memory_pools.pools[0].target_burst_bytes[targets[0]] == 2
+
+
+def test_workspace_pools_recombobulate_multi_fields_variant():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=flash",
+            "--workspace-pools-targets=flash:c",
+            "--workspace-pools-size-hint-bytes=flash:2048",
+            "--workspace-pools-clock-frequency-hz=flash:2000000",
+            "--workspace-pools-read-bandwidth-bytes-per-cycle=flash:4",
+            "--workspace-pools-write-bandwidth-bytes-per-cycle=flash:1",
+            "--workspace-pools-read-latency-cycles=flash:2000",
+            "--workspace-pools-write-latency-cycles=flash:1000",
+            "--workspace-pools-target-burst-bytes=flash:c:4",
+        ]
+    )
+
+    targets = [Target("c")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert len(memory_pools.pools) == 1
+    assert memory_pools.pools[0].pool_name == "flash"
+    assert memory_pools.pools[0].size_hint_bytes == 2048
+    assert memory_pools.pools[0].clock_frequency_hz == 2000000
+    assert memory_pools.pools[0].read_bandwidth_bytes_per_cycle == 4
+    assert memory_pools.pools[0].write_bandwidth_bytes_per_cycle == 1
+    assert memory_pools.pools[0].read_latency_cycles == 2000
+    assert memory_pools.pools[0].write_latency_cycles == 1000
+    assert len(memory_pools.pools[0].target_burst_bytes) == 1
+    assert memory_pools.pools[0].target_burst_bytes[targets[0]] == 4
+
+
+def test_workspace_pools_recombobulate_multi_fields_multi_pools():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram,flash",
+            "--workspace-pools-targets=sram:c,flash:c",
+            "--workspace-pools-size-hint-bytes=sram:1024,flash:2048",
+            "--workspace-pools-clock-frequency-hz=sram:4000000,flash:2000000",
+            "--workspace-pools-read-bandwidth-bytes-per-cycle=sram:8,flash:4",
+            "--workspace-pools-write-bandwidth-bytes-per-cycle=sram:4,flash:1",
+            "--workspace-pools-read-latency-cycles=sram:250,flash:2000",
+            "--workspace-pools-write-latency-cycles=sram:500,flash:1000",
+            "--workspace-pools-target-burst-bytes=sram:c:8,flash:c:4",
+        ]
+    )
+
+    targets = [Target("c")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert len(memory_pools.pools) == 2
+
+    assert memory_pools.pools[0].pool_name == "sram"
+    assert memory_pools.pools[0].size_hint_bytes == 1024
+    assert memory_pools.pools[0].clock_frequency_hz == 4000000
+    assert memory_pools.pools[0].read_bandwidth_bytes_per_cycle == 8
+    assert memory_pools.pools[0].write_bandwidth_bytes_per_cycle == 4
+    assert memory_pools.pools[0].read_latency_cycles == 250
+    assert memory_pools.pools[0].write_latency_cycles == 500
+    assert len(memory_pools.pools[0].target_burst_bytes) == 1
+    assert memory_pools.pools[0].target_burst_bytes[targets[0]] == 8
+
+    assert memory_pools.pools[1].pool_name == "flash"
+    assert memory_pools.pools[1].size_hint_bytes == 2048
+    assert memory_pools.pools[1].clock_frequency_hz == 2000000
+    assert memory_pools.pools[1].read_bandwidth_bytes_per_cycle == 4
+    assert memory_pools.pools[1].write_bandwidth_bytes_per_cycle == 1
+    assert memory_pools.pools[1].read_latency_cycles == 2000
+    assert memory_pools.pools[1].write_latency_cycles == 1000
+    assert len(memory_pools.pools[1].target_burst_bytes) == 1
+    assert memory_pools.pools[1].target_burst_bytes[targets[0]] == 4
+
+
+def test_workspace_pools_recombobulate_multi_fields_ordering():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram,flash",
+            "--workspace-pools-targets=flash:c,sram:c",
+            "--workspace-pools-size-hint-bytes=flash:2048,sram:1024",
+            "--workspace-pools-clock-frequency-hz=sram:4000000,flash:2000000",
+            "--workspace-pools-read-bandwidth-bytes-per-cycle=sram:8,flash:4",
+            "--workspace-pools-write-bandwidth-bytes-per-cycle=sram:4,flash:1",
+            "--workspace-pools-read-latency-cycles=sram:250,flash:2000",
+            "--workspace-pools-write-latency-cycles=flash:1000,sram:500",
+            "--workspace-pools-target-burst-bytes=sram:c:8,flash:c:4",
+        ]
+    )
+
+    targets = [Target("c")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert len(memory_pools.pools) == 2
+
+    assert memory_pools.pools[0].pool_name == "sram"
+    assert memory_pools.pools[0].size_hint_bytes == 1024
+    assert memory_pools.pools[0].write_latency_cycles == 500
+
+    assert memory_pools.pools[1].pool_name == "flash"
+    assert memory_pools.pools[1].size_hint_bytes == 2048
+    assert memory_pools.pools[1].write_latency_cycles == 1000
+
+
+def test_workspace_pools_recombobulate_multi_target():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-targets=sram:c",
+            "--workspace-pools-targets=sram:llvm",
+            "--workspace-pools-target-burst-bytes=sram:c:8,sram:llvm:4",
+        ]
+    )
+
+    c_target = Target("c")
+    llvm_target = Target("llvm")
+    extra_targets = []
+
+    targets = [c_target, llvm_target]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, extra_targets)
+
+    assert len(memory_pools.pools) == 1
+
+    assert len(memory_pools.pools[0].target_burst_bytes) == 2
+    assert memory_pools.pools[0].target_burst_bytes[c_target] == 8
+    assert memory_pools.pools[0].target_burst_bytes[llvm_target] == 4
+
+
+def test_workspace_pools_recombobulate_no_target_burst_bytes():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-targets=sram:c",
+            "--workspace-pools-target-burst-bytes=sram:c:8",
+        ]
+    )
+
+    c_target = Target("c")
+    targets = [c_target]
+
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+
+    assert len(memory_pools.pools) == 1
+    assert len(memory_pools.pools[0].target_burst_bytes) == 1
+    assert memory_pools.pools[0].target_burst_bytes[c_target] == 8
+
+
+def test_workspace_pools_recombobulate_missing_target():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+        ]
+    )
+
+    c_target = Target("c")
+    with pytest.raises(TVMCException):
+        workspace_pools_recombobulate(parsed, [c_target], _)
+
+
+def test_workspace_pools_recombobulate_multi_target_multi_pool():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-targets=sram:c",
+            "--workspace-pools-targets=sram:llvm",
+            "--workspace-pools-target-burst-bytes=sram:c:8,sram:llvm:4",
+        ]
+    )
+
+    c_target = Target("c")
+    llvm_target = Target("llvm")
+
+    targets = [c_target, llvm_target]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+
+    assert len(memory_pools.pools) == 1
+
+    assert len(memory_pools.pools[0].target_burst_bytes) == 2
+    assert memory_pools.pools[0].target_burst_bytes[llvm_target] == 4
+    assert memory_pools.pools[0].target_burst_bytes[c_target] == 8
+
+
+def test_workspace_pools_recombobulate_parameter_overrides():

Review Comment:
   ack! ill write a separate test that checks multiple pools but overriding just one of them



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] manupa-arm commented on pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
manupa-arm commented on PR #11427:
URL: https://github.com/apache/tvm/pull/11427#issuecomment-1170200186

   @tvm-bot rerun


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] dchauhan-arm commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
dchauhan-arm commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r891408260


##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(

Review Comment:
   I'm a little unsure by what you mean here, could you please elaborate? This approach using `parser.add_argument()` is taken from how other command line arguments are captured



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] dchauhan-arm commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
dchauhan-arm commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r891407931


##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(
+        "--workspace-pools",
+        help="""The name of the memory pool
+                Example usage: --workspace-pools=flash""",
+    )
+    parser.add_argument(
+        "--workspace-pools-size-hint-bytes",
+        nargs="?",
+        help="""The expected size hint to be used by the allocator.
+                Example usage: --workspace-pools-size-hint-bytes=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-access",
+        help="""A dictionary where keys describe which targets could
+                access the pool where value could take the values :
+                a) "rw" : read-write access
+                b) "ro" : write-only access
+                Example usage: --workspace-pools-target-access=flash:accel:ro""",
+    )
+    parser.add_argument(
+        "--workspace-pools-clock-frequency-hz",
+        nargs="?",
+        help="""The clock frequency that the memory pool runs at in Hz.
+                Example usage: --workspace-pools-clock-frequency-hz=flash:70000000""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The read bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-read-bandwidth-bytes-per-cycle=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The write bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-write-bandwidth-bytes-per-cycle=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-latency-cycles",
+        nargs="?",
+        help="""The read latency of the memory pool in cycles.
+                Example usage: --workspace-pools-read-latency-cycles=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-latency-cycles",
+        nargs="?",
+        help="""The write latency of the memory pool in cycles.
+                Example usage: --workspace-pools-write-latency-cycles=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-burst-bytes",
+        help="""The burst length of the memory pool in bytes per target.
+                Example usage: --workspace-pools-target-burst-bytes=flash:accel:1""",
+    )
+
+
+def _parse_target_burst(attr, pool_name):
+    if pool_name not in attr:
+        return {}
+
+    return {target: int(attr[pool_name][target]) for target in attr[pool_name]}
+
+
+def _parse_target_access(attr, pool_name):
+    try:
+        return attr[pool_name]
+    except:
+        raise TVMCException(f'Workspace Pool "{pool_name}" using undefined Target.')
+
+
+def _split_pools(attr):
+    return re.split(",", attr) if attr else []
+
+
+def _target_attributes_to_pools(attr, targets):
+    if not targets or attr is None:
+        return {}
+
+    target_attributes = {}
+    for pool_values in re.split(",", attr):
+        pool_name, target_name, target_value = re.split(":", pool_values)
+        if pool_name not in target_attributes:
+            target_attributes[pool_name] = {}
+
+        matched_targets = [target for target in targets if target_name == target.kind.name]
+        if matched_targets:
+            target_attributes[pool_name][matched_targets[0]] = target_value
+        else:
+            raise TVMCException(
+                "The workspace pool target specification for target access "
+                "needs to be the same TVM target as when specifying targets to use."
+            )
+
+    return target_attributes
+
+
+def _attribute_to_pools(attr):
+    return dict(pool.split(":", maxsplit=1) for pool in re.split(",", attr)) if attr else {}
+
+
+def workspace_pools_recombobulate(parsed, targets):
+    """Reconstructs the Workspace Pools args and returns a WorkspaceMemoryPool object"""
+    WORKSPACE_POOL_PARAMS = [

Review Comment:
   If they get out of sync, I agree with the comment you left below that PoolInfo should complain as that's what tvmc is wrapping



##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(
+        "--workspace-pools",
+        help="""The name of the memory pool
+                Example usage: --workspace-pools=flash""",
+    )
+    parser.add_argument(
+        "--workspace-pools-size-hint-bytes",
+        nargs="?",
+        help="""The expected size hint to be used by the allocator.
+                Example usage: --workspace-pools-size-hint-bytes=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-access",
+        help="""A dictionary where keys describe which targets could
+                access the pool where value could take the values :
+                a) "rw" : read-write access
+                b) "ro" : write-only access
+                Example usage: --workspace-pools-target-access=flash:accel:ro""",
+    )
+    parser.add_argument(
+        "--workspace-pools-clock-frequency-hz",
+        nargs="?",
+        help="""The clock frequency that the memory pool runs at in Hz.
+                Example usage: --workspace-pools-clock-frequency-hz=flash:70000000""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The read bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-read-bandwidth-bytes-per-cycle=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The write bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-write-bandwidth-bytes-per-cycle=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-latency-cycles",
+        nargs="?",
+        help="""The read latency of the memory pool in cycles.
+                Example usage: --workspace-pools-read-latency-cycles=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-latency-cycles",
+        nargs="?",
+        help="""The write latency of the memory pool in cycles.
+                Example usage: --workspace-pools-write-latency-cycles=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-burst-bytes",
+        help="""The burst length of the memory pool in bytes per target.
+                Example usage: --workspace-pools-target-burst-bytes=flash:accel:1""",
+    )
+
+
+def _parse_target_burst(attr, pool_name):
+    if pool_name not in attr:
+        return {}
+
+    return {target: int(attr[pool_name][target]) for target in attr[pool_name]}
+
+
+def _parse_target_access(attr, pool_name):
+    try:
+        return attr[pool_name]
+    except:
+        raise TVMCException(f'Workspace Pool "{pool_name}" using undefined Target.')
+
+
+def _split_pools(attr):
+    return re.split(",", attr) if attr else []
+
+
+def _target_attributes_to_pools(attr, targets):
+    if not targets or attr is None:
+        return {}
+
+    target_attributes = {}
+    for pool_values in re.split(",", attr):
+        pool_name, target_name, target_value = re.split(":", pool_values)
+        if pool_name not in target_attributes:
+            target_attributes[pool_name] = {}
+
+        matched_targets = [target for target in targets if target_name == target.kind.name]
+        if matched_targets:
+            target_attributes[pool_name][matched_targets[0]] = target_value
+        else:
+            raise TVMCException(
+                "The workspace pool target specification for target access "
+                "needs to be the same TVM target as when specifying targets to use."
+            )
+
+    return target_attributes
+
+
+def _attribute_to_pools(attr):
+    return dict(pool.split(":", maxsplit=1) for pool in re.split(",", attr)) if attr else {}
+
+
+def workspace_pools_recombobulate(parsed, targets):
+    """Reconstructs the Workspace Pools args and returns a WorkspaceMemoryPool object"""
+    WORKSPACE_POOL_PARAMS = [
+        "workspace_pools_size_hint_bytes",
+        "workspace_pools_target_access",
+        "workspace_pools_clock_frequency_hz",
+        "workspace_pools_read_bandwidth_bytes_per_cycle",
+        "workspace_pools_write_bandwidth_bytes_per_cycle",
+        "workspace_pools_read_latency_cycles",
+        "workspace_pools_write_latency_cycles",
+        "workspace_pools_target_burst_bytes",
+    ]
+    WORKSPACE_POOL_TARGET_PARAMS = [
+        "workspace_pools_target_access",
+        "workspace_pools_target_burst_bytes",
+    ]
+
+    workspace_pools = _split_pools(parsed.workspace_pools)
+    pool_to_attributes = {
+        workspace_pool_param: _attribute_to_pools(getattr(parsed, workspace_pool_param))
+        for workspace_pool_param in WORKSPACE_POOL_PARAMS
+    }
+    pool_to_target_attributes = {
+        workspace_pool_param: _target_attributes_to_pools(
+            getattr(parsed, workspace_pool_param), targets
+        )
+        for workspace_pool_param in WORKSPACE_POOL_TARGET_PARAMS
+    }
+
+    return WorkspaceMemoryPools(
+        [
+            PoolInfo(

Review Comment:
   I agree with this approach, if PoolInfo complained about an incorrect parameter being supplied then TVMC should complain 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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] areusch commented on pull request #11427: [TVMC] Workspace Pools Parameters

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

   @dchauhan-arm mention me when you're ready for another look here.


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] Mousius commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
Mousius commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r880228493


##########
tests/python/driver/tvmc/test_command_line.py:
##########
@@ -155,3 +162,39 @@ def test_tvmc_tune_file_check(capsys, invalid_input):
     )
     on_assert_error = f"'tvmc tune' failed to check invalid FILE: {invalid_input}"
     assert captured.err == expected_err, on_assert_error
+
+
+@mock.patch("tvm.relay.build")
+@mock.patch("tvm.driver.tvmc.load")
+@mock.patch("tvm.transform.PassContext")
+@mock.patch("tvm.driver.tvmc.model.TVMCPackage.__init__", return_value=None)
+@mock.patch("tvm.driver.tvmc.composite_target.get_codegen_by_target")
+def test_compile_check_workspace_pools(mock_ct, mock_pkg, mock_pc, mock_fe, mock_relay):
+    mock_codegen = {}
+    mock_codegen["config_key"] = "relay.ext.mock.options"
+    mock_codegen["pass_pipeline"] = lambda *args, **kwargs: None
+
+    mock_fe.return_value = mock.MagicMock()
+    mock_ct.return_value = mock_codegen
+    mock_relay.return_value = mock.MagicMock()
+
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-target-access=sram:llvm:ro",
+        ]
+    )
+
+    targets = [Target("llvm")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets)
+
+    tvmc_model = tvmc.load("no_file_needed")
+    tvmc.compile(
+        tvmc_model,
+        target="mockcodegen -testopt=value, llvm",
+        workspace_pools=memory_pools,
+    )
+
+    assert mock_relay.call_count == 1

Review Comment:
   We should add an `assert mock_relay.call_args_list[0].workspace_pools == memory_pools` to ensure `relay.build` is called with the right thing as well as being called.



##########
tests/python/driver/tvmc/test_command_line.py:
##########
@@ -155,3 +162,39 @@ def test_tvmc_tune_file_check(capsys, invalid_input):
     )
     on_assert_error = f"'tvmc tune' failed to check invalid FILE: {invalid_input}"
     assert captured.err == expected_err, on_assert_error
+
+
+@mock.patch("tvm.relay.build")
+@mock.patch("tvm.driver.tvmc.load")
+@mock.patch("tvm.transform.PassContext")
+@mock.patch("tvm.driver.tvmc.model.TVMCPackage.__init__", return_value=None)
+@mock.patch("tvm.driver.tvmc.composite_target.get_codegen_by_target")
+def test_compile_check_workspace_pools(mock_ct, mock_pkg, mock_pc, mock_fe, mock_relay):
+    mock_codegen = {}
+    mock_codegen["config_key"] = "relay.ext.mock.options"
+    mock_codegen["pass_pipeline"] = lambda *args, **kwargs: None
+
+    mock_fe.return_value = mock.MagicMock()
+    mock_ct.return_value = mock_codegen
+    mock_relay.return_value = mock.MagicMock()
+
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-target-access=sram:llvm:ro",
+        ]
+    )
+
+    targets = [Target("llvm")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets)

Review Comment:
   Could we create this with `memory_pools = WorkspacePoolInfo(...)` directly rather than re-parsing it here?



##########
tests/python/driver/tvmc/test_command_line.py:
##########
@@ -155,3 +162,39 @@ def test_tvmc_tune_file_check(capsys, invalid_input):
     )
     on_assert_error = f"'tvmc tune' failed to check invalid FILE: {invalid_input}"
     assert captured.err == expected_err, on_assert_error
+
+
+@mock.patch("tvm.relay.build")
+@mock.patch("tvm.driver.tvmc.load")
+@mock.patch("tvm.transform.PassContext")
+@mock.patch("tvm.driver.tvmc.model.TVMCPackage.__init__", return_value=None)
+@mock.patch("tvm.driver.tvmc.composite_target.get_codegen_by_target")
+def test_compile_check_workspace_pools(mock_ct, mock_pkg, mock_pc, mock_fe, mock_relay):

Review Comment:
   This would be better suited to `test_compiler.py` and another test here which calls `_main` with the workspace parameters in argument form.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] manupa-arm commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
manupa-arm commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r917750127


##########
tests/python/driver/tvmc/test_workspace_pools.py:
##########
@@ -0,0 +1,359 @@
+# 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.
+
+import pytest
+import argparse
+
+from tvm.driver.tvmc.workspace_pools import (
+    generate_workspace_pools_args,
+    workspace_pools_recombobulate,
+)
+from tvm.target import Target
+from tvm.driver.tvmc import TVMCException
+
+
+def test_workspace_pools_argparse():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, unparsed = parser.parse_known_args(
+        [
+            "--workspace-pools=sram,flash",
+            "--workspace-pools-targets=sram:c",
+            "--workspace-pools-targets=sram:llvm",
+            "--workspace-pools-targets=flash:c",
+            "--workspace-pools-size-hint-bytes=sram:400",
+            "--workspace-pools-size-hint-bytes=sram:500",
+            "--workspace-pools-clock-frequency-hz=sram:500",
+            "--workspace-pools-read-bandwidth-bytes-per-cycle=sram:200",
+            "--workspace-pools-write-bandwidth-bytes-per-cycle=sram:100",
+            "--workspace-pools-read-latency-cycles=sram:50",
+            "--workspace-pools-read-latency-cycles=flash:30",
+            "--workspace-pools-write-latency-cycles=sram:9001",
+            "--workspace-pools-target-burst-bytes=sram:c:2",
+            "--workspace-pools-is-internal=sram:0",
+        ]
+    )
+
+    assert parsed.workspace_pools == "sram,flash"
+    assert parsed.workspace_pools_targets == ["sram:c", "sram:llvm", "flash:c"]
+    assert parsed.workspace_pools_size_hint_bytes == ["sram:400", "sram:500"]
+    assert parsed.workspace_pools_clock_frequency_hz == ["sram:500"]
+    assert parsed.workspace_pools_read_bandwidth_bytes_per_cycle == ["sram:200"]
+    assert parsed.workspace_pools_write_bandwidth_bytes_per_cycle == ["sram:100"]
+    assert parsed.workspace_pools_read_latency_cycles == ["sram:50", "flash:30"]
+    assert parsed.workspace_pools_write_latency_cycles == ["sram:9001"]
+    assert parsed.workspace_pools_target_burst_bytes == ["sram:c:2"]
+
+    assert unparsed == ["--workspace-pools-is-internal=sram:0"]
+
+
+def test_workspace_pools_recombobulate_empty():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args([])
+
+    targets = [Target("llvm")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert memory_pools is None
+
+
+def test_workspace_pools_recombobulate():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-targets=sram:llvm",
+            "--workspace-pools-size-hint-bytes=sram:400",
+            "--workspace-pools-clock-frequency-hz=sram:500",
+        ]
+    )
+
+    targets = [Target("llvm")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert len(memory_pools.pools) == 1
+    assert memory_pools.pools[0].pool_name == "sram"
+    assert memory_pools.pools[0].size_hint_bytes == 400
+    assert memory_pools.pools[0].clock_frequency_hz == 500
+
+
+def test_workspace_pools_defaults():
+    parser = argparse.ArgumentParser()
+    targets = [Target("llvm")]
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-targets=sram:llvm",
+        ]
+    )
+
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert len(memory_pools.pools) == 1
+    assert memory_pools.pools[0].pool_name == "sram"
+    assert memory_pools.pools[0].size_hint_bytes == -1
+    assert memory_pools.pools[0].clock_frequency_hz == -1
+    assert memory_pools.pools[0].read_bandwidth_bytes_per_cycle == -1
+    assert memory_pools.pools[0].write_bandwidth_bytes_per_cycle == -1
+    assert memory_pools.pools[0].read_latency_cycles == 0
+    assert memory_pools.pools[0].write_latency_cycles == 0
+    assert len(memory_pools.pools[0].target_burst_bytes) == 0
+
+
+def test_workspace_pools_recombobulate_multi_fields():
+    parser = argparse.ArgumentParser()
+    targets = [Target("c")]
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-targets=sram:c",
+            "--workspace-pools-size-hint-bytes=sram:400",
+            "--workspace-pools-clock-frequency-hz=sram:500",
+            "--workspace-pools-read-bandwidth-bytes-per-cycle=sram:200",
+            "--workspace-pools-write-bandwidth-bytes-per-cycle=sram:100",
+            "--workspace-pools-read-latency-cycles=sram:50",
+            "--workspace-pools-write-latency-cycles=sram:9001",
+            "--workspace-pools-target-burst-bytes=sram:c:2",
+        ]
+    )
+
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert len(memory_pools.pools) == 1
+    assert memory_pools.pools[0].pool_name == "sram"
+    assert memory_pools.pools[0].size_hint_bytes == 400
+    assert memory_pools.pools[0].clock_frequency_hz == 500
+    assert memory_pools.pools[0].read_bandwidth_bytes_per_cycle == 200
+    assert memory_pools.pools[0].write_bandwidth_bytes_per_cycle == 100
+    assert memory_pools.pools[0].read_latency_cycles == 50
+    assert memory_pools.pools[0].write_latency_cycles == 9001
+    assert len(memory_pools.pools[0].target_burst_bytes) == 1
+    assert memory_pools.pools[0].target_burst_bytes[targets[0]] == 2
+
+
+def test_workspace_pools_recombobulate_multi_fields_variant():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=flash",
+            "--workspace-pools-targets=flash:c",
+            "--workspace-pools-size-hint-bytes=flash:2048",
+            "--workspace-pools-clock-frequency-hz=flash:2000000",
+            "--workspace-pools-read-bandwidth-bytes-per-cycle=flash:4",
+            "--workspace-pools-write-bandwidth-bytes-per-cycle=flash:1",
+            "--workspace-pools-read-latency-cycles=flash:2000",
+            "--workspace-pools-write-latency-cycles=flash:1000",
+            "--workspace-pools-target-burst-bytes=flash:c:4",
+        ]
+    )
+
+    targets = [Target("c")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert len(memory_pools.pools) == 1
+    assert memory_pools.pools[0].pool_name == "flash"
+    assert memory_pools.pools[0].size_hint_bytes == 2048
+    assert memory_pools.pools[0].clock_frequency_hz == 2000000
+    assert memory_pools.pools[0].read_bandwidth_bytes_per_cycle == 4
+    assert memory_pools.pools[0].write_bandwidth_bytes_per_cycle == 1
+    assert memory_pools.pools[0].read_latency_cycles == 2000
+    assert memory_pools.pools[0].write_latency_cycles == 1000
+    assert len(memory_pools.pools[0].target_burst_bytes) == 1
+    assert memory_pools.pools[0].target_burst_bytes[targets[0]] == 4
+
+
+def test_workspace_pools_recombobulate_multi_fields_multi_pools():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram,flash",
+            "--workspace-pools-targets=sram:c,flash:c",
+            "--workspace-pools-size-hint-bytes=sram:1024,flash:2048",
+            "--workspace-pools-clock-frequency-hz=sram:4000000,flash:2000000",
+            "--workspace-pools-read-bandwidth-bytes-per-cycle=sram:8,flash:4",
+            "--workspace-pools-write-bandwidth-bytes-per-cycle=sram:4,flash:1",
+            "--workspace-pools-read-latency-cycles=sram:250,flash:2000",
+            "--workspace-pools-write-latency-cycles=sram:500,flash:1000",
+            "--workspace-pools-target-burst-bytes=sram:c:8,flash:c:4",
+        ]
+    )
+
+    targets = [Target("c")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert len(memory_pools.pools) == 2
+
+    assert memory_pools.pools[0].pool_name == "sram"
+    assert memory_pools.pools[0].size_hint_bytes == 1024
+    assert memory_pools.pools[0].clock_frequency_hz == 4000000
+    assert memory_pools.pools[0].read_bandwidth_bytes_per_cycle == 8
+    assert memory_pools.pools[0].write_bandwidth_bytes_per_cycle == 4
+    assert memory_pools.pools[0].read_latency_cycles == 250
+    assert memory_pools.pools[0].write_latency_cycles == 500
+    assert len(memory_pools.pools[0].target_burst_bytes) == 1
+    assert memory_pools.pools[0].target_burst_bytes[targets[0]] == 8
+
+    assert memory_pools.pools[1].pool_name == "flash"
+    assert memory_pools.pools[1].size_hint_bytes == 2048
+    assert memory_pools.pools[1].clock_frequency_hz == 2000000
+    assert memory_pools.pools[1].read_bandwidth_bytes_per_cycle == 4
+    assert memory_pools.pools[1].write_bandwidth_bytes_per_cycle == 1
+    assert memory_pools.pools[1].read_latency_cycles == 2000
+    assert memory_pools.pools[1].write_latency_cycles == 1000
+    assert len(memory_pools.pools[1].target_burst_bytes) == 1
+    assert memory_pools.pools[1].target_burst_bytes[targets[0]] == 4
+
+
+def test_workspace_pools_recombobulate_multi_fields_ordering():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram,flash",
+            "--workspace-pools-targets=flash:c,sram:c",
+            "--workspace-pools-size-hint-bytes=flash:2048,sram:1024",
+            "--workspace-pools-clock-frequency-hz=sram:4000000,flash:2000000",
+            "--workspace-pools-read-bandwidth-bytes-per-cycle=sram:8,flash:4",
+            "--workspace-pools-write-bandwidth-bytes-per-cycle=sram:4,flash:1",
+            "--workspace-pools-read-latency-cycles=sram:250,flash:2000",
+            "--workspace-pools-write-latency-cycles=flash:1000,sram:500",
+            "--workspace-pools-target-burst-bytes=sram:c:8,flash:c:4",
+        ]
+    )
+
+    targets = [Target("c")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+    assert len(memory_pools.pools) == 2
+
+    assert memory_pools.pools[0].pool_name == "sram"
+    assert memory_pools.pools[0].size_hint_bytes == 1024
+    assert memory_pools.pools[0].write_latency_cycles == 500
+
+    assert memory_pools.pools[1].pool_name == "flash"
+    assert memory_pools.pools[1].size_hint_bytes == 2048
+    assert memory_pools.pools[1].write_latency_cycles == 1000
+
+
+def test_workspace_pools_recombobulate_multi_target():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-targets=sram:c",
+            "--workspace-pools-targets=sram:llvm",
+            "--workspace-pools-target-burst-bytes=sram:c:8,sram:llvm:4",
+        ]
+    )
+
+    c_target = Target("c")
+    llvm_target = Target("llvm")
+    extra_targets = []
+
+    targets = [c_target, llvm_target]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, extra_targets)
+
+    assert len(memory_pools.pools) == 1
+
+    assert len(memory_pools.pools[0].target_burst_bytes) == 2
+    assert memory_pools.pools[0].target_burst_bytes[c_target] == 8
+    assert memory_pools.pools[0].target_burst_bytes[llvm_target] == 4
+
+
+def test_workspace_pools_recombobulate_no_target_burst_bytes():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-targets=sram:c",
+            "--workspace-pools-target-burst-bytes=sram:c:8",
+        ]
+    )
+
+    c_target = Target("c")
+    targets = [c_target]
+
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+
+    assert len(memory_pools.pools) == 1
+    assert len(memory_pools.pools[0].target_burst_bytes) == 1
+    assert memory_pools.pools[0].target_burst_bytes[c_target] == 8
+
+
+def test_workspace_pools_recombobulate_missing_target():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+        ]
+    )
+
+    c_target = Target("c")
+    with pytest.raises(TVMCException):
+        workspace_pools_recombobulate(parsed, [c_target], _)
+
+
+def test_workspace_pools_recombobulate_multi_target_multi_pool():
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-targets=sram:c",
+            "--workspace-pools-targets=sram:llvm",
+            "--workspace-pools-target-burst-bytes=sram:c:8,sram:llvm:4",
+        ]
+    )
+
+    c_target = Target("c")
+    llvm_target = Target("llvm")
+
+    targets = [c_target, llvm_target]
+    memory_pools = workspace_pools_recombobulate(parsed, targets, _)
+
+    assert len(memory_pools.pools) == 1
+
+    assert len(memory_pools.pools[0].target_burst_bytes) == 2
+    assert memory_pools.pools[0].target_burst_bytes[llvm_target] == 4
+    assert memory_pools.pools[0].target_burst_bytes[c_target] == 8
+
+
+def test_workspace_pools_recombobulate_parameter_overrides():

Review Comment:
   We would need a test case with multiple pools and a override that changes just a single pool



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] manupa-arm commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
manupa-arm commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r903451308


##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(
+        "--workspace-pools",
+        help="""The name of the memory pool
+                Example usage: --workspace-pools=flash""",
+    )
+    parser.add_argument(
+        "--workspace-pools-size-hint-bytes",
+        nargs="?",
+        help="""The expected size hint to be used by the allocator.
+                Example usage: --workspace-pools-size-hint-bytes=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-access",
+        help="""A dictionary where keys describe which targets could
+                access the pool where value could take the values :
+                a) "rw" : read-write access
+                b) "ro" : write-only access
+                Example usage: --workspace-pools-target-access=flash:accel:ro""",
+    )
+    parser.add_argument(
+        "--workspace-pools-clock-frequency-hz",
+        nargs="?",
+        help="""The clock frequency that the memory pool runs at in Hz.
+                Example usage: --workspace-pools-clock-frequency-hz=flash:70000000""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The read bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-read-bandwidth-bytes-per-cycle=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The write bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-write-bandwidth-bytes-per-cycle=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-latency-cycles",
+        nargs="?",
+        help="""The read latency of the memory pool in cycles.
+                Example usage: --workspace-pools-read-latency-cycles=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-latency-cycles",
+        nargs="?",
+        help="""The write latency of the memory pool in cycles.
+                Example usage: --workspace-pools-write-latency-cycles=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-burst-bytes",
+        help="""The burst length of the memory pool in bytes per target.
+                Example usage: --workspace-pools-target-burst-bytes=flash:accel:1""",
+    )
+
+
+def _parse_target_burst(attr, pool_name):
+    if pool_name not in attr:
+        return {}
+
+    return {target: int(attr[pool_name][target]) for target in attr[pool_name]}
+
+
+def _parse_target_access(attr, pool_name):
+    try:
+        return attr[pool_name]
+    except:
+        raise TVMCException(f'Workspace Pool "{pool_name}" using undefined Target.')
+
+
+def _split_pools(attr):
+    return re.split(",", attr) if attr else []
+
+
+def _target_attributes_to_pools(attr, targets):
+    if not targets or attr is None:
+        return {}
+
+    target_attributes = {}
+    for pool_values in re.split(",", attr):
+        pool_name, target_name, target_value = re.split(":", pool_values)
+        if pool_name not in target_attributes:
+            target_attributes[pool_name] = {}
+
+        matched_targets = [target for target in targets if target_name == target.kind.name]
+        if matched_targets:
+            target_attributes[pool_name][matched_targets[0]] = target_value
+        else:
+            raise TVMCException(
+                "The workspace pool target specification for target access "
+                "needs to be the same TVM target as when specifying targets to use."
+            )
+
+    return target_attributes
+
+
+def _attribute_to_pools(attr):
+    return dict(pool.split(":", maxsplit=1) for pool in re.split(",", attr)) if attr else {}
+
+
+def workspace_pools_recombobulate(parsed, targets):
+    """Reconstructs the Workspace Pools args and returns a WorkspaceMemoryPool object"""
+    WORKSPACE_POOL_PARAMS = [
+        "workspace_pools_size_hint_bytes",
+        "workspace_pools_target_access",
+        "workspace_pools_clock_frequency_hz",
+        "workspace_pools_read_bandwidth_bytes_per_cycle",
+        "workspace_pools_write_bandwidth_bytes_per_cycle",
+        "workspace_pools_read_latency_cycles",
+        "workspace_pools_write_latency_cycles",
+        "workspace_pools_target_burst_bytes",
+    ]
+    WORKSPACE_POOL_TARGET_PARAMS = [
+        "workspace_pools_target_access",
+        "workspace_pools_target_burst_bytes",
+    ]
+
+    workspace_pools = _split_pools(parsed.workspace_pools)
+    pool_to_attributes = {
+        workspace_pool_param: _attribute_to_pools(getattr(parsed, workspace_pool_param))
+        for workspace_pool_param in WORKSPACE_POOL_PARAMS
+    }
+    pool_to_target_attributes = {
+        workspace_pool_param: _target_attributes_to_pools(
+            getattr(parsed, workspace_pool_param), targets
+        )
+        for workspace_pool_param in WORKSPACE_POOL_TARGET_PARAMS
+    }
+
+    return WorkspaceMemoryPools(
+        [
+            PoolInfo(

Review Comment:
   I think we still need to keep-in-sync comment because PoolInfo could be added by arguments with defaults and tvmc support for that could be missed out.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] dchauhan-arm commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
dchauhan-arm commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r880715294


##########
tests/python/driver/tvmc/test_command_line.py:
##########
@@ -155,3 +162,39 @@ def test_tvmc_tune_file_check(capsys, invalid_input):
     )
     on_assert_error = f"'tvmc tune' failed to check invalid FILE: {invalid_input}"
     assert captured.err == expected_err, on_assert_error
+
+
+@mock.patch("tvm.relay.build")
+@mock.patch("tvm.driver.tvmc.load")
+@mock.patch("tvm.transform.PassContext")
+@mock.patch("tvm.driver.tvmc.model.TVMCPackage.__init__", return_value=None)
+@mock.patch("tvm.driver.tvmc.composite_target.get_codegen_by_target")
+def test_compile_check_workspace_pools(mock_ct, mock_pkg, mock_pc, mock_fe, mock_relay):
+    mock_codegen = {}
+    mock_codegen["config_key"] = "relay.ext.mock.options"
+    mock_codegen["pass_pipeline"] = lambda *args, **kwargs: None
+
+    mock_fe.return_value = mock.MagicMock()
+    mock_ct.return_value = mock_codegen
+    mock_relay.return_value = mock.MagicMock()
+
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-target-access=sram:llvm:ro",
+        ]
+    )
+
+    targets = [Target("llvm")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets)
+
+    tvmc_model = tvmc.load("no_file_needed")
+    tvmc.compile(
+        tvmc_model,
+        target="mockcodegen -testopt=value, llvm",
+        workspace_pools=memory_pools,
+    )
+
+    assert mock_relay.call_count == 1

Review Comment:
   ack



##########
tests/python/driver/tvmc/test_command_line.py:
##########
@@ -155,3 +162,39 @@ def test_tvmc_tune_file_check(capsys, invalid_input):
     )
     on_assert_error = f"'tvmc tune' failed to check invalid FILE: {invalid_input}"
     assert captured.err == expected_err, on_assert_error
+
+
+@mock.patch("tvm.relay.build")
+@mock.patch("tvm.driver.tvmc.load")
+@mock.patch("tvm.transform.PassContext")
+@mock.patch("tvm.driver.tvmc.model.TVMCPackage.__init__", return_value=None)
+@mock.patch("tvm.driver.tvmc.composite_target.get_codegen_by_target")
+def test_compile_check_workspace_pools(mock_ct, mock_pkg, mock_pc, mock_fe, mock_relay):
+    mock_codegen = {}
+    mock_codegen["config_key"] = "relay.ext.mock.options"
+    mock_codegen["pass_pipeline"] = lambda *args, **kwargs: None
+
+    mock_fe.return_value = mock.MagicMock()
+    mock_ct.return_value = mock_codegen
+    mock_relay.return_value = mock.MagicMock()
+
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-target-access=sram:llvm:ro",
+        ]
+    )
+
+    targets = [Target("llvm")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets)

Review Comment:
   ack



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] dchauhan-arm commented on pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
dchauhan-arm commented on PR #11427:
URL: https://github.com/apache/tvm/pull/11427#issuecomment-1135535583

   cc @leandron @manupa-arm @areusch 


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] dchauhan-arm commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
dchauhan-arm commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r880716088


##########
tests/python/driver/tvmc/test_command_line.py:
##########
@@ -155,3 +162,39 @@ def test_tvmc_tune_file_check(capsys, invalid_input):
     )
     on_assert_error = f"'tvmc tune' failed to check invalid FILE: {invalid_input}"
     assert captured.err == expected_err, on_assert_error
+
+
+@mock.patch("tvm.relay.build")
+@mock.patch("tvm.driver.tvmc.load")
+@mock.patch("tvm.transform.PassContext")
+@mock.patch("tvm.driver.tvmc.model.TVMCPackage.__init__", return_value=None)
+@mock.patch("tvm.driver.tvmc.composite_target.get_codegen_by_target")
+def test_compile_check_workspace_pools(mock_ct, mock_pkg, mock_pc, mock_fe, mock_relay):

Review Comment:
   ack to both moving the test and a different test for `test_command_line.py`



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] leandron merged pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
leandron merged PR #11427:
URL: https://github.com/apache/tvm/pull/11427


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] manupa-arm commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
manupa-arm commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r903483325


##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(
+        "--workspace-pools",
+        help="""The name of the memory pool
+                Example usage: --workspace-pools=flash""",
+    )
+    parser.add_argument(
+        "--workspace-pools-size-hint-bytes",
+        nargs="?",
+        help="""The expected size hint to be used by the allocator.
+                Example usage: --workspace-pools-size-hint-bytes=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-access",
+        help="""A dictionary where keys describe which targets could
+                access the pool where value could take the values :
+                a) "rw" : read-write access
+                b) "ro" : write-only access
+                Example usage: --workspace-pools-target-access=flash:accel:ro""",
+    )
+    parser.add_argument(
+        "--workspace-pools-clock-frequency-hz",
+        nargs="?",
+        help="""The clock frequency that the memory pool runs at in Hz.
+                Example usage: --workspace-pools-clock-frequency-hz=flash:70000000""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The read bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-read-bandwidth-bytes-per-cycle=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The write bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-write-bandwidth-bytes-per-cycle=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-latency-cycles",
+        nargs="?",
+        help="""The read latency of the memory pool in cycles.
+                Example usage: --workspace-pools-read-latency-cycles=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-latency-cycles",
+        nargs="?",
+        help="""The write latency of the memory pool in cycles.
+                Example usage: --workspace-pools-write-latency-cycles=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-burst-bytes",
+        help="""The burst length of the memory pool in bytes per target.
+                Example usage: --workspace-pools-target-burst-bytes=flash:accel:1""",
+    )
+
+
+def _parse_target_burst(attr, pool_name):
+    if pool_name not in attr:
+        return {}
+
+    return {target: int(attr[pool_name][target]) for target in attr[pool_name]}
+
+
+def _parse_target_access(attr, pool_name):
+    try:
+        return attr[pool_name]
+    except:
+        raise TVMCException(f'Workspace Pool "{pool_name}" using undefined Target.')
+
+
+def _split_pools(attr):
+    return re.split(",", attr) if attr else []
+
+
+def _target_attributes_to_pools(attr, targets):
+    if not targets or attr is None:
+        return {}
+
+    target_attributes = {}
+    for pool_values in re.split(",", attr):
+        pool_name, target_name, target_value = re.split(":", pool_values)
+        if pool_name not in target_attributes:
+            target_attributes[pool_name] = {}
+
+        matched_targets = [target for target in targets if target_name == target.kind.name]
+        if matched_targets:
+            target_attributes[pool_name][matched_targets[0]] = target_value
+        else:
+            raise TVMCException(
+                "The workspace pool target specification for target access "
+                "needs to be the same TVM target as when specifying targets to use."
+            )
+
+    return target_attributes
+
+
+def _attribute_to_pools(attr):
+    return dict(pool.split(":", maxsplit=1) for pool in re.split(",", attr)) if attr else {}
+
+
+def workspace_pools_recombobulate(parsed, targets):
+    """Reconstructs the Workspace Pools args and returns a WorkspaceMemoryPool object"""
+    WORKSPACE_POOL_PARAMS = [
+        "workspace_pools_size_hint_bytes",
+        "workspace_pools_target_access",
+        "workspace_pools_clock_frequency_hz",
+        "workspace_pools_read_bandwidth_bytes_per_cycle",
+        "workspace_pools_write_bandwidth_bytes_per_cycle",
+        "workspace_pools_read_latency_cycles",
+        "workspace_pools_write_latency_cycles",
+        "workspace_pools_target_burst_bytes",
+    ]
+    WORKSPACE_POOL_TARGET_PARAMS = [
+        "workspace_pools_target_access",
+        "workspace_pools_target_burst_bytes",
+    ]
+
+    workspace_pools = _split_pools(parsed.workspace_pools)
+    pool_to_attributes = {
+        workspace_pool_param: _attribute_to_pools(getattr(parsed, workspace_pool_param))
+        for workspace_pool_param in WORKSPACE_POOL_PARAMS
+    }
+    pool_to_target_attributes = {
+        workspace_pool_param: _target_attributes_to_pools(
+            getattr(parsed, workspace_pool_param), targets
+        )
+        for workspace_pool_param in WORKSPACE_POOL_TARGET_PARAMS
+    }
+
+    return WorkspaceMemoryPools(
+        [
+            PoolInfo(

Review Comment:
   My concern was PoolInfo could be augmented with new parameters with defaults and we could easily miss those out in the tvmc layer. Having the comment will help the author and the reviewer to not to miss them out in the tvmc layer.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] manupa-arm commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
manupa-arm commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r905195817


##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(
+        "--workspace-pools",
+        help="""The name of the memory pool
+                Example usage: --workspace-pools=flash""",
+    )
+    parser.add_argument(
+        "--workspace-pools-size-hint-bytes",
+        nargs="?",
+        help="""The expected size hint to be used by the allocator.
+                Example usage: --workspace-pools-size-hint-bytes=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-access",
+        help="""A dictionary where keys describe which targets could
+                access the pool where value could take the values :
+                a) "rw" : read-write access
+                b) "ro" : write-only access
+                Example usage: --workspace-pools-target-access=flash:accel:ro""",
+    )
+    parser.add_argument(
+        "--workspace-pools-clock-frequency-hz",
+        nargs="?",
+        help="""The clock frequency that the memory pool runs at in Hz.
+                Example usage: --workspace-pools-clock-frequency-hz=flash:70000000""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The read bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-read-bandwidth-bytes-per-cycle=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The write bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-write-bandwidth-bytes-per-cycle=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-latency-cycles",
+        nargs="?",
+        help="""The read latency of the memory pool in cycles.
+                Example usage: --workspace-pools-read-latency-cycles=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-latency-cycles",
+        nargs="?",
+        help="""The write latency of the memory pool in cycles.
+                Example usage: --workspace-pools-write-latency-cycles=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-burst-bytes",
+        help="""The burst length of the memory pool in bytes per target.
+                Example usage: --workspace-pools-target-burst-bytes=flash:accel:1""",
+    )
+
+
+def _parse_target_burst(attr, pool_name):
+    if pool_name not in attr:
+        return {}
+
+    return {target: int(attr[pool_name][target]) for target in attr[pool_name]}
+
+
+def _parse_target_access(attr, pool_name):
+    try:
+        return attr[pool_name]
+    except:
+        raise TVMCException(f'Workspace Pool "{pool_name}" using undefined Target.')
+
+
+def _split_pools(attr):
+    return re.split(",", attr) if attr else []
+
+
+def _target_attributes_to_pools(attr, targets):
+    if not targets or attr is None:
+        return {}
+
+    target_attributes = {}
+    for pool_values in re.split(",", attr):
+        pool_name, target_name, target_value = re.split(":", pool_values)
+        if pool_name not in target_attributes:
+            target_attributes[pool_name] = {}
+
+        matched_targets = [target for target in targets if target_name == target.kind.name]
+        if matched_targets:
+            target_attributes[pool_name][matched_targets[0]] = target_value
+        else:
+            raise TVMCException(
+                "The workspace pool target specification for target access "
+                "needs to be the same TVM target as when specifying targets to use."
+            )
+
+    return target_attributes
+
+
+def _attribute_to_pools(attr):
+    return dict(pool.split(":", maxsplit=1) for pool in re.split(",", attr)) if attr else {}
+
+
+def workspace_pools_recombobulate(parsed, targets):
+    """Reconstructs the Workspace Pools args and returns a WorkspaceMemoryPool object"""
+    WORKSPACE_POOL_PARAMS = [
+        "workspace_pools_size_hint_bytes",
+        "workspace_pools_target_access",
+        "workspace_pools_clock_frequency_hz",
+        "workspace_pools_read_bandwidth_bytes_per_cycle",
+        "workspace_pools_write_bandwidth_bytes_per_cycle",
+        "workspace_pools_read_latency_cycles",
+        "workspace_pools_write_latency_cycles",
+        "workspace_pools_target_burst_bytes",
+    ]
+    WORKSPACE_POOL_TARGET_PARAMS = [
+        "workspace_pools_target_access",
+        "workspace_pools_target_burst_bytes",
+    ]
+
+    workspace_pools = _split_pools(parsed.workspace_pools)
+    pool_to_attributes = {
+        workspace_pool_param: _attribute_to_pools(getattr(parsed, workspace_pool_param))
+        for workspace_pool_param in WORKSPACE_POOL_PARAMS
+    }
+    pool_to_target_attributes = {
+        workspace_pool_param: _target_attributes_to_pools(
+            getattr(parsed, workspace_pool_param), targets
+        )
+        for workspace_pool_param in WORKSPACE_POOL_TARGET_PARAMS
+    }
+
+    return WorkspaceMemoryPools(
+        [
+            PoolInfo(

Review Comment:
   Oh we only need the keep-in-sync comment at the PoolInfo side and not here, because "PoolInfo will get upset if you pass incorrect properties".



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] Mousius commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
Mousius commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r903475832


##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(
+        "--workspace-pools",
+        help="""The name of the memory pool
+                Example usage: --workspace-pools=flash""",
+    )
+    parser.add_argument(
+        "--workspace-pools-size-hint-bytes",
+        nargs="?",
+        help="""The expected size hint to be used by the allocator.
+                Example usage: --workspace-pools-size-hint-bytes=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-access",
+        help="""A dictionary where keys describe which targets could
+                access the pool where value could take the values :
+                a) "rw" : read-write access
+                b) "ro" : write-only access
+                Example usage: --workspace-pools-target-access=flash:accel:ro""",
+    )
+    parser.add_argument(
+        "--workspace-pools-clock-frequency-hz",
+        nargs="?",
+        help="""The clock frequency that the memory pool runs at in Hz.
+                Example usage: --workspace-pools-clock-frequency-hz=flash:70000000""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The read bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-read-bandwidth-bytes-per-cycle=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The write bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-write-bandwidth-bytes-per-cycle=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-latency-cycles",
+        nargs="?",
+        help="""The read latency of the memory pool in cycles.
+                Example usage: --workspace-pools-read-latency-cycles=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-latency-cycles",
+        nargs="?",
+        help="""The write latency of the memory pool in cycles.
+                Example usage: --workspace-pools-write-latency-cycles=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-burst-bytes",
+        help="""The burst length of the memory pool in bytes per target.
+                Example usage: --workspace-pools-target-burst-bytes=flash:accel:1""",
+    )
+
+
+def _parse_target_burst(attr, pool_name):
+    if pool_name not in attr:
+        return {}
+
+    return {target: int(attr[pool_name][target]) for target in attr[pool_name]}
+
+
+def _parse_target_access(attr, pool_name):
+    try:
+        return attr[pool_name]
+    except:
+        raise TVMCException(f'Workspace Pool "{pool_name}" using undefined Target.')
+
+
+def _split_pools(attr):
+    return re.split(",", attr) if attr else []
+
+
+def _target_attributes_to_pools(attr, targets):
+    if not targets or attr is None:
+        return {}
+
+    target_attributes = {}
+    for pool_values in re.split(",", attr):
+        pool_name, target_name, target_value = re.split(":", pool_values)
+        if pool_name not in target_attributes:
+            target_attributes[pool_name] = {}
+
+        matched_targets = [target for target in targets if target_name == target.kind.name]
+        if matched_targets:
+            target_attributes[pool_name][matched_targets[0]] = target_value
+        else:
+            raise TVMCException(
+                "The workspace pool target specification for target access "
+                "needs to be the same TVM target as when specifying targets to use."
+            )
+
+    return target_attributes
+
+
+def _attribute_to_pools(attr):
+    return dict(pool.split(":", maxsplit=1) for pool in re.split(",", attr)) if attr else {}
+
+
+def workspace_pools_recombobulate(parsed, targets):
+    """Reconstructs the Workspace Pools args and returns a WorkspaceMemoryPool object"""
+    WORKSPACE_POOL_PARAMS = [
+        "workspace_pools_size_hint_bytes",
+        "workspace_pools_target_access",
+        "workspace_pools_clock_frequency_hz",
+        "workspace_pools_read_bandwidth_bytes_per_cycle",
+        "workspace_pools_write_bandwidth_bytes_per_cycle",
+        "workspace_pools_read_latency_cycles",
+        "workspace_pools_write_latency_cycles",
+        "workspace_pools_target_burst_bytes",
+    ]
+    WORKSPACE_POOL_TARGET_PARAMS = [
+        "workspace_pools_target_access",
+        "workspace_pools_target_burst_bytes",
+    ]
+
+    workspace_pools = _split_pools(parsed.workspace_pools)
+    pool_to_attributes = {
+        workspace_pool_param: _attribute_to_pools(getattr(parsed, workspace_pool_param))
+        for workspace_pool_param in WORKSPACE_POOL_PARAMS
+    }
+    pool_to_target_attributes = {
+        workspace_pool_param: _target_attributes_to_pools(
+            getattr(parsed, workspace_pool_param), targets
+        )
+        for workspace_pool_param in WORKSPACE_POOL_TARGET_PARAMS
+    }
+
+    return WorkspaceMemoryPools(
+        [
+            PoolInfo(

Review Comment:
   From my point of view:
   1. `PoolInfo` has documented properties
   2. `PoolInfo` will get upset if you pass incorrect properties
   3. `tvmc` arguments are documented 
   
   I don't really see the need to add an additional comment to link these together? I don't think we do this for the tuning parameters either: https://github.com/apache/tvm/blob/main/python/tvm/driver/tvmc/autotuner.py ? 



##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(
+        "--workspace-pools",
+        help="""The name of the memory pool
+                Example usage: --workspace-pools=flash""",
+    )
+    parser.add_argument(
+        "--workspace-pools-size-hint-bytes",
+        nargs="?",
+        help="""The expected size hint to be used by the allocator.
+                Example usage: --workspace-pools-size-hint-bytes=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-access",
+        help="""A dictionary where keys describe which targets could
+                access the pool where value could take the values :
+                a) "rw" : read-write access
+                b) "ro" : write-only access
+                Example usage: --workspace-pools-target-access=flash:accel:ro""",
+    )
+    parser.add_argument(
+        "--workspace-pools-clock-frequency-hz",
+        nargs="?",
+        help="""The clock frequency that the memory pool runs at in Hz.
+                Example usage: --workspace-pools-clock-frequency-hz=flash:70000000""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The read bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-read-bandwidth-bytes-per-cycle=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The write bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-write-bandwidth-bytes-per-cycle=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-latency-cycles",
+        nargs="?",
+        help="""The read latency of the memory pool in cycles.
+                Example usage: --workspace-pools-read-latency-cycles=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-latency-cycles",
+        nargs="?",
+        help="""The write latency of the memory pool in cycles.
+                Example usage: --workspace-pools-write-latency-cycles=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-burst-bytes",
+        help="""The burst length of the memory pool in bytes per target.
+                Example usage: --workspace-pools-target-burst-bytes=flash:accel:1""",
+    )
+
+
+def _parse_target_burst(attr, pool_name):
+    if pool_name not in attr:
+        return {}
+
+    return {target: int(attr[pool_name][target]) for target in attr[pool_name]}
+
+
+def _parse_target_access(attr, pool_name):
+    try:
+        return attr[pool_name]
+    except:
+        raise TVMCException(f'Workspace Pool "{pool_name}" using undefined Target.')
+
+
+def _split_pools(attr):
+    return re.split(",", attr) if attr else []
+
+
+def _target_attributes_to_pools(attr, targets):
+    if not targets or attr is None:
+        return {}
+
+    target_attributes = {}
+    for pool_values in re.split(",", attr):
+        pool_name, target_name, target_value = re.split(":", pool_values)
+        if pool_name not in target_attributes:
+            target_attributes[pool_name] = {}
+
+        matched_targets = [target for target in targets if target_name == target.kind.name]
+        if matched_targets:
+            target_attributes[pool_name][matched_targets[0]] = target_value
+        else:
+            raise TVMCException(
+                "The workspace pool target specification for target access "
+                "needs to be the same TVM target as when specifying targets to use."
+            )
+
+    return target_attributes
+
+
+def _attribute_to_pools(attr):
+    return dict(pool.split(":", maxsplit=1) for pool in re.split(",", attr)) if attr else {}
+
+
+def workspace_pools_recombobulate(parsed, targets):
+    """Reconstructs the Workspace Pools args and returns a WorkspaceMemoryPool object"""
+    WORKSPACE_POOL_PARAMS = [
+        "workspace_pools_size_hint_bytes",
+        "workspace_pools_target_access",
+        "workspace_pools_clock_frequency_hz",
+        "workspace_pools_read_bandwidth_bytes_per_cycle",
+        "workspace_pools_write_bandwidth_bytes_per_cycle",
+        "workspace_pools_read_latency_cycles",
+        "workspace_pools_write_latency_cycles",
+        "workspace_pools_target_burst_bytes",
+    ]
+    WORKSPACE_POOL_TARGET_PARAMS = [
+        "workspace_pools_target_access",
+        "workspace_pools_target_burst_bytes",
+    ]
+
+    workspace_pools = _split_pools(parsed.workspace_pools)
+    pool_to_attributes = {
+        workspace_pool_param: _attribute_to_pools(getattr(parsed, workspace_pool_param))
+        for workspace_pool_param in WORKSPACE_POOL_PARAMS
+    }
+    pool_to_target_attributes = {
+        workspace_pool_param: _target_attributes_to_pools(
+            getattr(parsed, workspace_pool_param), targets
+        )
+        for workspace_pool_param in WORKSPACE_POOL_TARGET_PARAMS
+    }
+
+    return WorkspaceMemoryPools(
+        [
+            PoolInfo(

Review Comment:
   1. `PoolInfo` has documented properties
   2. `PoolInfo` will get upset if you pass incorrect properties
   3. `tvmc` arguments are documented 
   
   I don't really see the need to add an additional comment to link these together? I don't think we do this for the tuning parameters either: https://github.com/apache/tvm/blob/main/python/tvm/driver/tvmc/autotuner.py ? 



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] manupa-arm commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Posted by GitBox <gi...@apache.org>.
manupa-arm commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r903451308


##########
python/tvm/driver/tvmc/workspace_pools.py:
##########
@@ -0,0 +1,199 @@
+# 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.
+"""
+Functions for processing dynamic workspace pool TVMC args
+"""
+
+
+import logging
+import re
+
+from tvm.driver.tvmc import TVMCException
+from tvm.ir.memory_pools import PoolInfo, WorkspaceMemoryPools
+
+
+# pylint: disable=invalid-name
+logger = logging.getLogger("TVMC")
+
+
+def generate_workspace_pools_args(parser):
+    """Generates arguments for each Workspace Pools's options"""
+    parser.add_argument(
+        "--workspace-pools",
+        help="""The name of the memory pool
+                Example usage: --workspace-pools=flash""",
+    )
+    parser.add_argument(
+        "--workspace-pools-size-hint-bytes",
+        nargs="?",
+        help="""The expected size hint to be used by the allocator.
+                Example usage: --workspace-pools-size-hint-bytes=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-access",
+        help="""A dictionary where keys describe which targets could
+                access the pool where value could take the values :
+                a) "rw" : read-write access
+                b) "ro" : write-only access
+                Example usage: --workspace-pools-target-access=flash:accel:ro""",
+    )
+    parser.add_argument(
+        "--workspace-pools-clock-frequency-hz",
+        nargs="?",
+        help="""The clock frequency that the memory pool runs at in Hz.
+                Example usage: --workspace-pools-clock-frequency-hz=flash:70000000""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The read bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-read-bandwidth-bytes-per-cycle=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-bandwidth-bytes-per-cycle",
+        nargs="?",
+        help="""The write bandwidth of the memory pool in bytes/cycle.
+                Example usage: --workspace-pools-write-bandwidth-bytes-per-cycle=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-read-latency-cycles",
+        nargs="?",
+        help="""The read latency of the memory pool in cycles.
+                Example usage: --workspace-pools-read-latency-cycles=flash:4""",
+    )
+    parser.add_argument(
+        "--workspace-pools-write-latency-cycles",
+        nargs="?",
+        help="""The write latency of the memory pool in cycles.
+                Example usage: --workspace-pools-write-latency-cycles=flash:8""",
+    )
+    parser.add_argument(
+        "--workspace-pools-target-burst-bytes",
+        help="""The burst length of the memory pool in bytes per target.
+                Example usage: --workspace-pools-target-burst-bytes=flash:accel:1""",
+    )
+
+
+def _parse_target_burst(attr, pool_name):
+    if pool_name not in attr:
+        return {}
+
+    return {target: int(attr[pool_name][target]) for target in attr[pool_name]}
+
+
+def _parse_target_access(attr, pool_name):
+    try:
+        return attr[pool_name]
+    except:
+        raise TVMCException(f'Workspace Pool "{pool_name}" using undefined Target.')
+
+
+def _split_pools(attr):
+    return re.split(",", attr) if attr else []
+
+
+def _target_attributes_to_pools(attr, targets):
+    if not targets or attr is None:
+        return {}
+
+    target_attributes = {}
+    for pool_values in re.split(",", attr):
+        pool_name, target_name, target_value = re.split(":", pool_values)
+        if pool_name not in target_attributes:
+            target_attributes[pool_name] = {}
+
+        matched_targets = [target for target in targets if target_name == target.kind.name]
+        if matched_targets:
+            target_attributes[pool_name][matched_targets[0]] = target_value
+        else:
+            raise TVMCException(
+                "The workspace pool target specification for target access "
+                "needs to be the same TVM target as when specifying targets to use."
+            )
+
+    return target_attributes
+
+
+def _attribute_to_pools(attr):
+    return dict(pool.split(":", maxsplit=1) for pool in re.split(",", attr)) if attr else {}
+
+
+def workspace_pools_recombobulate(parsed, targets):
+    """Reconstructs the Workspace Pools args and returns a WorkspaceMemoryPool object"""
+    WORKSPACE_POOL_PARAMS = [
+        "workspace_pools_size_hint_bytes",
+        "workspace_pools_target_access",
+        "workspace_pools_clock_frequency_hz",
+        "workspace_pools_read_bandwidth_bytes_per_cycle",
+        "workspace_pools_write_bandwidth_bytes_per_cycle",
+        "workspace_pools_read_latency_cycles",
+        "workspace_pools_write_latency_cycles",
+        "workspace_pools_target_burst_bytes",
+    ]
+    WORKSPACE_POOL_TARGET_PARAMS = [
+        "workspace_pools_target_access",
+        "workspace_pools_target_burst_bytes",
+    ]
+
+    workspace_pools = _split_pools(parsed.workspace_pools)
+    pool_to_attributes = {
+        workspace_pool_param: _attribute_to_pools(getattr(parsed, workspace_pool_param))
+        for workspace_pool_param in WORKSPACE_POOL_PARAMS
+    }
+    pool_to_target_attributes = {
+        workspace_pool_param: _target_attributes_to_pools(
+            getattr(parsed, workspace_pool_param), targets
+        )
+        for workspace_pool_param in WORKSPACE_POOL_TARGET_PARAMS
+    }
+
+    return WorkspaceMemoryPools(
+        [
+            PoolInfo(

Review Comment:
   I think we still need the keep-in-sync comment because PoolInfo could be added with arguments with defaults and tvmc support for that could be missed out.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org