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
31fcf744
Commit
31fcf744
authored
Mar 18, 2025
by
YdrMaster
Browse files
issue/50/refactor: workspace_size 改为 minWorkSpaceSize()
Signed-off-by:
YdrMaster
<
ydrml@hotmail.com
>
parent
b5ccf30f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
8 deletions
+13
-8
src/infiniop/ops/random_sample/cpu/random_sample_cpu.cc
src/infiniop/ops/random_sample/cpu/random_sample_cpu.cc
+4
-0
src/infiniop/ops/random_sample/operator.cc
src/infiniop/ops/random_sample/operator.cc
+4
-3
src/infiniop/ops/random_sample/random_sample.h
src/infiniop/ops/random_sample/random_sample.h
+5
-5
No files found.
src/infiniop/ops/random_sample/cpu/random_sample_cpu.cc
View file @
31fcf744
...
@@ -41,6 +41,10 @@ infiniStatus_t Descriptor::create(
...
@@ -41,6 +41,10 @@ infiniStatus_t Descriptor::create(
return
INFINI_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
}
size_t
Descriptor
::
minWorkspaceSize
()
const
{
return
_min_workspace_size
;
}
template
<
typename
DT
>
template
<
typename
DT
>
struct
ComputeType
{
struct
ComputeType
{
using
type
=
DT
;
using
type
=
DT
;
...
...
src/infiniop/ops/random_sample/operator.cc
View file @
31fcf744
...
@@ -37,9 +37,10 @@ __C infiniStatus_t infiniopGetRandomSampleWorkspaceSize(
...
@@ -37,9 +37,10 @@ __C infiniStatus_t infiniopGetRandomSampleWorkspaceSize(
infiniopRandomSampleDescriptor_t
desc
,
infiniopRandomSampleDescriptor_t
desc
,
size_t
*
size
)
{
size_t
*
size
)
{
#define GET(CASE, NAMESPACE) \
#define GET(CASE, NAMESPACE) \
case CASE: \
case CASE: \
*size = reinterpret_cast<const op::random_sample::NAMESPACE::Descriptor *>(desc)->workspace_size; \
using Ptr = const op::random_sample::NAMESPACE::Descriptor *; \
*size = reinterpret_cast<Ptr>(desc)->minWorkspaceSize(); \
return INFINI_STATUS_SUCCESS
return INFINI_STATUS_SUCCESS
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
...
...
src/infiniop/ops/random_sample/random_sample.h
View file @
31fcf744
...
@@ -12,13 +12,13 @@
...
@@ -12,13 +12,13 @@
Opaque *_opaque; \
Opaque *_opaque; \
\
\
infiniDtype_t _dt_i, _dt_p; \
infiniDtype_t _dt_i, _dt_p; \
size_t _n
;
\
size_t _n
, _min_workspace_size;
\
\
\
Descriptor( \
Descriptor( \
infiniDtype_t dt_i, \
infiniDtype_t dt_i, \
infiniDtype_t dt_p, \
infiniDtype_t dt_p, \
size_t n, \
size_t n, \
size_t workspace_size
_,
\
size_t
min_
workspace_size
,
\
Opaque *opaque, \
Opaque *opaque, \
infiniDevice_t device_type, \
infiniDevice_t device_type, \
int device_id) \
int device_id) \
...
@@ -27,11 +27,9 @@
...
@@ -27,11 +27,9 @@
_dt_i(dt_i), \
_dt_i(dt_i), \
_dt_p(dt_p), \
_dt_p(dt_p), \
_n(n), \
_n(n), \
workspace_size(workspace_size
_
) {}
\
_min_
workspace_size(
min_
workspace_size) {} \
\
\
public: \
public: \
size_t workspace_size; \
\
~Descriptor(); \
~Descriptor(); \
\
\
static infiniStatus_t create( \
static infiniStatus_t create( \
...
@@ -40,6 +38,8 @@
...
@@ -40,6 +38,8 @@
infiniopTensorDescriptor_t result_desc, \
infiniopTensorDescriptor_t result_desc, \
infiniopTensorDescriptor_t probs_desc); \
infiniopTensorDescriptor_t probs_desc); \
\
\
size_t minWorkspaceSize() const; \
\
infiniStatus_t calculate( \
infiniStatus_t calculate( \
void *workspace, \
void *workspace, \
size_t workspace_size, \
size_t workspace_size, \
...
...
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