Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hercules
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
Hercules
Commits
de396b2c
Commit
de396b2c
authored
1 month ago
by
rarbore2
Browse files
Options
Downloads
Patches
Plain Diff
HerculesRefInto trait
parent
3a178bba
No related branches found
No related tags found
1 merge request
!185
HerculesRefInto trait
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hercules_rt/src/lib.rs
+16
-0
16 additions, 0 deletions
hercules_rt/src/lib.rs
juno_samples/matmul/src/main.rs
+3
-7
3 additions, 7 deletions
juno_samples/matmul/src/main.rs
with
19 additions
and
7 deletions
hercules_rt/src/lib.rs
+
16
−
0
View file @
de396b2c
...
...
@@ -811,3 +811,19 @@ where
self
.as_cuda_ref
()
}
}
pub
trait
HerculesRefInto
<
'a
>
{
fn
to
(
&
'a
self
)
->
HerculesCPURef
<
'a
>
;
}
impl
<
'a
,
T
>
HerculesRefInto
<
'a
>
for
&
'a
[
T
]
{
fn
to
(
&
'a
self
)
->
HerculesCPURef
<
'a
>
{
HerculesCPURef
::
from_slice
(
self
)
}
}
impl
<
'a
,
T
>
HerculesRefInto
<
'a
>
for
Box
<
[
T
]
>
{
fn
to
(
&
'a
self
)
->
HerculesCPURef
<
'a
>
{
HerculesCPURef
::
from_slice
(
self
)
}
}
This diff is collapsed.
Click to expand it.
juno_samples/matmul/src/main.rs
+
3
−
7
View file @
de396b2c
...
...
@@ -2,9 +2,9 @@
use
rand
::
random
;
use
hercules_rt
::{
runner
,
HerculesRefInto
};
#[cfg(feature
=
"cuda"
)]
use
hercules_rt
::
CUDABox
;
use
hercules_rt
::{
runner
,
HerculesCPURef
};
use
hercules_rt
::{
CUDABox
,
HerculesCPURef
};
juno_build
::
juno!
(
"matmul"
);
...
...
@@ -25,12 +25,8 @@ fn main() {
}
#[cfg(not(feature
=
"cuda"
))]
{
let
a
=
HerculesCPURef
::
from_slice
(
&
a
);
let
b
=
HerculesCPURef
::
from_slice
(
&
b
);
let
mut
r
=
runner!
(
matmul
);
let
c
=
r
.run
(
I
as
u64
,
J
as
u64
,
K
as
u64
,
a
.clone
(),
b
.clone
())
.await
;
let
c
=
r
.run
(
I
as
u64
,
J
as
u64
,
K
as
u64
,
a
.to
(),
b
.to
())
.await
;
assert_eq!
(
c
.as_slice
::
<
i32
>
(),
&*
correct_c
);
}
#[cfg(feature
=
"cuda"
)]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment