Skip to content

Commit

Permalink
Merge pull request #938 from xmos/merge-transposes
Browse files Browse the repository at this point in the history
Merge transposes
  • Loading branch information
panickal-xmos authored Nov 6, 2024
2 parents ba134f5 + 297baba commit ded91c9
Show file tree
Hide file tree
Showing 9 changed files with 632 additions and 53 deletions.
36 changes: 20 additions & 16 deletions python/xmos_ai_tools/xformer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from .flash import generate_flash
import re

__compilation_output = ""
__compilation_stdout = ""
__compilation_stderr = ""
__arena_size = 0


Expand All @@ -29,28 +30,31 @@ def convert(

args.append(str(filename))

process_call: subprocess.CompletedProcess = subprocess.run(
[arg for arg in args],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
check=True,
)

global __compilation_output, __arena_size
__compilation_output = process_call.stdout.decode("utf-8")
size_str = re.sub("((.|\n|\r)*)Tensor arena size :", "", __compilation_output)
size_str = re.sub("(\n|\r)((.|\n|\r)*)", "", size_str)
__arena_size = int(size_str.strip())

return process_call.returncode
try:
process_call: subprocess.CompletedProcess = subprocess.run(
[arg for arg in args],
check=True, text=True, capture_output=True,
)
global __compilation_stdout, __compilation_stderr, __arena_size
__compilation_stdout = process_call.stdout
__compilation_stderr = process_call.stderr
size_str = re.sub("((.|\n|\r)*)Tensor arena size :", "", __compilation_stdout)
size_str = re.sub("(\n|\r)((.|\n|\r)*)", "", size_str)
__arena_size = int(size_str.strip())
return process_call.returncode
except subprocess.CalledProcessError as e:
print(e)
print("Return code:", e.returncode)
print("Error output:", e.stderr)


def tensor_arena_size() -> int:
return __arena_size


def print_optimization_report():
print(__compilation_output)
print(__compilation_stderr)
print(__compilation_stdout)


def print_help(show_hidden: Optional[bool] = False) -> int:
Expand Down
1 change: 0 additions & 1 deletion python/xmos_ai_tools/xinterpreters/host_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ def close(self, model_index: int = 0) -> None:
if self.obj:
lib.delete_interpreter(self.obj)
self.obj = None
print(self.obj)

def tensor_arena_size(self) -> int:
"""! Read the size of the tensor arena required.
Expand Down
3 changes: 3 additions & 0 deletions xformer/Transforms/OptimizeConv2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ struct ChannelwiseSplitConv2DOutputPattern
return splitResultType;
};

if(!llvm::isa<TFL::QConstOp>(op.getFilter().getDefiningOp()))
return failure();

auto filterQConstOp =
dyn_cast<TFL::QConstOp>(op.getFilter().getDefiningOp());
auto filterType = op.getFilter().getType().cast<ShapedType>();
Expand Down
Loading

0 comments on commit ded91c9

Please sign in to comment.