{"action":"created","comment":{"url":"https://api.github.com/repos/chainer/chainer/pulls/comments/243931909","pull_request_review_id":187815706,"id":243931909,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MzkzMTkwOQ==","diff_hunk":"@@ -0,0 +1,76 @@\n+#include \"mnist.h\"\n+\n+#include <cassert>\n+#include <cstdint>\n+#include <fstream>\n+#include <memory>\n+#include <string>\n+\n+#include \"chainerx/array.h\"\n+#include \"chainerx/device.h\"\n+#include \"chainerx/dtype.h\"\n+#include \"chainerx/routines/creation.h\"\n+#include \"chainerx/shape.h\"\n+\n+namespace chx = chainerx;\n+\n+namespace {\n+\n+chx::Array ReadArray(std::ifstream& ifs, const chx::Shape& shape) {\n+    int64_t n = shape.GetTotalSize();\n+\n+    std::shared_ptr<uint8_t> data{new uint8_t[n], std::default_delete<uint8_t[]>{}};\n+    ifs.read(reinterpret_cast<char*>(data.get()), n);\n+\n+    return chx::FromContiguousHostData(shape, chx::Dtype::kUInt8, static_cast<std::shared_ptr<void>>(data), chx::GetDefaultDevice());\n+}\n+\n+int32_t ReadInt32(std::ifstream& ifs) {\n+    int32_t result = 0;\n+    for (int i = 0; i < 4; ++i) {\n+        char byte;\n+        ifs.read(&byte, sizeof(byte));\n+        result = (result << 8) | (static_cast<uint32_t>(byte) & 0xff);","path":"chainerx_cc/examples/mnist_cc/mnist.cc","position":33,"original_position":33,"commit_id":"48100acba4e47d71e81de2511ab7018e83edeb47","original_commit_id":"48100acba4e47d71e81de2511ab7018e83edeb47","user":{"login":"niboshi","id":635436,"node_id":"MDQ6VXNlcjYzNTQzNg==","avatar_url":"https://avatars0.githubusercontent.com/u/635436?v=4","gravatar_id":"","url":"https://api.github.com/users/niboshi","html_url":"https://github.com/niboshi","followers_url":"https://api.github.com/users/niboshi/followers","following_url":"https://api.github.com/users/niboshi/following{/other_user}","gists_url":"https://api.github.com/users/niboshi/gists{/gist_id}","starred_url":"https://api.github.com/users/niboshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/niboshi/subscriptions","organizations_url":"https://api.github.com/users/niboshi/orgs","repos_url":"https://api.github.com/users/niboshi/repos","events_url":"https://api.github.com/users/niboshi/events{/privacy}","received_events_url":"https://api.github.com/users/niboshi/received_events","type":"User","site_admin":false},"body":"OK, then how about this?\r\n\r\n```suggestion\r\n        result = (result << 8) | static_cast<uint32_t>(static_cast<uint8_t>(byte));\r\n```","created_at":"2018-12-26T02:17:01Z","updated_at":"2018-12-26T02:17:01Z","html_url":"https://github.com/chainer/chainer/pull/5746#discussion_r243931909","pull_request_url":"https://api.github.com/repos/chainer/chainer/pulls/5746","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/chainer/chainer/pulls/comments/243931909"},"html":{"href":"https://github.com/chainer/chainer/pull/5746#discussion_r243931909"},"pull_request":{"href":"https://api.github.com/repos/chainer/chainer/pulls/5746"}},"in_reply_to_id":243896993},"pull_request":{"url":"https://api.github.com/repos/chainer/chainer/pulls/5746","id":234597201,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM0NTk3MjAx","html_url":"https://github.com/chainer/chainer/pull/5746","diff_url":"https://github.com/chainer/chainer/pull/5746.diff","patch_url":"https://github.com/chainer/chainer/pull/5746.patch","issue_url":"https://api.github.com/repos/chainer/chainer/issues/5746","number":5746,"state":"open","locked":false,"title":"ChainerX MNIST C++ example","user":{"login":"hvy","id":5983694,"node_id":"MDQ6VXNlcjU5ODM2OTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5983694?v=4","gravatar_id":"","url":"https://api.github.com/users/hvy","html_url":"https://github.com/hvy","followers_url":"https://api.github.com/users/hvy/followers","following_url":"https://api.github.com/users/hvy/following{/other_user}","gists_url":"https://api.github.com/users/hvy/gists{/gist_id}","starred_url":"https://api.github.com/users/hvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvy/subscriptions","organizations_url":"https://api.github.com/users/hvy/orgs","repos_url":"https://api.github.com/users/hvy/repos","events_url":"https://api.github.com/users/hvy/events{/privacy}","received_events_url":"https://api.github.com/users/hvy/received_events","type":"User","site_admin":false},"body":"This PR introduces an experimental MNIST MLP example written in C++ using ChainerX.\r\n\r\nIt can be built with `cmake`.\r\n\r\n```shell\r\ncd chainerx_cc\r\nmkdir build\r\ncd build\r\ncmake .. \\\r\n    -DCMAKE_BUILD_TYPE=Release \\\r\n    -DCHAINERX_BUILD_EXAMPLES=ON \\\r\n    -DCHAINERX_BUILD_CUDA=ON \\\r\n    -DCUDNN_ROOT_DIR=/path/to/cudnn\r\nmake -j16\r\n./examples/mnist_cc/train_mnist --epoch 10 --device cuda:0 --data /my/mnist/root\r\n```\r\n\r\n`/my/mnist/root` is a directory containing the MNIST dataset (the 4 files `train-images-idx3-ubyte`, `train-labels-idx1-ubyte`, `t10k-images-idx3-ubyte` and `t10k-labels-idx1-ubyte`).","created_at":"2018-11-29T11:12:09Z","updated_at":"2018-12-26T02:17:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"16532c119e5669fee0b488bd47560debdda7bbc6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1144360898,"node_id":"MDU6TGFiZWwxMTQ0MzYwODk4","url":"https://api.github.com/repos/chainer/chainer/labels/ChainerX","name":"ChainerX","color":"006b75","default":false},{"id":227815550,"node_id":"MDU6TGFiZWwyMjc4MTU1NTA=","url":"https://api.github.com/repos/chainer/chainer/labels/cat:example","name":"cat:example","color":"5319e7","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/chainer/chainer/pulls/5746/commits","review_comments_url":"https://api.github.com/repos/chainer/chainer/pulls/5746/comments","review_comment_url":"https://api.github.com/repos/chainer/chainer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chainer/chainer/issues/5746/comments","statuses_url":"https://api.github.com/repos/chainer/chainer/statuses/48100acba4e47d71e81de2511ab7018e83edeb47","head":{"label":"hvy:mnist-cpp-example","ref":"mnist-cpp-example","sha":"48100acba4e47d71e81de2511ab7018e83edeb47","user":{"login":"hvy","id":5983694,"node_id":"MDQ6VXNlcjU5ODM2OTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5983694?v=4","gravatar_id":"","url":"https://api.github.com/users/hvy","html_url":"https://github.com/hvy","followers_url":"https://api.github.com/users/hvy/followers","following_url":"https://api.github.com/users/hvy/following{/other_user}","gists_url":"https://api.github.com/users/hvy/gists{/gist_id}","starred_url":"https://api.github.com/users/hvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvy/subscriptions","organizations_url":"https://api.github.com/users/hvy/orgs","repos_url":"https://api.github.com/users/hvy/repos","events_url":"https://api.github.com/users/hvy/events{/privacy}","received_events_url":"https://api.github.com/users/hvy/received_events","type":"User","site_admin":false},"repo":{"id":53650069,"node_id":"MDEwOlJlcG9zaXRvcnk1MzY1MDA2OQ==","name":"chainer","full_name":"hvy/chainer","private":false,"owner":{"login":"hvy","id":5983694,"node_id":"MDQ6VXNlcjU5ODM2OTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5983694?v=4","gravatar_id":"","url":"https://api.github.com/users/hvy","html_url":"https://github.com/hvy","followers_url":"https://api.github.com/users/hvy/followers","following_url":"https://api.github.com/users/hvy/following{/other_user}","gists_url":"https://api.github.com/users/hvy/gists{/gist_id}","starred_url":"https://api.github.com/users/hvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvy/subscriptions","organizations_url":"https://api.github.com/users/hvy/orgs","repos_url":"https://api.github.com/users/hvy/repos","events_url":"https://api.github.com/users/hvy/events{/privacy}","received_events_url":"https://api.github.com/users/hvy/received_events","type":"User","site_admin":false},"html_url":"https://github.com/hvy/chainer","description":"A flexible framework of neural networks for deep learning","fork":true,"url":"https://api.github.com/repos/hvy/chainer","forks_url":"https://api.github.com/repos/hvy/chainer/forks","keys_url":"https://api.github.com/repos/hvy/chainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hvy/chainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hvy/chainer/teams","hooks_url":"https://api.github.com/repos/hvy/chainer/hooks","issue_events_url":"https://api.github.com/repos/hvy/chainer/issues/events{/number}","events_url":"https://api.github.com/repos/hvy/chainer/events","assignees_url":"https://api.github.com/repos/hvy/chainer/assignees{/user}","branches_url":"https://api.github.com/repos/hvy/chainer/branches{/branch}","tags_url":"https://api.github.com/repos/hvy/chainer/tags","blobs_url":"https://api.github.com/repos/hvy/chainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hvy/chainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hvy/chainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/hvy/chainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hvy/chainer/statuses/{sha}","languages_url":"https://api.github.com/repos/hvy/chainer/languages","stargazers_url":"https://api.github.com/repos/hvy/chainer/stargazers","contributors_url":"https://api.github.com/repos/hvy/chainer/contributors","subscribers_url":"https://api.github.com/repos/hvy/chainer/subscribers","subscription_url":"https://api.github.com/repos/hvy/chainer/subscription","commits_url":"https://api.github.com/repos/hvy/chainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/hvy/chainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/hvy/chainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/hvy/chainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/hvy/chainer/contents/{+path}","compare_url":"https://api.github.com/repos/hvy/chainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hvy/chainer/merges","archive_url":"https://api.github.com/repos/hvy/chainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hvy/chainer/downloads","issues_url":"https://api.github.com/repos/hvy/chainer/issues{/number}","pulls_url":"https://api.github.com/repos/hvy/chainer/pulls{/number}","milestones_url":"https://api.github.com/repos/hvy/chainer/milestones{/number}","notifications_url":"https://api.github.com/repos/hvy/chainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hvy/chainer/labels{/name}","releases_url":"https://api.github.com/repos/hvy/chainer/releases{/id}","deployments_url":"https://api.github.com/repos/hvy/chainer/deployments","created_at":"2016-03-11T08:02:21Z","updated_at":"2018-12-21T06:30:43Z","pushed_at":"2018-12-26T01:15:32Z","git_url":"git://github.com/hvy/chainer.git","ssh_url":"git@github.com:hvy/chainer.git","clone_url":"https://github.com/hvy/chainer.git","svn_url":"https://github.com/hvy/chainer","homepage":"http://chainer.org","size":44515,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"chainer:master","ref":"master","sha":"b07650278d9e5829feac96eac7f2f1202095f454","user":{"login":"chainer","id":23183003,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzMTgzMDAz","avatar_url":"https://avatars3.githubusercontent.com/u/23183003?v=4","gravatar_id":"","url":"https://api.github.com/users/chainer","html_url":"https://github.com/chainer","followers_url":"https://api.github.com/users/chainer/followers","following_url":"https://api.github.com/users/chainer/following{/other_user}","gists_url":"https://api.github.com/users/chainer/gists{/gist_id}","starred_url":"https://api.github.com/users/chainer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chainer/subscriptions","organizations_url":"https://api.github.com/users/chainer/orgs","repos_url":"https://api.github.com/users/chainer/repos","events_url":"https://api.github.com/users/chainer/events{/privacy}","received_events_url":"https://api.github.com/users/chainer/received_events","type":"Organization","site_admin":false},"repo":{"id":36914478,"node_id":"MDEwOlJlcG9zaXRvcnkzNjkxNDQ3OA==","name":"chainer","full_name":"chainer/chainer","private":false,"owner":{"login":"chainer","id":23183003,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzMTgzMDAz","avatar_url":"https://avatars3.githubusercontent.com/u/23183003?v=4","gravatar_id":"","url":"https://api.github.com/users/chainer","html_url":"https://github.com/chainer","followers_url":"https://api.github.com/users/chainer/followers","following_url":"https://api.github.com/users/chainer/following{/other_user}","gists_url":"https://api.github.com/users/chainer/gists{/gist_id}","starred_url":"https://api.github.com/users/chainer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chainer/subscriptions","organizations_url":"https://api.github.com/users/chainer/orgs","repos_url":"https://api.github.com/users/chainer/repos","events_url":"https://api.github.com/users/chainer/events{/privacy}","received_events_url":"https://api.github.com/users/chainer/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/chainer/chainer","description":"A flexible framework of neural networks for deep learning","fork":false,"url":"https://api.github.com/repos/chainer/chainer","forks_url":"https://api.github.com/repos/chainer/chainer/forks","keys_url":"https://api.github.com/repos/chainer/chainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chainer/chainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chainer/chainer/teams","hooks_url":"https://api.github.com/repos/chainer/chainer/hooks","issue_events_url":"https://api.github.com/repos/chainer/chainer/issues/events{/number}","events_url":"https://api.github.com/repos/chainer/chainer/events","assignees_url":"https://api.github.com/repos/chainer/chainer/assignees{/user}","branches_url":"https://api.github.com/repos/chainer/chainer/branches{/branch}","tags_url":"https://api.github.com/repos/chainer/chainer/tags","blobs_url":"https://api.github.com/repos/chainer/chainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chainer/chainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chainer/chainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/chainer/chainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chainer/chainer/statuses/{sha}","languages_url":"https://api.github.com/repos/chainer/chainer/languages","stargazers_url":"https://api.github.com/repos/chainer/chainer/stargazers","contributors_url":"https://api.github.com/repos/chainer/chainer/contributors","subscribers_url":"https://api.github.com/repos/chainer/chainer/subscribers","subscription_url":"https://api.github.com/repos/chainer/chainer/subscription","commits_url":"https://api.github.com/repos/chainer/chainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/chainer/chainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/chainer/chainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/chainer/chainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/chainer/chainer/contents/{+path}","compare_url":"https://api.github.com/repos/chainer/chainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chainer/chainer/merges","archive_url":"https://api.github.com/repos/chainer/chainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chainer/chainer/downloads","issues_url":"https://api.github.com/repos/chainer/chainer/issues{/number}","pulls_url":"https://api.github.com/repos/chainer/chainer/pulls{/number}","milestones_url":"https://api.github.com/repos/chainer/chainer/milestones{/number}","notifications_url":"https://api.github.com/repos/chainer/chainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chainer/chainer/labels{/name}","releases_url":"https://api.github.com/repos/chainer/chainer/releases{/id}","deployments_url":"https://api.github.com/repos/chainer/chainer/deployments","created_at":"2015-06-05T05:50:37Z","updated_at":"2018-12-26T01:25:37Z","pushed_at":"2018-12-26T01:29:01Z","git_url":"git://github.com/chainer/chainer.git","ssh_url":"git@github.com:chainer/chainer.git","clone_url":"https://github.com/chainer/chainer.git","svn_url":"https://github.com/chainer/chainer","homepage":"https://chainer.org","size":40616,"stargazers_count":4406,"watchers_count":4406,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1169,"mirror_url":null,"archived":false,"open_issues_count":260,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1169,"open_issues":260,"watchers":4406,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chainer/chainer/pulls/5746"},"html":{"href":"https://github.com/chainer/chainer/pull/5746"},"issue":{"href":"https://api.github.com/repos/chainer/chainer/issues/5746"},"comments":{"href":"https://api.github.com/repos/chainer/chainer/issues/5746/comments"},"review_comments":{"href":"https://api.github.com/repos/chainer/chainer/pulls/5746/comments"},"review_comment":{"href":"https://api.github.com/repos/chainer/chainer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chainer/chainer/pulls/5746/commits"},"statuses":{"href":"https://api.github.com/repos/chainer/chainer/statuses/48100acba4e47d71e81de2511ab7018e83edeb47"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"niboshi"}}