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
79e6883b
Unverified
Commit
79e6883b
authored
Dec 01, 2025
by
pengcheng888
Committed by
GitHub
Dec 01, 2025
Browse files
Merge pull request #683 from pengcheng888/issue/680_mm
issue/680-为mulmat添加alpha参数算子
parents
cad2d45a
4916ff8a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
9 deletions
+11
-9
include/infinicore/ops/matmul.hpp
include/infinicore/ops/matmul.hpp
+2
-2
python/infinicore/ops/matmul.py
python/infinicore/ops/matmul.py
+3
-3
src/infinicore/ops/matmul/matmul.cc
src/infinicore/ops/matmul/matmul.cc
+4
-4
src/infinicore/pybind11/ops/matmul.hpp
src/infinicore/pybind11/ops/matmul.hpp
+2
-0
No files found.
include/infinicore/ops/matmul.hpp
View file @
79e6883b
...
...
@@ -5,7 +5,7 @@
namespace
infinicore
::
op
{
Tensor
matmul
(
Tensor
a
,
Tensor
b
);
void
matmul_
(
Tensor
c
,
Tensor
a
,
Tensor
b
);
Tensor
matmul
(
Tensor
a
,
Tensor
b
,
float
alpha
=
1.0
f
);
void
matmul_
(
Tensor
c
,
Tensor
a
,
Tensor
b
,
float
alpha
=
1.0
f
);
}
// namespace infinicore::op
python/infinicore/ops/matmul.py
View file @
79e6883b
...
...
@@ -2,10 +2,10 @@ from infinicore.lib import _infinicore
from
infinicore.tensor
import
Tensor
def
matmul
(
input
,
other
,
*
,
out
=
None
):
def
matmul
(
input
,
other
,
*
,
alpha
=
1.0
,
out
=
None
):
if
out
is
None
:
return
Tensor
(
_infinicore
.
matmul
(
input
.
_underlying
,
other
.
_underlying
))
return
Tensor
(
_infinicore
.
matmul
(
input
.
_underlying
,
other
.
_underlying
,
alpha
))
_infinicore
.
matmul_
(
out
.
_underlying
,
input
.
_underlying
,
other
.
_underlying
)
_infinicore
.
matmul_
(
out
.
_underlying
,
input
.
_underlying
,
other
.
_underlying
,
alpha
)
return
out
src/infinicore/ops/matmul/matmul.cc
View file @
79e6883b
...
...
@@ -3,11 +3,11 @@
namespace
infinicore
::
op
{
Tensor
matmul
(
Tensor
a
,
Tensor
b
)
{
return
gemm
(
a
,
b
,
1.0
f
,
0.0
f
);
Tensor
matmul
(
Tensor
a
,
Tensor
b
,
float
alpha
)
{
return
gemm
(
a
,
b
,
alpha
,
0.0
f
);
}
void
matmul_
(
Tensor
c
,
Tensor
a
,
Tensor
b
)
{
Gemm
::
execute
(
c
,
a
,
b
,
1.0
f
,
0.0
f
);
void
matmul_
(
Tensor
c
,
Tensor
a
,
Tensor
b
,
float
alpha
)
{
Gemm
::
execute
(
c
,
a
,
b
,
alpha
,
0.0
f
);
}
}
// namespace infinicore::op
src/infinicore/pybind11/ops/matmul.hpp
View file @
79e6883b
...
...
@@ -13,6 +13,7 @@ inline void bind_matmul(py::module &m) {
&
op
::
matmul
,
py
::
arg
(
"a"
),
py
::
arg
(
"b"
),
py
::
arg
(
"alpha"
)
=
1.0
f
,
R"doc(Matrix multiplication of two tensors.)doc"
);
m
.
def
(
"matmul_"
,
...
...
@@ -20,6 +21,7 @@ inline void bind_matmul(py::module &m) {
py
::
arg
(
"c"
),
py
::
arg
(
"a"
),
py
::
arg
(
"b"
),
py
::
arg
(
"alpha"
)
=
1.0
f
,
R"doc(In-place matrix multiplication.)doc"
);
}
...
...
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