Skip to content

Commit

Permalink
#598: Runtime support for dealloc op, slight refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jnie-TT committed Sep 4, 2024
1 parent e9b4720 commit 77b92d3
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 165 deletions.
7 changes: 6 additions & 1 deletion include/ttmlir/Target/TTNN/program.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ table Conv2dOp {
groups: uint32;
}

table DeallocOp {
in: tt.target.TensorRef;
}

union OpType {
OpenDeviceOp,
CloseDeviceOp,
Expand All @@ -135,7 +139,8 @@ union OpType {
TransposeOp,
Conv2dOp,
ConcatOp,
ReshapeOp
ReshapeOp,
DeallocOp
}

table Operation {
Expand Down
12 changes: 12 additions & 0 deletions lib/Target/TTNN/TTNNToFlatbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ createSoftmaxOp(FlatbufferObjectCache &cache, SoftmaxOp op) {
return ::tt::target::ttnn::CreateSoftmaxOp(*cache.fbb, in, out, dimension);
}

template <typename DeallocOp>
::flatbuffers::Offset<::tt::target::ttnn::DeallocOp>
createDeallocOp(FlatbufferObjectCache &cache, DeallocOp op) {
auto in =
cache.at<::tt::target::TensorRef>(getOperandThroughDPSOps(op.getInput()));
return ::tt::target::ttnn::CreateDeallocOp(*cache.fbb, in);
}

::flatbuffers::Offset<::tt::target::ttnn::Operation>
emitTTNNOperation(FlatbufferObjectCache &cache, Operation *op,
std::string const &debugString) {
Expand Down Expand Up @@ -356,6 +364,10 @@ emitTTNNOperation(FlatbufferObjectCache &cache, Operation *op,
return createOperation(cache, createReshapeOp(cache, reshapeOp),
debugString);
}
if (auto deallocOp = dyn_cast<DeallocOp>(op); deallocOp) {
return createOperation(cache, createDeallocOp(cache, deallocOp),
debugString);
}

llvm_unreachable("unhandled op in emitTTNNOperation");
}
Expand Down
Loading

0 comments on commit 77b92d3

Please sign in to comment.