Clean up unnecessary codes in softmax and hardmax kernel (#9580)

* add p50 in test

* remove unnecessary codes from softmax

* remove unnecessary codes from hardmax

Co-authored-by: Yulong Wang <yulongw@microsoft.com>
This commit is contained in:
Sunghoon 2021-10-28 10:01:46 -07:00 committed by GitHub
parent e8268c9a18
commit 17cf39a964
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 20 deletions

View file

@ -114,12 +114,8 @@ Status Hardmax<float>::Compute(OpKernelContext* ctx) const {
}
if (is_transpose_required) {
std::vector<size_t> reverse_permutation(rank);
for (size_t i = 0, end = permutation.size(); i < end; ++i) {
reverse_permutation[permutation[i]] = i;
}
// Perform the transpose to get the axes back to the original ordering
ORT_RETURN_IF_ERROR(TransposeBase::DoTranspose(reverse_permutation, intermediate_output, *Y));
ORT_RETURN_IF_ERROR(TransposeBase::DoTranspose(permutation, intermediate_output, *Y));
}
return Status::OK();

View file

@ -180,12 +180,8 @@ Status Softmax<T>::ComputeImplOpset13(const Tensor& input, Tensor& output, size_
log_softmax_, thread_pool));
if (is_transpose_required) {
std::vector<size_t> reverse_permutation(rank);
for (size_t i = 0, end = permutation.size(); i < end; ++i) {
reverse_permutation[permutation[i]] = i;
}
// Perform the transpose to get the axes back to the original ordering
ORT_RETURN_IF_ERROR(TransposeBase::DoTranspose(reverse_permutation, intermediate_output, output));
ORT_RETURN_IF_ERROR(TransposeBase::DoTranspose(permutation, intermediate_output, output));
}
return Status::OK();

View file

@ -223,15 +223,11 @@ SPECIALIZED_SOFTMAX_HELPER_IMPL_BFloat16(true)
return status;
if (is_transpose_required) {
std::vector<size_t> reverse_permutation(rank);
for (size_t i = 0, end = permutation.size(); i < end; ++i) {
reverse_permutation[permutation[i]] = i;
}
// Perform the transpose to get the axes back to the original ordering
ORT_RETURN_IF_ERROR(Transpose::DoTranspose(cuda_ep_->GetDeviceProp(),
Stream(),
CublasHandle(),
reverse_permutation, *intermediate_output, *Y));
permutation, *intermediate_output, *Y));
}
return Status::OK();

View file

@ -199,15 +199,11 @@ Status Softmax<T>::ComputeInternal(OpKernelContext* ctx) const {
return status;
if (is_transpose_required) {
std::vector<size_t> reverse_permutation(rank);
for (size_t i = 0, end = permutation.size(); i < end; ++i) {
reverse_permutation[permutation[i]] = i;
}
// Perform the transpose to get the axes back to the original ordering
ORT_RETURN_IF_ERROR(Transpose::DoTranspose(rocm_ep_->GetDeviceProp(),
Stream(),
RocblasHandle(),
reverse_permutation, *intermediate_output, *Y));
permutation, *intermediate_output, *Y));
}
return Status::OK();