mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-06-06 05:55:39 +00:00
Re-use CopyAsType<>() to implement copy ctor
This commit is contained in:
@@ -254,7 +254,7 @@ struct Tensor
|
||||
Tensor(const HostTensorDescriptor& desc) : mDesc(desc), mData(mDesc.GetElementSpaceSize()) {}
|
||||
|
||||
template <typename OutT>
|
||||
Tensor<OutT> CopyAsType()
|
||||
Tensor<OutT> CopyAsType() const
|
||||
{
|
||||
Tensor<OutT> ret(mDesc);
|
||||
for(size_t i = 0; i < mData.size(); i++)
|
||||
@@ -266,11 +266,10 @@ struct Tensor
|
||||
|
||||
Tensor(const Tensor& other) : mDesc(other.mDesc), mData(other.mData) {}
|
||||
|
||||
template <typename OtherT,
|
||||
typename =
|
||||
std::enable_if_t<sizeof(T) == sizeof(OtherT) && std::is_convertible_v<T, OtherT>>>
|
||||
Tensor(const Tensor<OtherT>& other)
|
||||
: mDesc(other.mDesc), mData(std::begin(other.mData), std::end(other.mData))
|
||||
Tensor(Tensor&& other) = default;
|
||||
|
||||
template <typename OtherT>
|
||||
Tensor(const Tensor<OtherT>& other) : Tensor(other.template CopyAsType<T>())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user