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

slice optimization to use builtin tensor function when possible #360

Merged
merged 2 commits into from
Jan 21, 2023
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
10 changes: 7 additions & 3 deletions include/matx/operators/slice.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ namespace matx
index_t strides[OpType::Rank()];
for(int i = 0; i < OpType::Rank(); i++)
strides[i] = 1;
return detail::SliceOp<OpType::Rank(),OpType>(op, starts, ends, strides);
return slice(op, starts, ends, strides);
}

/**
Expand All @@ -227,7 +227,11 @@ namespace matx
const index_t (&ends)[OpType::Rank()],
const index_t (&strides)[OpType::Rank()])
{
return detail::SliceOp<N,OpType>(op, starts, ends, strides);
if constexpr (is_tensor_view_v<OpType>) {
return op.template Slice<N>(starts, ends, strides);
} else {
return detail::SliceOp<N,OpType>(op, starts, ends, strides);
}
}

/**
Expand All @@ -254,6 +258,6 @@ namespace matx
typename OpType::shape_type strides[OpType::Rank()];
for (int i = 0; i < OpType::Rank(); i++)
strides[i] = 1;
return detail::SliceOp<N,OpType>(opIn, starts, ends, strides);
return slice<N, OpType>(opIn, starts, ends, strides);
}
} // end namespace matx
9 changes: 7 additions & 2 deletions include/matx/transforms/matmul.h
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,13 @@ __MATX_INLINE__ auto getCublasSupportedTensor( const Op &in, cudaStream_t stream
} else {
bool supported = true;

// either RANK-1 or RANK-2 stride must equal one in cublasLt
if(in.Stride(RANK-1) != 1 && in.Stride(RANK-2) != 1) {
if(

// either RANK-1 or RANK-2 stride must equal one in cublasLt
(in.Stride(RANK-1) != 1 && in.Stride(RANK-2) != 1) ||
// cloned matrices not supported in cublas
(in.Stride(RANK-1) == 0 || in.Stride(RANK-2) == 0)
) {
supported = false;
}

Expand Down