-
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.
* add op tril --------- Co-authored-by: wugeshui <[email protected]>
- Loading branch information
1 parent
c592042
commit b702b11
Showing
3 changed files
with
41 additions
and
15 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,39 @@ | ||
/** | ||
* @file | ||
* @author DeepLink | ||
* @copyright (c) 2023, DeepLink. | ||
*/ | ||
|
||
#include <diopi/functions.h> | ||
#include "../cnnl_helper.hpp" | ||
#include "../common/common.hpp" | ||
|
||
namespace impl { | ||
namespace camb { | ||
|
||
extern "C" { | ||
|
||
DIOPI_API diopiError_t diopiTril(diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t diagonal) { | ||
cnnlHandle_t handle = cnnlHandlePool.get(ctx); | ||
DiopiTensor input_tensor(input); | ||
DiopiTensor out_tensor(out); | ||
|
||
std::vector<DiopiTensor*> pTensors{&input_tensor}; | ||
DIOPI_CALL(autoCastTensorType(ctx, pTensors, {diopi_dtype_int8, diopi_dtype_int16, diopi_dtype_int32, diopi_dtype_float16, diopi_dtype_float32})); | ||
DiopiTensor input_tensor_tmp = *pTensors[0]; | ||
DiopiTensor out_tensor_tmp = out_tensor; | ||
DIOPI_CALL(dataTypeCast(ctx, out_tensor_tmp, input_tensor_tmp.dtype())); | ||
|
||
CnnlTensorDesc input_desc(input_tensor_tmp, CNNL_LAYOUT_ARRAY); | ||
CnnlTensorDesc out_desc(out_tensor_tmp, CNNL_LAYOUT_ARRAY); | ||
|
||
DIOPI_CALLCNNL(cnnlTri(handle, static_cast<int>(diagonal), false, input_desc.get(), input_tensor_tmp.data(), out_desc.get(), out_tensor_tmp.data())); | ||
DIOPI_CALL(dataTypeCast(ctx, out_tensor, out_tensor_tmp)); | ||
|
||
return diopiSuccess; | ||
} | ||
|
||
} // extern "C" | ||
|
||
} // namespace camb | ||
} // namespace impl |