mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-25 19:48:11 +00:00
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:
parent
e8268c9a18
commit
17cf39a964
4 changed files with 4 additions and 20 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue