manupa-arm commented on a change in pull request #9890: URL: https://github.com/apache/tvm/pull/9890#discussion_r793408464
########## File path: python/tvm/contrib/ethosu/cascader/pareto.py ########## @@ -0,0 +1,39 @@ +# 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. +"""Pareto optimisation functions for the NPU cascader.""" +from typing import List + +from tvm import Object + +from . import _ffi_api +from .plan import Plan + + +def get_pareto_frontier(costs: List[List[float]]) -> List[bool]: Review comment: Should we add docstrings for these functions ? ########## File path: python/tvm/contrib/ethosu/cascader/pareto.py ########## @@ -0,0 +1,39 @@ +# 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. +"""Pareto optimisation functions for the NPU cascader.""" +from typing import List + +from tvm import Object + +from . import _ffi_api +from .plan import Plan + + +def get_pareto_frontier(costs: List[List[float]]) -> List[bool]: + for i, cost in enumerate(costs): + for j, value in enumerate(cost): + costs[i][j] = float(value) + + return [bool(v) for v in _ffi_api.GetParetoFrontier(costs)] + + +def thin_vector(vec: List[Object], max_size: int) -> List[Object]: + return list(_ffi_api.ThinVector(vec, max_size)) + + +def pareto_cull_plans(plans: List[Plan], max_plans: int) -> List[Plan]: Review comment: Should we add docstrings for these functions ? ########## File path: python/tvm/contrib/ethosu/cascader/plan.py ########## @@ -0,0 +1,99 @@ +# 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. +"""Plan class to hold subgraph scheduling information.""" +from typing import Dict, FrozenSet +import tvm._ffi + +from tvm.runtime import Object + +from . import _ffi_api +from .graph import Tensor, Part +from .tensor_config import TensorConfig, MemoryRegion + + +@tvm._ffi.register_object("contrib.ethosu.cascader.Plan") +class Plan(Object): + """Plan class""" Review comment: We would need a better description than this. ########## File path: python/tvm/contrib/ethosu/cascader/pareto.py ########## @@ -0,0 +1,39 @@ +# 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. +"""Pareto optimisation functions for the NPU cascader.""" +from typing import List + +from tvm import Object + +from . import _ffi_api +from .plan import Plan + + +def get_pareto_frontier(costs: List[List[float]]) -> List[bool]: + for i, cost in enumerate(costs): + for j, value in enumerate(cost): + costs[i][j] = float(value) + + return [bool(v) for v in _ffi_api.GetParetoFrontier(costs)] + + +def thin_vector(vec: List[Object], max_size: int) -> List[Object]: Review comment: Should we add docstrings for these functions ? ########## File path: python/tvm/contrib/ethosu/cascader/plan_generator.py ########## @@ -0,0 +1,51 @@ +# 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. +"""Algorithms to generate Plans for a CascaderGraph.""" +from typing import List, Dict + +from tvm.contrib.ethosu.cascader.tensor_config import MemoryRegion + +from . import _ffi_api +from .cascader_options import CascaderOptions +from .plan import Plan +from .stripe_config import StripeConfig +from .graph import CascaderGraph, Part, Tensor + + +def generate_output_stripe_configs(part: Part, stripe_factors: int) -> List[StripeConfig]: Review comment: Docstring here as well and for later functions ? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
