-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tensor partition and generic copy for ck wrapper (#1108)
* Add tensor partition and generic copy for ck wrapper * Update changelog * Stylistic fixes * Change shape/strides logic to descriptor transforms * Fixes * Fix client example * Fix comments
- Loading branch information
Showing
14 changed files
with
940 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) 2023, Advanced Micro Devices, Inc. All rights reserved. | ||
|
||
#pragma once | ||
|
||
#include "../utils/tensor_utils.hpp" | ||
|
||
namespace ck { | ||
namespace wrapper { | ||
|
||
/** | ||
* \brief Perform generic copy between two tensors. Tensors must have the | ||
* same size. | ||
* | ||
* \param src_tensor Source tensor. | ||
* \param dst_tensor Destination tensor. | ||
*/ | ||
template <typename SrcTensorType, typename DstTensorType> | ||
__host__ __device__ void copy(const SrcTensorType& src_tensor, DstTensorType& dst_tensor) | ||
{ | ||
if constexpr(!SrcTensorType::IsDynamicBuffer) | ||
{ | ||
using SizeType = decltype(size(src_tensor)); | ||
static_for<0, SizeType{}, 1>{}([&](auto i) { dst_tensor(i) = src_tensor(i); }); | ||
} | ||
else if constexpr(!DstTensorType::IsDynamicBuffer) | ||
{ | ||
using SizeType = decltype(size(dst_tensor)); | ||
static_for<0, SizeType{}, 1>{}([&](auto i) { dst_tensor(i) = src_tensor(i); }); | ||
} | ||
else | ||
{ | ||
for(int i = 0; i < size(src_tensor); i++) | ||
{ | ||
dst_tensor(i) = src_tensor(i); | ||
} | ||
} | ||
} | ||
|
||
} // namespace wrapper | ||
} // namespace ck |
Oops, something went wrong.