Skip to content

Commit

Permalink
[microNPU][2c] Initial Performance Model
Browse files Browse the repository at this point in the history
* Added the pre-computed performance modelling per block.
* Added the aggregation of cycles given a stripe config.
* Implemented the op-specific performance code for conv2d.
* Created a DeviceConfig class to hold constant performance related data
that is dependent on the accelerator configuration
* Added generation of all valid block configs. This is pre-computed and
given as an argument when constructing EthosuParts.
* Implemented selection of the block config that gives the least amount
of data read given a StripeConfig.
  • Loading branch information
jacobbohlin authored and mbaret committed Dec 22, 2021
1 parent aba0a8e commit 77a5b22
Show file tree
Hide file tree
Showing 23 changed files with 1,609 additions and 145 deletions.
3 changes: 3 additions & 0 deletions python/tvm/contrib/ethosu/cascader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@
for both performance and memory usage on Arm(R) Ethos(TM)-U NPUs.
"""
from .stripe_config import StripeConfig
from .block_config import BlockConfig
from .propagator import Propagator
from .graph import (
PerformanceInfo,
Tensor,
Part,
TESubgraph,
CascaderGraph,
BufferMode,
register_matcher,
create_cascader_graph,
)
from .parts import InlinePart, EthosuPart
from .device_config import EthosuDeviceConfig
49 changes: 49 additions & 0 deletions python/tvm/contrib/ethosu/cascader/block_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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.
"""Block config to hold an output block shape and a corresponding input block shape"""
# pylint: disable=invalid-name
from typing import List
import tvm._ffi

from tvm.runtime import Object

from . import _ffi_api


@tvm._ffi.register_object("contrib.ethosu.cascader.BlockConfig")
class BlockConfig(Object):
"""BlockConfig class"""

def __init__(self, output_shape: List[int], compute_cycles: int, output_cycles: int):
self.__init_handle_by_constructor__(
_ffi_api.BlockConfig, output_shape, compute_cycles, output_cycles
)

@property
def output_shape(self) -> List[int]:
return list(self._output_shape)

@property
def compute_cycles(self) -> int:
return int(self._compute_cycles)

@property
def output_cycles(self) -> int:
return int(self._output_cycles)

def __repr__(self) -> str:
return f"BlockConfig(output_shape={self.output_shape})"
Loading

0 comments on commit 77a5b22

Please sign in to comment.