Commit c1032ce1 authored by wsttiger's avatar wsttiger
Browse files

Deleted some code in resnet18

parent 9b3eff99
...@@ -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;
// }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment