-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ascend]Zgc/diopi ascend add masked fill (#1005)
* enable use aclnnCopy in tensor.copy_ * add masked_fill relate
- Loading branch information
1 parent
4fb272f
commit 57a3b7a
Showing
4 changed files
with
73 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* @file | ||
* @author DeepLink | ||
* @copyright (c) 2024, DeepLink. | ||
*/ | ||
|
||
#include "helper.hpp" | ||
#include "op_plugin/OpApiInterface.h" | ||
|
||
namespace OP_IMPL_NS { | ||
|
||
diopiError_t diopiMaskedFill(diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t mask, | ||
diopiConstTensorHandle_t value) { | ||
BEGIN_CALL_ACL_OP(out, input, mask, value); | ||
if (input == nullptr || inputAt.numel() <= 0) { | ||
return diopiSuccess; | ||
} | ||
if (outAt.data_ptr() != inputAt.data_ptr()) { | ||
outAt.copy_(inputAt); | ||
} | ||
op_api::masked_fill_(outAt, maskAt, valueAt); | ||
END_CALL_ACL_OP(); | ||
} | ||
|
||
diopiError_t diopiMaskedFillInp(diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t mask, diopiConstTensorHandle_t value) { | ||
BEGIN_CALL_ACL_OP(input, mask, value); | ||
if (input == nullptr || inputAt.numel() <= 0) { | ||
return diopiSuccess; | ||
} | ||
op_api::masked_fill_(inputAt, maskAt, valueAt); | ||
END_CALL_ACL_OP(); | ||
} | ||
|
||
diopiError_t diopiMaskedFillScalar(diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t mask, | ||
const diopiScalar_t* value) { | ||
BEGIN_CALL_ACL_OP(out, input, mask, value); | ||
if (input == nullptr || inputAt.numel() <= 0) { | ||
return diopiSuccess; | ||
} | ||
if (outAt.data_ptr() != inputAt.data_ptr()) { | ||
outAt.copy_(inputAt); | ||
} | ||
op_api::masked_fill_(outAt, maskAt, valueAt); | ||
END_CALL_ACL_OP(); | ||
} | ||
|
||
diopiError_t diopiMaskedFillInpScalar(diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t mask, const diopiScalar_t* value) { | ||
BEGIN_CALL_ACL_OP(input, mask, value); | ||
if (input == nullptr || inputAt.numel() <= 0) { | ||
return diopiSuccess; | ||
} | ||
op_api::masked_fill_(inputAt, maskAt, valueAt); | ||
END_CALL_ACL_OP(); | ||
} | ||
|
||
} // namespace OP_IMPL_NS |
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