Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Post From-Device Copy Processing Issue #1796

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ test/lit.site.cfg.py
# TTNN and TTMetal flatbuffers
*.ttnn
*.ttm

# Root level mlir files (often used for testing, none should be at root)
/*.mlir
2 changes: 1 addition & 1 deletion python/test_infra/ttir_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def bitwise_not(self, in0: Operand) -> OpView:
return self.eltwise_proxy(torch.bitwise_not, ttir.BitwiseNotOp, [in0])

def ceil(self, in0: Operand) -> OpView:
return self.eltwise_proxy(torch.log, ttir.CeilOp, [in0])
return self.eltwise_proxy(torch.ceil, ttir.CeilOp, [in0])

def sin(self, in0: Operand) -> OpView:
return self.eltwise_proxy(torch.sin, ttir.SinOp, [in0])
Expand Down
21 changes: 5 additions & 16 deletions runtime/lib/ttnn/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,23 +510,12 @@ Tensor getOpOutputTensor(OpContext opContextHandle,
return createNullTensor();
}

::ttnn::Tensor hostTensor = ::ttnn::from_device(*outPtr);
::ttnn::Tensor outCopy =
::ttnn::to_layout(hostTensor, ::ttnn::ROW_MAJOR_LAYOUT, std::nullopt,
std::nullopt, static_cast<::ttnn::IDevice *>(nullptr));

void *src = ::tt::tt_metal::get_raw_host_data_ptr(outCopy);
std::uint32_t outCopySize = outCopy.volume() * outCopy.element_size();
std::shared_ptr<void> data = ::tt::runtime::utils::malloc_shared(outCopySize);
std::memcpy(data.get(), src, outCopySize);

auto tensor = std::make_shared<::ttnn::Tensor>(
ttnn::createStorage<BorrowedStorage>(data.get(), outCopy.volume(),
::tt::target::DataType::Float32),
outCopy.shape().value, ::ttnn::DataType::FLOAT32,
::ttnn::Layout::ROW_MAJOR);
std::shared_ptr<::ttnn::Tensor> hostTensor =
std::make_shared<::ttnn::Tensor>(::ttnn::to_layout(
::ttnn::from_device(*outPtr), ::ttnn::Layout::ROW_MAJOR, std::nullopt,
std::nullopt, static_cast<::ttnn::IDevice *>(nullptr)));

return Tensor(std::static_pointer_cast<void>(tensor), nullptr,
return Tensor(std::static_pointer_cast<void>(hostTensor), nullptr,
DeviceRuntime::TTNN);
}

Expand Down
Loading