summaryrefslogtreecommitdiff
path: root/caffe2/binaries
diff options
context:
space:
mode:
authorYangqing Jia <jiayq84@gmail.com>2015-07-17 11:24:46 -0700
committerYangqing Jia <jiayq84@gmail.com>2015-07-18 07:23:09 -0700
commit47c70a43b4821fe0848345a3f6abf2c197669f30 (patch)
tree75c9379969402bebd57efcda1f5c1c10d54b689c /caffe2/binaries
parentc5166e578c90db43c2d479446673efbd3e99b01e (diff)
downloadpytorch-47c70a43b4821fe0848345a3f6abf2c197669f30.tar.gz
pytorch-47c70a43b4821fe0848345a3f6abf2c197669f30.tar.bz2
pytorch-47c70a43b4821fe0848345a3f6abf2c197669f30.zip
(1) minidb bugfix
(2) blob serialization comments (3) cudnn: putting it under a separate device name so we can explicitly choose cudnn instead of having CUDA device prioritizing it. (4) note that mint is not available with ipython due to zeromq conflict (5) db_throughput utility (6) added gprofiler
Diffstat (limited to 'caffe2/binaries')
-rw-r--r--caffe2/binaries/BREW38
-rw-r--r--caffe2/binaries/db_throughput.cc48
2 files changed, 73 insertions, 13 deletions
diff --git a/caffe2/binaries/BREW b/caffe2/binaries/BREW
index 46680ead3a..834755c08a 100644
--- a/caffe2/binaries/BREW
+++ b/caffe2/binaries/BREW
@@ -25,43 +25,56 @@ cc_binary(
)
cc_binary(
- name = "make_cifar_db",
+ name = "convert_encoded_to_raw_leveldb",
srcs = [
- "make_cifar_db.cc",
+ "convert_encoded_to_raw_leveldb.cc",
],
deps = [
- "//caffe2/db:db",
+ "//caffe2/core:core",
"//caffe2/proto:caffe2_proto",
+ "//third_party/leveldb:leveldb",
"//third_party/gflags:gflags",
"//third_party/glog:glog",
+ "//third_party/opencv:opencv_core",
+ "//third_party/opencv:opencv_highgui",
+ "//third_party/opencv:opencv_imgproc",
],
)
cc_binary(
- name = "make_image_db",
+ name = "db_throughput",
srcs = [
- "make_image_db.cc",
+ "db_throughput.cc",
+ ],
+ deps = [
+ "//caffe2/db:db",
+ "//third_party/gflags:gflags",
+ "//third_party/glog:glog",
+ "//third_party/google:profiler",
+ ],
+)
+
+cc_binary(
+ name = "make_cifar_db",
+ srcs = [
+ "make_cifar_db.cc",
],
deps = [
"//caffe2/db:db",
"//caffe2/proto:caffe2_proto",
"//third_party/gflags:gflags",
"//third_party/glog:glog",
- "//third_party/opencv:opencv_core",
- "//third_party/opencv:opencv_highgui",
- "//third_party/opencv:opencv_imgproc",
],
)
cc_binary(
- name = "convert_encoded_to_raw_leveldb",
+ name = "make_image_db",
srcs = [
- "convert_encoded_to_raw_leveldb.cc",
+ "make_image_db.cc",
],
deps = [
- "//caffe2/core:core",
+ "//caffe2/db:db",
"//caffe2/proto:caffe2_proto",
- "//third_party/leveldb:leveldb",
"//third_party/gflags:gflags",
"//third_party/glog:glog",
"//third_party/opencv:opencv_core",
@@ -70,7 +83,6 @@ cc_binary(
],
)
-
cc_binary(
name = "make_mnist_db",
srcs = [
diff --git a/caffe2/binaries/db_throughput.cc b/caffe2/binaries/db_throughput.cc
new file mode 100644
index 0000000000..7c9ae1a5bb
--- /dev/null
+++ b/caffe2/binaries/db_throughput.cc
@@ -0,0 +1,48 @@
+#include <ctime>
+#include <cstdio>
+
+#include "caffe2/core/db.h"
+#include "caffe2/proto/caffe2.pb.h"
+#include "gflags/gflags.h"
+#include "glog/logging.h"
+#include "google/profiler.h"
+
+DEFINE_string(input_db, "", "The input db.");
+DEFINE_string(input_db_type, "", "The input db type.");
+DEFINE_string(profile_file, "db_throughput_profile", "The profile output.");
+DEFINE_int32(report_interval, 1000, "The report interval.");
+DEFINE_int32(repeat, 10, "The number to repeat the throughput test.");
+
+using caffe2::db::Cursor;
+using caffe2::db::DB;
+using caffe2::string;
+
+int main(int argc, char** argv) {
+ google::InitGoogleLogging(argv[0]);
+ gflags::SetUsageMessage(
+ "This script reports the throughput .");
+ gflags::ParseCommandLineFlags(&argc, &argv, true);
+
+ std::unique_ptr<DB> in_db(caffe2::db::CreateDB(
+ FLAGS_input_db_type, FLAGS_input_db, caffe2::db::READ));
+ std::unique_ptr<Cursor> cursor(in_db->NewCursor());
+
+ ProfilerStart(FLAGS_profile_file.c_str());
+ for (int iter_id = 0; iter_id < FLAGS_repeat; ++iter_id) {
+ clock_t start = clock();
+ for (int i = 0; i < FLAGS_report_interval; ++i) {
+ volatile string key = cursor->key();
+ volatile string value = cursor->value();
+ cursor->Next();
+ if (!cursor->Valid()) {
+ cursor->SeekToFirst();
+ }
+ }
+ clock_t elapsed = clock() - start;
+ double elapsed_seconds = static_cast<double>(elapsed) / CLOCKS_PER_SEC;
+ printf("Iteration %03d, took %4.5f seconds, throughput %f items/sec.\n",
+ iter_id, elapsed_seconds, FLAGS_report_interval / elapsed_seconds);
+ }
+ ProfilerStop();
+ return 0;
+}