{"action":"created","comment":{"url":"https://api.github.com/repos/Theano/Theano/pulls/comments/109116017","pull_request_review_id":30196514,"id":109116017,"diff_hunk":"@@ -0,0 +1,86 @@\n+#ifndef _MKL_NDARRAY_H_\n+#define _MKL_NDARRAY_H_\n+\n+#include <numpy/arrayobject.h>\n+#include <stdio.h>\n+#include <stdint.h>\n+#include \"mkl_dnn.h\"\n+\n+#ifndef SIZE_MAX\n+#define SIZE_MAX ((size_t)(-1))\n+#endif\n+\n+#ifndef Py_TYPE\n+#define Py_TYPE(o) ((o)->ob_type)\n+#endif\n+\n+#define MAX_NDIM     (16)\n+#define MKL_FLOAT32  (11)\n+#define MKL_FLOAT64  (12)\n+\n+char* MKL_TYPE[] = {\"\", \"\", \"\", \"int16\", \"\", \"int32\", \"\", \"int64\",\n+                    \"\", \"\", \"\", \"float32\", \"float64\", \"\"};\n+\n+#if PY_MAJOR_VERSION >= 3\n+// Py3k treats all ints as longs. This one is not caught by npy_3kcompat.h.\n+#define PyNumber_Int PyNumber_Long\n+\n+#include \"numpy/npy_3kcompat.h\"\n+\n+// Py3k strings are unicode, these mimic old functionality.\n+//\n+// NOTE: npy_3kcompat.h replaces PyString_X with PyBytes_X, which breaks\n+// compatibility with some functions returning text.\n+#define PyString_Check PyUnicode_Check\n+#define PyString_FromString PyUnicode_FromString\n+#define PyString_AsString PyUnicode_AsUTF8\n+#define PyString_FromStringAndSize PyUnicode_FromStringAndSize\n+#define PyString_Size PyUnicode_GET_SIZE\n+#define PyInt_FromSize_t PyLong_FromSize_t\n+\n+// Python 3 expects a PyObject* as the first argument to PySlice_GetIndicesEx().\n+#define SLICE_CAST(x) (x)\n+#else\n+// Python 2 expects a PySliceObject* as the first argument to PySlice_GetIndicesEx().\n+#define SLICE_CAST(x) ((PySliceObject*)(x))\n+#endif // end #if PY_MAJOR_VERSION >= 3\n+\n+\n+/**\n+ * MKLNdarray: wrapper for MKL private data and layout\n+ * This is a Python type.\n+ */\n+typedef struct __MKLNdarray__{\n+\n+    PyObject_HEAD\n+    PyObject * base;\n+\n+    /* Type-specific fields go here. */\n+    int         nd;                             // the number of dimensions of the tensor, maximum is 16 (MAX_NDIM).\n+    int         dtype;                          // an integer type number is given here.\n+    size_t      data_size;                      // the number of bytes allocated for mkl_data\n+    size_t      user_structure[2 * MAX_NDIM];   // user layout: [size0, size1, ..., stride0, stride1, ..., 0, 0].\n+    dnnLayout_t private_layout;                 // layout instance create by MKL APIs\n+    void*       private_data;                   // data buffer\n+    void*       private_workspace;              // computation workspace for forward and backward\n+}MKLNdarray;\n+\n+\n+__attribute__((visibility (\"default\"))) int MKLNdarray_Check(const PyObject* ob);\n+__attribute__((visibility (\"default\"))) PyObject* MKLNdarray_New(int nd, int typenum);\n+__attribute__((visibility (\"default\"))) int MKLNdarray_CopyFromArray(MKLNdarray* self, PyArrayObject* obj);\n+__attribute__((visibility (\"default\"))) int MKLNdarray_set_structure(MKLNdarray* self, int nd, const size_t* dims);\n+__attribute__((visibility (\"default\"))) PyObject* MKLNdarray_CreateArrayObj(MKLNdarray* self);\n+\n+__attribute__((visibility (\"default\"))) void* MKLNdarray_DATA(const MKLNdarray* self);\n+__attribute__((visibility (\"default\"))) void* MKLNdarray_WORKSPACE(const MKLNdarray* self);\n+__attribute__((visibility (\"default\"))) dnnLayout_t MKLNdarray_LAYOUT(const MKLNdarray* self);\n+__attribute__((visibility (\"default\"))) const size_t* MKLNdarray_DIMS(const MKLNdarray* self);\n+__attribute__((visibility (\"default\"))) const size_t* MKLNdarray_STRIDES(const MKLNdarray* self);\n+__attribute__((visibility (\"default\"))) int MKLNdarray_NDIM(const MKLNdarray* self);\n+__attribute__((visibility (\"default\"))) int MKLNdarray_TYPE(const MKLNdarray* self);","path":"theano/sandbox/mkl/mkl_ndarray.h","position":81,"original_position":81,"commit_id":"ef9a8702ef33a9989b6e54caef19e0d07a109d33","original_commit_id":"ef9a8702ef33a9989b6e54caef19e0d07a109d33","user":{"login":"pcs-theano","id":17443780,"avatar_url":"https://avatars1.githubusercontent.com/u/17443780?v=3","gravatar_id":"","url":"https://api.github.com/users/pcs-theano","html_url":"https://github.com/pcs-theano","followers_url":"https://api.github.com/users/pcs-theano/followers","following_url":"https://api.github.com/users/pcs-theano/following{/other_user}","gists_url":"https://api.github.com/users/pcs-theano/gists{/gist_id}","starred_url":"https://api.github.com/users/pcs-theano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pcs-theano/subscriptions","organizations_url":"https://api.github.com/users/pcs-theano/orgs","repos_url":"https://api.github.com/users/pcs-theano/repos","events_url":"https://api.github.com/users/pcs-theano/events{/privacy}","received_events_url":"https://api.github.com/users/pcs-theano/received_events","type":"User","site_admin":false},"body":"Will change the code in that way.","created_at":"2017-03-31T08:54:43Z","updated_at":"2017-03-31T08:54:43Z","html_url":"https://github.com/Theano/Theano/pull/5770#discussion_r109116017","pull_request_url":"https://api.github.com/repos/Theano/Theano/pulls/5770","_links":{"self":{"href":"https://api.github.com/repos/Theano/Theano/pulls/comments/109116017"},"html":{"href":"https://github.com/Theano/Theano/pull/5770#discussion_r109116017"},"pull_request":{"href":"https://api.github.com/repos/Theano/Theano/pulls/5770"}}},"pull_request":{"url":"https://api.github.com/repos/Theano/Theano/pulls/5770","id":112700954,"html_url":"https://github.com/Theano/Theano/pull/5770","diff_url":"https://github.com/Theano/Theano/pull/5770.diff","patch_url":"https://github.com/Theano/Theano/pull/5770.patch","issue_url":"https://api.github.com/repos/Theano/Theano/issues/5770","number":5770,"state":"open","locked":false,"title":"Add MKL ndarray and MKL library check for the new MKL engine","user":{"login":"pcs-theano","id":17443780,"avatar_url":"https://avatars1.githubusercontent.com/u/17443780?v=3","gravatar_id":"","url":"https://api.github.com/users/pcs-theano","html_url":"https://github.com/pcs-theano","followers_url":"https://api.github.com/users/pcs-theano/followers","following_url":"https://api.github.com/users/pcs-theano/following{/other_user}","gists_url":"https://api.github.com/users/pcs-theano/gists{/gist_id}","starred_url":"https://api.github.com/users/pcs-theano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pcs-theano/subscriptions","organizations_url":"https://api.github.com/users/pcs-theano/orgs","repos_url":"https://api.github.com/users/pcs-theano/repos","events_url":"https://api.github.com/users/pcs-theano/events{/privacy}","received_events_url":"https://api.github.com/users/pcs-theano/received_events","type":"User","site_admin":false},"body":"As previously mentioned in issue #5580, we would like to merge our optimization with MKL engine into the master branch. Since there're a lot of code change, so we separate our implementations into several different PRs for the upstream. \r\n\r\nThis is our first PR for the optimization, we created a new folder `mkl` under sandbox for all the new codes. Also we added a new tensor type named `MKLNdarrayType` for the data with MKL layout and buffer. The new data type will be used for all the MKL related Ops.\r\n\r\nThe rest of the code changes will be separated into different PRs based on each different Op and its optimizer in the following days after this one.\r\n\r\nAny comments are welcome. \r\n\r\n","created_at":"2017-03-27T09:21:41Z","updated_at":"2017-03-31T08:54:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da995e2ba9014d83642447f10aa12c8458f19978","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Theano/Theano/pulls/5770/commits","review_comments_url":"https://api.github.com/repos/Theano/Theano/pulls/5770/comments","review_comment_url":"https://api.github.com/repos/Theano/Theano/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Theano/Theano/issues/5770/comments","statuses_url":"https://api.github.com/repos/Theano/Theano/statuses/ef9a8702ef33a9989b6e54caef19e0d07a109d33","head":{"label":"intel:mkl_ndarray","ref":"mkl_ndarray","sha":"ef9a8702ef33a9989b6e54caef19e0d07a109d33","user":{"login":"intel","id":17888862,"avatar_url":"https://avatars0.githubusercontent.com/u/17888862?v=3","gravatar_id":"","url":"https://api.github.com/users/intel","html_url":"https://github.com/intel","followers_url":"https://api.github.com/users/intel/followers","following_url":"https://api.github.com/users/intel/following{/other_user}","gists_url":"https://api.github.com/users/intel/gists{/gist_id}","starred_url":"https://api.github.com/users/intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intel/subscriptions","organizations_url":"https://api.github.com/users/intel/orgs","repos_url":"https://api.github.com/users/intel/repos","events_url":"https://api.github.com/users/intel/events{/privacy}","received_events_url":"https://api.github.com/users/intel/received_events","type":"Organization","site_admin":false},"repo":{"id":69532325,"name":"Theano","full_name":"intel/Theano","owner":{"login":"intel","id":17888862,"avatar_url":"https://avatars0.githubusercontent.com/u/17888862?v=3","gravatar_id":"","url":"https://api.github.com/users/intel","html_url":"https://github.com/intel","followers_url":"https://api.github.com/users/intel/followers","following_url":"https://api.github.com/users/intel/following{/other_user}","gists_url":"https://api.github.com/users/intel/gists{/gist_id}","starred_url":"https://api.github.com/users/intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intel/subscriptions","organizations_url":"https://api.github.com/users/intel/orgs","repos_url":"https://api.github.com/users/intel/repos","events_url":"https://api.github.com/users/intel/events{/privacy}","received_events_url":"https://api.github.com/users/intel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/intel/Theano","description":"This fork of Theano/Theano is dedicated to improve its performance on CPU device, in particular Intel® Xeon® processors and Intel® Xeon Phi™ processors.","fork":true,"url":"https://api.github.com/repos/intel/Theano","forks_url":"https://api.github.com/repos/intel/Theano/forks","keys_url":"https://api.github.com/repos/intel/Theano/keys{/key_id}","collaborators_url":"https://api.github.com/repos/intel/Theano/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/intel/Theano/teams","hooks_url":"https://api.github.com/repos/intel/Theano/hooks","issue_events_url":"https://api.github.com/repos/intel/Theano/issues/events{/number}","events_url":"https://api.github.com/repos/intel/Theano/events","assignees_url":"https://api.github.com/repos/intel/Theano/assignees{/user}","branches_url":"https://api.github.com/repos/intel/Theano/branches{/branch}","tags_url":"https://api.github.com/repos/intel/Theano/tags","blobs_url":"https://api.github.com/repos/intel/Theano/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/intel/Theano/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/intel/Theano/git/refs{/sha}","trees_url":"https://api.github.com/repos/intel/Theano/git/trees{/sha}","statuses_url":"https://api.github.com/repos/intel/Theano/statuses/{sha}","languages_url":"https://api.github.com/repos/intel/Theano/languages","stargazers_url":"https://api.github.com/repos/intel/Theano/stargazers","contributors_url":"https://api.github.com/repos/intel/Theano/contributors","subscribers_url":"https://api.github.com/repos/intel/Theano/subscribers","subscription_url":"https://api.github.com/repos/intel/Theano/subscription","commits_url":"https://api.github.com/repos/intel/Theano/commits{/sha}","git_commits_url":"https://api.github.com/repos/intel/Theano/git/commits{/sha}","comments_url":"https://api.github.com/repos/intel/Theano/comments{/number}","issue_comment_url":"https://api.github.com/repos/intel/Theano/issues/comments{/number}","contents_url":"https://api.github.com/repos/intel/Theano/contents/{+path}","compare_url":"https://api.github.com/repos/intel/Theano/compare/{base}...{head}","merges_url":"https://api.github.com/repos/intel/Theano/merges","archive_url":"https://api.github.com/repos/intel/Theano/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/intel/Theano/downloads","issues_url":"https://api.github.com/repos/intel/Theano/issues{/number}","pulls_url":"https://api.github.com/repos/intel/Theano/pulls{/number}","milestones_url":"https://api.github.com/repos/intel/Theano/milestones{/number}","notifications_url":"https://api.github.com/repos/intel/Theano/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/intel/Theano/labels{/name}","releases_url":"https://api.github.com/repos/intel/Theano/releases{/id}","deployments_url":"https://api.github.com/repos/intel/Theano/deployments","created_at":"2016-09-29T05:00:38Z","updated_at":"2017-03-30T09:23:01Z","pushed_at":"2017-03-31T02:52:45Z","git_url":"git://github.com/intel/Theano.git","ssh_url":"git@github.com:intel/Theano.git","clone_url":"https://github.com/intel/Theano.git","svn_url":"https://github.com/intel/Theano","homepage":"http://www.deeplearning.net/software/theano","size":68264,"stargazers_count":31,"watchers_count":31,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":0,"forks":9,"open_issues":0,"watchers":31,"default_branch":"master"}},"base":{"label":"Theano:master","ref":"master","sha":"b3d19ce8e8d7cdf87c3f84599be81647803aa1f6","user":{"login":"Theano","id":970517,"avatar_url":"https://avatars1.githubusercontent.com/u/970517?v=3","gravatar_id":"","url":"https://api.github.com/users/Theano","html_url":"https://github.com/Theano","followers_url":"https://api.github.com/users/Theano/followers","following_url":"https://api.github.com/users/Theano/following{/other_user}","gists_url":"https://api.github.com/users/Theano/gists{/gist_id}","starred_url":"https://api.github.com/users/Theano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Theano/subscriptions","organizations_url":"https://api.github.com/users/Theano/orgs","repos_url":"https://api.github.com/users/Theano/repos","events_url":"https://api.github.com/users/Theano/events{/privacy}","received_events_url":"https://api.github.com/users/Theano/received_events","type":"Organization","site_admin":false},"repo":{"id":2183193,"name":"Theano","full_name":"Theano/Theano","owner":{"login":"Theano","id":970517,"avatar_url":"https://avatars1.githubusercontent.com/u/970517?v=3","gravatar_id":"","url":"https://api.github.com/users/Theano","html_url":"https://github.com/Theano","followers_url":"https://api.github.com/users/Theano/followers","following_url":"https://api.github.com/users/Theano/following{/other_user}","gists_url":"https://api.github.com/users/Theano/gists{/gist_id}","starred_url":"https://api.github.com/users/Theano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Theano/subscriptions","organizations_url":"https://api.github.com/users/Theano/orgs","repos_url":"https://api.github.com/users/Theano/repos","events_url":"https://api.github.com/users/Theano/events{/privacy}","received_events_url":"https://api.github.com/users/Theano/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Theano/Theano","description":"Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. It can use GPUs and perform efficient symbolic differentiation.","fork":false,"url":"https://api.github.com/repos/Theano/Theano","forks_url":"https://api.github.com/repos/Theano/Theano/forks","keys_url":"https://api.github.com/repos/Theano/Theano/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Theano/Theano/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Theano/Theano/teams","hooks_url":"https://api.github.com/repos/Theano/Theano/hooks","issue_events_url":"https://api.github.com/repos/Theano/Theano/issues/events{/number}","events_url":"https://api.github.com/repos/Theano/Theano/events","assignees_url":"https://api.github.com/repos/Theano/Theano/assignees{/user}","branches_url":"https://api.github.com/repos/Theano/Theano/branches{/branch}","tags_url":"https://api.github.com/repos/Theano/Theano/tags","blobs_url":"https://api.github.com/repos/Theano/Theano/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Theano/Theano/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Theano/Theano/git/refs{/sha}","trees_url":"https://api.github.com/repos/Theano/Theano/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Theano/Theano/statuses/{sha}","languages_url":"https://api.github.com/repos/Theano/Theano/languages","stargazers_url":"https://api.github.com/repos/Theano/Theano/stargazers","contributors_url":"https://api.github.com/repos/Theano/Theano/contributors","subscribers_url":"https://api.github.com/repos/Theano/Theano/subscribers","subscription_url":"https://api.github.com/repos/Theano/Theano/subscription","commits_url":"https://api.github.com/repos/Theano/Theano/commits{/sha}","git_commits_url":"https://api.github.com/repos/Theano/Theano/git/commits{/sha}","comments_url":"https://api.github.com/repos/Theano/Theano/comments{/number}","issue_comment_url":"https://api.github.com/repos/Theano/Theano/issues/comments{/number}","contents_url":"https://api.github.com/repos/Theano/Theano/contents/{+path}","compare_url":"https://api.github.com/repos/Theano/Theano/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Theano/Theano/merges","archive_url":"https://api.github.com/repos/Theano/Theano/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Theano/Theano/downloads","issues_url":"https://api.github.com/repos/Theano/Theano/issues{/number}","pulls_url":"https://api.github.com/repos/Theano/Theano/pulls{/number}","milestones_url":"https://api.github.com/repos/Theano/Theano/milestones{/number}","notifications_url":"https://api.github.com/repos/Theano/Theano/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Theano/Theano/labels{/name}","releases_url":"https://api.github.com/repos/Theano/Theano/releases{/id}","deployments_url":"https://api.github.com/repos/Theano/Theano/deployments","created_at":"2011-08-10T03:48:06Z","updated_at":"2017-03-31T08:12:35Z","pushed_at":"2017-03-31T01:20:41Z","git_url":"git://github.com/Theano/Theano.git","ssh_url":"git@github.com:Theano/Theano.git","clone_url":"https://github.com/Theano/Theano.git","svn_url":"https://github.com/Theano/Theano","homepage":"http://www.deeplearning.net/software/theano","size":60614,"stargazers_count":5999,"watchers_count":5999,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2066,"mirror_url":null,"open_issues_count":726,"forks":2066,"open_issues":726,"watchers":5999,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Theano/Theano/pulls/5770"},"html":{"href":"https://github.com/Theano/Theano/pull/5770"},"issue":{"href":"https://api.github.com/repos/Theano/Theano/issues/5770"},"comments":{"href":"https://api.github.com/repos/Theano/Theano/issues/5770/comments"},"review_comments":{"href":"https://api.github.com/repos/Theano/Theano/pulls/5770/comments"},"review_comment":{"href":"https://api.github.com/repos/Theano/Theano/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Theano/Theano/pulls/5770/commits"},"statuses":{"href":"https://api.github.com/repos/Theano/Theano/statuses/ef9a8702ef33a9989b6e54caef19e0d07a109d33"}}}}
{"actor":{"display_login":"pcs-theano"}}