Skip to content

Commit

Permalink
Merge pull request #57 from tum-ei-eda/moiopt
Browse files Browse the repository at this point in the history
add moiopt feature; fix tvmaot wrapper name sanitization; typos
  • Loading branch information
PhilippvK authored Jun 15, 2022
2 parents 50ffb24 + 0c94a9c commit 2ef1c79
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 24 deletions.
38 changes: 27 additions & 11 deletions mlonmcu/feature/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def __init__(self, config=None):
super().__init__("memplan", config=config)

def get_framework_config(self, framework):
assert framework in ["tvm"], f"Usupported fetaure '{self.name}' for framework '{framework}'"
assert framework in ["tvm"], f"Unsupported feature '{self.name}' for framework '{framework}'"
raise NotImplementedError
return {"tvm.memplan_enable": self.enabled}

Expand All @@ -458,7 +458,7 @@ def algorithm(self):
return str(self.config["algorithm"])

def add_backend_config(self, backend, config):
assert backend in ["tvmaot"], f"Usupported fetaure '{self.name}' for backend '{backend}'"
assert backend in ["tvmaot"], f"Unsupported feature '{self.name}' for backend '{backend}'"
if f"{backend}.extra_pass_config" in config:
tmp = config[f"{backend}.extra_pass_config"]
elif "extra_pass_config" in config:
Expand All @@ -474,17 +474,33 @@ def add_backend_config(self, backend, config):
# -> enable this via backend


@register_feature("fusetile")
class Fusetile(FrameworkFeature): # TODO: rename to MOIOPT?
"""WIP TVM feature by (@rafzi)"""
@register_feature("moiopt")
class MOIOPT(BackendFeature):
"""Memory-Optimizing, Inter-Operator Tiling - currently only supported with custom TVM"""

DEFAULTS = {
**FeatureBase.DEFAULTS,
"noftp": False,
"onlyftp": False,
"norecurse": False,
}

def __init__(self, config=None):
super().__init__("fusetile", config=config)
super().__init__("moiopt", config=config)

def get_framework_config(self, framework):
assert framework in ["tvm"], f"Usupported fetaure '{self.name}' for framework '{framework}'"
raise NotImplementedError
return {"tvm.fusetile_enable": self.enabled}
def add_backend_config(self, backend, config):
assert backend in ["tvmaot", "tvmrt"], f"Unsupported feature '{self.name}' for backend '{backend}'"
if f"{backend}.extra_pass_config" in config:
tmp = config[f"{backend}.extra_pass_config"]
elif "extra_pass_config" in config:
tmp = config["extra_pass_config"]
else:
tmp = {}
tmp["relay.moiopt.enable"] = self.enabled
tmp["relay.moiopt.noftp"] = self.config["noftp"]
tmp["relay.moiopt.onlyftp"] = self.config["onlyftp"]
tmp["relay.moiopt.norecurse"] = self.config["norecurse"]
config.update({f"{backend}.extra_pass_config": tmp})

# -> enable this via backend

Expand Down Expand Up @@ -678,7 +694,7 @@ def config_file(self):
return str(self.config["config_file"]) if "config_file" in self.config else None

def get_framework_config(self, framework):
assert framework in ["tvm"], f"Usupported fetaure '{self.name}' for framework '{framework}'"
assert framework in ["tvm"], f"Unsupported feature '{self.name}' for framework '{framework}'"
raise NotImplementedError
return filter_none(
{
Expand Down
2 changes: 1 addition & 1 deletion mlonmcu/flow/tvm/backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TVMBackend(Backend):

name = None

FEATURES = ["autotune", "autotuned", "cmsisnnbyoc", "disable_legalize"]
FEATURES = ["autotune", "autotuned", "cmsisnnbyoc", "disable_legalize", "moiopt"]

DEFAULTS = {
"print_outputs": False,
Expand Down
2 changes: 1 addition & 1 deletion mlonmcu/flow/tvm/backend/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def writeTensorsHelper(tensors, prefix, out=False):
ret += f"void* {direction}puts[] = {{" + ", ".join(names) + "};\n"
ret += f"struct {prefix}_{direction}puts {prefix}_{direction}puts = {{" + "\n"
for i, t in enumerate(tensors):
tensor_name = t.name.replace(":", "_")
tensor_name = t.name.replace(":", "_").replace("/", "_")
ret += f" .{tensor_name} = {names[i]}," + "\n"
ret += "};\n"
return ret
Expand Down
2 changes: 1 addition & 1 deletion resources/templates/default.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ frameworks:
autotuned: true
features:
cmsisnnbyoc: false
# Some frontends are eperimental and therefore disabled here
# Some frontends are experimental and therefore disabled here
# Features like packing are only available in certain environments
#
frontends:
Expand Down
28 changes: 18 additions & 10 deletions resources/templates/tumeda.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,41 @@ paths:
# Here default clone_urls
repos:
tensorflow: # TODO: rename to tflite-micro?
url: "git@github.com:tensorflow/tflite-micro.git"
url: "https://github.com/tensorflow/tflite-micro.git"
ref: 746f880a405aeca2db6d005fd9fb8e451f3cea34
tflite_micro_compiler:
url: "[email protected]:PhilippvK/tflite_micro_compiler.git"
ref: patches
tvm:
url: "[email protected]:tum-ei-eda/tvm.git"
ref: latest
url: "[email protected]:rafzi/privtvm.git"
ref: moiopt
utvm_staticrt_codegen:
url: "[email protected]:tum-ei-eda/utvm_staticrt_codegen.git"
ref: master
ref: 1b296f1efcc28671ee21ccbe86a81b968db8b1e5
tvm_extensions:
url: "https://github.com/tum-ei-eda/tvm_extensions.git"
ref: main
etiss:
url: "git@github.com:tum-ei-eda/etiss.git"
ref: master
url: "https://github.com/tum-ei-eda/etiss.git"
ref: d20bd6e6019a680f98d9904e6fc1c2d51f4a061b
muriscvnn:
url: "[email protected]:fabianpedd/muriscv_nn.git"
ref: main
packer:
url: "[email protected]:de-tum-ei-eda-esl/tflite-pack.git"
ref: main
spike:
url: "git@github.com:riscv-software-src/riscv-isa-sim.git"
url: "https://github.com/riscv-software-src/riscv-isa-sim.git"
ref: master
spikepk:
url: "git@github.com:riscv-software-src/riscv-pk.git"
url: "https://github.com/riscv-software-src/riscv-pk.git"
ref: master
cmsis:
url: "https://github.com/ARM-software/CMSIS_5.git"
ref: 8c60448c0e1e50e426180b26db9bc31ddf774361
mlif:
url: "https://github.com/tum-ei-eda/mlonmcu-sw.git"
ref: main
ref: 35c07e41c2dd92618f0249d24a7c564110ae2b6d
espidf:
url: "https://github.com/espressif/esp-idf.git"
ref: release/v4.4
Expand Down Expand Up @@ -93,21 +93,29 @@ frameworks:
features:
debug_arena: true
disable_legalize: true
autotune: true
autotuned: true
moiopt: true
tvmaot:
enabled: true
features:
debug_arena: true
unpacked_api: true
usmp: false
disable_legalize: true
autotune: true
autotuned: true
moiopt: true
tvmcg:
enabled: true
features:
debug_arena: true
disable_legalize: true
autotune: true
autotuned: true
features:
cmsisnnbyoc: false
# Some frontends are eperimental and therefore disabled here
# Some frontends are experimental and therefore disabled here
# Features like packing are only available in certain environments
#
frontends:
Expand Down

0 comments on commit 2ef1c79

Please sign in to comment.