Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jerrrrry
infinicore
Commits
02922ce9
Commit
02922ce9
authored
May 14, 2025
by
zhangyue
Browse files
issue/174: Separate getworkspace and execution
parent
98270602
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
src/infiniop/ops/causal_softmax/ascend/causal_softmax_aclnn.cc
...nfiniop/ops/causal_softmax/ascend/causal_softmax_aclnn.cc
+14
-14
No files found.
src/infiniop/ops/causal_softmax/ascend/causal_softmax_aclnn.cc
View file @
02922ce9
...
@@ -12,6 +12,8 @@ struct Descriptor::Opaque {
...
@@ -12,6 +12,8 @@ struct Descriptor::Opaque {
aclnnTensorDescriptor_t
value
;
aclnnTensorDescriptor_t
value
;
void
*
mask_addr
;
void
*
mask_addr
;
void
*
value_addr
;
void
*
value_addr
;
uint64_t
workspacesize
;
aclOpExecutor
*
executor
;
~
Opaque
()
{
~
Opaque
()
{
delete
x
;
delete
x
;
...
@@ -21,6 +23,9 @@ struct Descriptor::Opaque {
...
@@ -21,6 +23,9 @@ struct Descriptor::Opaque {
aclrtFree
(
mask_addr
);
aclrtFree
(
mask_addr
);
aclrtFree
(
value_addr
);
aclrtFree
(
value_addr
);
// Delete useless executor
aclDestroyAclOpExecutor
(
executor
);
}
}
};
};
...
@@ -92,20 +97,19 @@ infiniStatus_t Descriptor::create(
...
@@ -92,20 +97,19 @@ infiniStatus_t Descriptor::create(
aclTensor
*
tvalue
=
value
->
tensor
;
aclTensor
*
tvalue
=
value
->
tensor
;
CHECK_ACL
(
aclnnInplaceMaskedFillTensorGetWorkspaceSize
(
tx
,
tmask
,
tvalue
,
&
workspacesize_mask
,
&
mask_executor
));
CHECK_ACL
(
aclnnInplaceMaskedFillTensorGetWorkspaceSize
(
tx
,
tmask
,
tvalue
,
&
workspacesize_mask
,
&
mask_executor
));
int64_t
dim
=
2
;
int64_t
dim
=
2
;
CHECK_ACL
(
aclnnSoftmaxGetWorkspaceSize
(
tx
,
dim
,
ty
,
&
workspacesize_softmax
,
&
executor
));
CHECK_ACL
(
aclnnSoftmaxGetWorkspaceSize
(
tx
,
dim
,
ty
,
&
workspacesize_softmax
,
&
executor
));
// set executor reusable
aclSetAclOpExecutorRepeatable
(
executor
);
// Create the descripto
r
// Create the descripto
size_t
all_workspacesize
=
std
::
max
(
workspacesize_softmax
,
workspacesize_mask
);
size_t
all_workspacesize
=
std
::
max
(
workspacesize_softmax
,
workspacesize_mask
);
*
desc_ptr
=
new
Descriptor
(
new
Opaque
{
x
,
mask
,
y
,
value
,
mask_addr
,
value_addr
},
*
desc_ptr
=
new
Descriptor
(
new
Opaque
{
x
,
mask
,
y
,
value
,
mask_addr
,
value_addr
,
workspacesize_softmax
,
executor
},
std
::
move
(
info
),
all_workspacesize
,
handle_ascend
->
device
,
handle_ascend
->
device_id
);
std
::
move
(
info
),
all_workspacesize
,
handle_ascend
->
device
,
handle_ascend
->
device_id
);
// Delete useless executor
aclDestroyAclOpExecutor
(
executor
);
aclDestroyAclOpExecutor
(
mask_executor
);
return
INFINI_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
}
...
@@ -117,11 +121,8 @@ infiniStatus_t Descriptor::calculate(void *workspace, size_t workspace_size, voi
...
@@ -117,11 +121,8 @@ infiniStatus_t Descriptor::calculate(void *workspace, size_t workspace_size, voi
auto
ty
=
_opaque
->
y
->
tensor
;
auto
ty
=
_opaque
->
y
->
tensor
;
auto
tmask
=
_opaque
->
mask
->
tensor
;
auto
tmask
=
_opaque
->
mask
->
tensor
;
auto
tvalue
=
_opaque
->
value
->
tensor
;
auto
tvalue
=
_opaque
->
value
->
tensor
;
aclOpExecutor
*
executor
=
nullptr
;
aclOpExecutor
*
mask_executor
=
nullptr
;
aclOpExecutor
*
mask_executor
=
nullptr
;
size_t
workspacesize_softmax
=
0
;
size_t
workspacesize_mask
=
0
;
size_t
workspacesize_mask
=
0
;
int64_t
dim
=
2
;
AclSetTensorAddr
(
mask_executor
,
0
,
tx
,
(
void
*
)
x
);
AclSetTensorAddr
(
mask_executor
,
0
,
tx
,
(
void
*
)
x
);
AclSetTensorAddr
(
mask_executor
,
1
,
tmask
,
_opaque
->
mask_addr
);
AclSetTensorAddr
(
mask_executor
,
1
,
tmask
,
_opaque
->
mask_addr
);
...
@@ -129,10 +130,9 @@ infiniStatus_t Descriptor::calculate(void *workspace, size_t workspace_size, voi
...
@@ -129,10 +130,9 @@ infiniStatus_t Descriptor::calculate(void *workspace, size_t workspace_size, voi
CHECK_ACL
(
aclnnInplaceMaskedFillTensorGetWorkspaceSize
(
tx
,
tmask
,
tvalue
,
&
workspacesize_mask
,
&
mask_executor
));
CHECK_ACL
(
aclnnInplaceMaskedFillTensorGetWorkspaceSize
(
tx
,
tmask
,
tvalue
,
&
workspacesize_mask
,
&
mask_executor
));
CHECK_ACL
(
aclnnInplaceMaskedFillTensor
(
workspace
,
workspacesize_mask
,
mask_executor
,
stream
));
CHECK_ACL
(
aclnnInplaceMaskedFillTensor
(
workspace
,
workspacesize_mask
,
mask_executor
,
stream
));
AclSetTensorAddr
(
executor
,
0
,
tx
,
(
void
*
)
x
);
AclSetTensorAddr
(
_opaque
->
executor
,
0
,
tx
,
(
void
*
)
x
);
AclSetTensorAddr
(
executor
,
1
,
ty
,
y
);
AclSetTensorAddr
(
_opaque
->
executor
,
1
,
ty
,
y
);
CHECK_ACL
(
aclnnSoftmaxGetWorkspaceSize
(
tx
,
dim
,
ty
,
&
workspacesize_softmax
,
&
executor
));
CHECK_ACL
(
aclnnSoftmax
(
workspace
,
_opaque
->
workspacesize
,
_opaque
->
executor
,
stream
));
CHECK_ACL
(
aclnnSoftmax
(
workspace
,
workspacesize_softmax
,
executor
,
stream
));
return
INFINI_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment