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
bd7a1466
Unverified
Commit
bd7a1466
authored
Apr 24, 2025
by
PanZezhong1725
Committed by
GitHub
Apr 24, 2025
Browse files
Merge pull request #195 from InfiniTensor/issue/194_fix_elementwise_overallocation
issue/194/fix: Fix ElementwiseInfo Meta Allocation
parents
62b7dd01
85bff3ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
5 deletions
+6
-5
src/infiniop/elementwise/cpu/elementwise_cpu.h
src/infiniop/elementwise/cpu/elementwise_cpu.h
+1
-1
src/infiniop/elementwise/elementwise.h
src/infiniop/elementwise/elementwise.h
+3
-2
src/infiniop/ops/swiglu/cuda/swiglu_cuda_internal.cuh
src/infiniop/ops/swiglu/cuda/swiglu_cuda_internal.cuh
+2
-2
No files found.
src/infiniop/elementwise/cpu/elementwise_cpu.h
View file @
bd7a1466
...
@@ -102,7 +102,7 @@ struct DeviceImpl::Opaque {};
...
@@ -102,7 +102,7 @@ struct DeviceImpl::Opaque {};
template
<
typename
...
Args
>
template
<
typename
...
Args
>
utils
::
Result
<
DeviceImpl
>
DeviceImpl
::
create
(
Args
&&
...
args
)
{
utils
::
Result
<
DeviceImpl
>
DeviceImpl
::
create
(
Args
&&
...
args
)
{
return
utils
::
Result
<
DeviceImpl
>
(
nullptr
)
;
return
INFINI_STATUS_NOT_IMPLEMENTED
;
}
}
// Perform elementwise operation for different input types
// Perform elementwise operation for different input types
...
...
src/infiniop/elementwise/elementwise.h
View file @
bd7a1466
...
@@ -84,8 +84,9 @@ private:
...
@@ -84,8 +84,9 @@ private:
_output_contiguous
(
output_contiguous
)
{}
_output_contiguous
(
output_contiguous
)
{}
public:
public:
// Get the Memory size of the meta data in bytes
inline
size_t
getMetaMemSize
()
const
{
inline
size_t
getMetaMemSize
()
const
{
return
_meta
.
size
();
return
_meta
.
size
()
*
sizeof
(
size_t
)
;
}
}
inline
const
int8_t
*
getMetaStart
()
const
{
inline
const
int8_t
*
getMetaStart
()
const
{
return
reinterpret_cast
<
const
int8_t
*>
(
_meta
.
data
());
return
reinterpret_cast
<
const
int8_t
*>
(
_meta
.
data
());
...
@@ -167,7 +168,7 @@ public:
...
@@ -167,7 +168,7 @@ public:
+
input_size
*
ndim
*
sizeof
(
shape_unit
)
+
input_size
*
ndim
*
sizeof
(
shape_unit
)
+
input_size
*
ndim
*
sizeof
(
stride_unit
)
+
input_size
*
ndim
*
sizeof
(
stride_unit
)
+
2
*
input_size
*
sizeof
(
bool
);
+
2
*
input_size
*
sizeof
(
bool
);
std
::
vector
<
size_t
>
meta
(
meta_mem_size
);
std
::
vector
<
size_t
>
meta
(
CEIL_DIV
(
meta_mem_size
,
sizeof
(
size_t
))
);
int8_t
*
meta_ptr
=
reinterpret_cast
<
int8_t
*>
(
meta
.
data
());
int8_t
*
meta_ptr
=
reinterpret_cast
<
int8_t
*>
(
meta
.
data
());
const
auto
output_shape
=
output_desc
->
shape
();
const
auto
output_shape
=
output_desc
->
shape
();
...
...
src/infiniop/ops/swiglu/cuda/swiglu_cuda_internal.cuh
View file @
bd7a1466
...
@@ -14,7 +14,7 @@ private:
...
@@ -14,7 +14,7 @@ private:
}
else
if
constexpr
(
std
::
is_same_v
<
T
,
half
>
)
{
}
else
if
constexpr
(
std
::
is_same_v
<
T
,
half
>
)
{
return
hrcp
(
__hadd
(
half
(
1.
f
),
__float2half
(
__expf
(
__half2float
(
__hneg
(
x
))))));
return
hrcp
(
__hadd
(
half
(
1.
f
),
__float2half
(
__expf
(
__half2float
(
__hneg
(
x
))))));
}
else
if
constexpr
(
std
::
is_same_v
<
T
,
float
>
)
{
}
else
if
constexpr
(
std
::
is_same_v
<
T
,
float
>
)
{
return
__frcp_r
d
(
__fadd_r
d
(
1
,
__expf
(
-
x
)));
return
__frcp_r
n
(
__fadd_r
n
(
1
,
__expf
(
-
x
)));
}
else
{
}
else
{
return
1
/
(
1
+
std
::
exp
(
-
x
));
return
1
/
(
1
+
std
::
exp
(
-
x
));
}
}
...
@@ -29,7 +29,7 @@ public:
...
@@ -29,7 +29,7 @@ public:
}
else
if
constexpr
(
std
::
is_same_v
<
T
,
half
>
)
{
}
else
if
constexpr
(
std
::
is_same_v
<
T
,
half
>
)
{
return
__hmul
(
__hmul
(
gate
,
sigmoid
(
gate
)),
up
);
return
__hmul
(
__hmul
(
gate
,
sigmoid
(
gate
)),
up
);
}
else
if
constexpr
(
std
::
is_same_v
<
T
,
float
>
)
{
}
else
if
constexpr
(
std
::
is_same_v
<
T
,
float
>
)
{
return
__fmul_r
d
(
__fmul_r
d
(
gate
,
sigmoid
(
gate
)),
up
);
return
__fmul_r
n
(
__fmul_r
n
(
gate
,
sigmoid
(
gate
)),
up
);
}
else
{
}
else
{
return
gate
*
sigmoid
(
gate
)
*
up
;
return
gate
*
sigmoid
(
gate
)
*
up
;
}
}
...
...
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