-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Conversation
src/operator/quadratics_op-inl.h
Outdated
@@ -0,0 +1,31 @@ | |||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional?
13b7a65
to
fd39a23
Compare
@juliusshufan is mkl act test on your test plan? you can work w/ @azai91 for this test. |
119a21e
to
857c3d4
Compare
tests/cpp/operator/mkldnn.cc
Outdated
attrs.attrs.dict.insert({"act_type", "relu"}); | ||
attrs.attrs.op->attr_parser(&attrs.attrs); | ||
attrs.dispatches.resize(1); | ||
attrs.dispatches[0] = DispatchMode::kFCompute; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need kFComputeEx here. MKLDNN uses kFComputeEx.
tests/cpp/operator/mkldnn.cc
Outdated
for (int i = 0; i < size; i++) | ||
data[i] = i - shift; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only works for the default layout. You need a version for the MKLDNN format as well.
tests/cpp/operator/mkldnn.cc
Outdated
TestArrayShapes tas = GetTestArrayShapes(); | ||
std::vector<nnvm::TShape> shapes = tas.shapes; | ||
std::vector<mkldnn::memory::primitive_desc> pds = tas.pds; | ||
|
||
std::vector<NDArray> in_arrs; | ||
for (auto shape : shapes) { | ||
in_arrs.emplace_back(shape, Context()); | ||
InitArray(&in_arrs.back()); | ||
init_fn(&in_arrs.back()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need a version to initialize the MKLDNN NDArray as well.
tests/cpp/operator/mkldnn.cc
Outdated
mshadow::default_real_t *d2 = static_cast<mshadow::default_real_t*>(blob2.dptr_); | ||
EXPECT_EQ(tmp1.shape().Size(), tmp2.shape().Size()); | ||
for (size_t i = 0; i < tmp1.shape().Size(); i++) { | ||
EXPECT_EQ(d1[i], std::abs(d2[i])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abs? if it's negative, it should be 0.
tests/cpp/operator/mkldnn.cc
Outdated
} | ||
} | ||
|
||
void TestOp(const OpAttrs &attrs, InitFunc init_fn, VerifyFunc verify_fn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function actually can only test unary operators. It's better to have unary in the name
c987bca
to
2d24c60
Compare
tests/cpp/operator/mkldnn.cc
Outdated
std::vector<NDArray> in_arrs; | ||
in_arrs.emplace_back(shape, Context()); | ||
InitArray(&in_arrs.back()); | ||
init_fn(&in_arrs.back(), false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you make them true as well?
tests/cpp/operator/mkldnn.cc
Outdated
|
||
// Get a reused version. | ||
nnvm::TShape s(1); | ||
s[0] = shape.Size(); | ||
NDArray arr(s, Context()); | ||
arr = arr.AsArray(shape, arr.dtype()); | ||
InitArray(&arr); | ||
init_fn(&arr, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same here
tests/cpp/operator/mkldnn.cc
Outdated
const TBlob &blob = arr->data(); | ||
mshadow::default_real_t *data = blob.dptr<mshadow::default_real_t>(); | ||
size_t size = blob.Size(); | ||
for (size_t i = 0; i < size; i++) | ||
data[i] = i; | ||
if (is_rand) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_rand inside the for loop ?
tests/cpp/operator/mkldnn.cc
Outdated
const TBlob &blob = arr->data(); | ||
mshadow::default_real_t *data = blob.dptr<mshadow::default_real_t>(); | ||
size_t size = blob.Size(); | ||
int size = blob.Size(); | ||
if (is_rand) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_rand should be inside the for loop
can you fix lint |
src/operator/nn/mkldnn/mkldnn_sum.cc
Outdated
} else { | ||
in_mem = inputs[i].GetMKLDNNData(); | ||
} | ||
in_mem = inputs[i].GetMKLDNNData(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you modify the code here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woops realized it was not the same. reverted.
ded9ecc
to
2e0c42a
Compare
tests/cpp/operator/mkldnn.cc
Outdated
} | ||
} | ||
} | ||
|
||
TEST(IMPERATIVE, UnaryOp) { | ||
OpAttrs attrs = GetCopyOp(); | ||
TestUnaryOp(attrs, VerifyCopyResult); | ||
TestUnaryOp(attrs, InitDefaultArray, VerifyCopyResult); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fix the indent here.
* add mkl act unit test * fix operator name * use custom ndarray init * func missing param * add init fn for act operator test * remove extra white space * fix fetch relu operator * fix get relu operator name * add assert abs in verify fn * remove unused operator * cast blob ptr to float * use parsed param * use attr_parser * fix header order * update test fn name * use relu fn * add kFComputeEx dispatch * init posneg mklarray * fix generating rnd pos neg ints * output arrays are rnd generated * test that getinputarrays creates view and mkldnn arrays * add more output types * fix typo * fix gettestput test * create arrattr struct to display arr info * refactor initarray * print arr description in verify fn * use long int string interpolation * fix alias params * iterate over dims * print c_str * print output info * improve print message * improve print * fix new lines in output * refactor print messages * fix typos * fix lint issues * fix rebase * pass ndarray as ptr * store copy of ndarray in attrs obj * fix rem inits * fix dispatch size * move print earlier * use createmkldnnmem helper fun * fix lint * refactor if else statement * use buffer ndarray * fix spacing * fix refactor * revert sum refactor * use fallback compute * fix typo * fix lint * use fallbackcompute fn for act operator * convert activation impl funcs to fxcompute std * remove unused var * move unused variable * fix indent
* add mkl act unit test * fix operator name * use custom ndarray init * func missing param * add init fn for act operator test * remove extra white space * fix fetch relu operator * fix get relu operator name * add assert abs in verify fn * remove unused operator * cast blob ptr to float * use parsed param * use attr_parser * fix header order * update test fn name * use relu fn * add kFComputeEx dispatch * init posneg mklarray * fix generating rnd pos neg ints * output arrays are rnd generated * test that getinputarrays creates view and mkldnn arrays * add more output types * fix typo * fix gettestput test * create arrattr struct to display arr info * refactor initarray * print arr description in verify fn * use long int string interpolation * fix alias params * iterate over dims * print c_str * print output info * improve print message * improve print * fix new lines in output * refactor print messages * fix typos * fix lint issues * fix rebase * pass ndarray as ptr * store copy of ndarray in attrs obj * fix rem inits * fix dispatch size * move print earlier * use createmkldnnmem helper fun * fix lint * refactor if else statement * use buffer ndarray * fix spacing * fix refactor * revert sum refactor * use fallback compute * fix typo * fix lint * use fallbackcompute fn for act operator * convert activation impl funcs to fxcompute std * remove unused var * move unused variable * fix indent
Description
(Brief description on what this PR is about)
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments