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
gaoqiong
MIGraphX
Commits
c1032ce1
Commit
c1032ce1
authored
Aug 14, 2018
by
wsttiger
Browse files
Deleted some code in resnet18
parent
9b3eff99
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
31 deletions
+27
-31
src/onnx/resnet18.cpp
src/onnx/resnet18.cpp
+27
-31
No files found.
src/onnx/resnet18.cpp
View file @
c1032ce1
...
@@ -61,43 +61,20 @@ int main(int argc, char const* argv[])
...
@@ -61,43 +61,20 @@ int main(int argc, char const* argv[])
auto
imageset
=
read_cifar10_images
(
datafile
);
auto
imageset
=
read_cifar10_images
(
datafile
);
// // GPU target
// GPU target
// prog.compile(migraph::gpu::target{});
prog
.
compile
(
migraph
::
gpu
::
target
{});
// migraph::program::parameter_map m;
migraph
::
program
::
parameter_map
m
;
// auto s = migraph::shape{migraph::shape::float_type, {1, 3, 32, 32}};
// m["output"] =
// migraph::gpu::to_gpu(migraph::generate_argument(prog.get_parameter_shape("output")));
// auto labels = imageset.first;
// auto input = imageset.second;
// auto ptr = input.data();
// for(int i = 0; i < 10; i++)
// {
// std::cout << "label: " << (uint32_t)labels[i] << " ----> ";
// m["0"] = migraph::gpu::to_gpu(migraph::argument{s, &ptr[3072 * i]});
// auto result = migraph::gpu::from_gpu(prog.eval(m));
// std::vector<float> logits;
// result.visit([&](auto output) { logits.assign(output.begin(), output.end()); });
// std::vector<float> probs = softmax(logits);
// for(auto x : logits)
// std::cout << x << " ";
// std::cout << std::endl;
// }
// // CPU target
// prog.compile(migraph::cpu::cpu_target{});
// auto s = migraph::shape{migraph::shape::float_type, {1, 3, 32, 32}};
// auto input3 = migraph::generate_argument(s, 12345);
// auto result = prog.eval({{"0", input3}});
prog
.
compile
(
migraph
::
cpu
::
cpu_target
{});
auto
s
=
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
1
,
3
,
32
,
32
}};
auto
s
=
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
1
,
3
,
32
,
32
}};
m
[
"output"
]
=
migraph
::
gpu
::
to_gpu
(
migraph
::
generate_argument
(
prog
.
get_parameter_shape
(
"output"
)));
auto
labels
=
imageset
.
first
;
auto
labels
=
imageset
.
first
;
auto
input
=
imageset
.
second
;
auto
input
=
imageset
.
second
;
auto
ptr
=
input
.
data
();
auto
ptr
=
input
.
data
();
for
(
int
i
=
0
;
i
<
10
;
i
++
)
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
{
std
::
cout
<<
"label: "
<<
(
uint32_t
)
labels
[
i
]
<<
" ----> "
;
std
::
cout
<<
"label: "
<<
(
uint32_t
)
labels
[
i
]
<<
" ----> "
;
auto
input3
=
migraph
::
argument
{
s
,
&
ptr
[
3072
*
i
]};
m
[
"0"
]
=
migraph
::
gpu
::
to_gpu
(
migraph
::
argument
{
s
,
&
ptr
[
3072
*
i
]}
)
;
auto
result
=
prog
.
eval
({{
"0"
,
input3
}}
);
auto
result
=
migraph
::
gpu
::
from_gpu
(
prog
.
eval
(
m
)
);
std
::
vector
<
float
>
logits
;
std
::
vector
<
float
>
logits
;
result
.
visit
([
&
](
auto
output
)
{
logits
.
assign
(
output
.
begin
(),
output
.
end
());
});
result
.
visit
([
&
](
auto
output
)
{
logits
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
probs
=
softmax
(
logits
);
std
::
vector
<
float
>
probs
=
softmax
(
logits
);
...
@@ -105,4 +82,23 @@ int main(int argc, char const* argv[])
...
@@ -105,4 +82,23 @@ int main(int argc, char const* argv[])
std
::
cout
<<
x
<<
" "
;
std
::
cout
<<
x
<<
" "
;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
}
}
// // // CPU target
// prog.compile(migraph::cpu::cpu_target{});
// auto s = migraph::shape{migraph::shape::float_type, {1, 3, 32, 32}};
// auto labels = imageset.first;
// auto input = imageset.second;
// auto ptr = input.data();
// for(int i = 0; i < 10; i++)
// {
// std::cout << "label: " << (uint32_t)labels[i] << " ----> ";
// auto input3 = migraph::argument{s, &ptr[3072 * i]};
// auto result = prog.eval({{"0", input3}});
// std::vector<float> logits;
// result.visit([&](auto output) { logits.assign(output.begin(), output.end()); });
// std::vector<float> probs = softmax(logits);
// for(auto x : logits)
// std::cout << x << " ";
// std::cout << std::endl;
// }
}
}
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