Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes in MKL add_n to address several regressions #13021

Merged
merged 3 commits into from
Sep 20, 2017

Conversation

agramesh1
Copy link
Contributor

Fixed failures due to scalar and empty tensors

@mention-bot
Copy link

@agramesh1, thanks for your PR! By analyzing the history of the files in this pull request, we identified @jinghuangintel to be a potential reviewer.

@tensorflow-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@drpngx
Copy link
Contributor

drpngx commented Sep 13, 2017

@rmlarsen could you take a look?

@drpngx drpngx added the awaiting review Pull request awaiting review label Sep 13, 2017
@caisq
Copy link
Contributor

caisq commented Sep 19, 2017

Gentle ping, @rmlarsen

@@ -54,17 +54,63 @@ class MklAddNOp : public OpKernel {
GetMklShape(ctx, 1, &(mkl_context.input2_shape));
bool input2_in_mkl_format = mkl_context.input2_shape.IsMklTensor();

// handle the case of a scalar
if (!input1_in_mkl_format && !input0.dims()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer input0.dims() == 0.

mkl_context.output_shape.SetMklTensor(false);
AllocateOutputSetMklShape(ctx, 0, &out_tensor, o_shape,
mkl_context.output_shape);
void* out_o = const_cast<void*>(static_cast<const void*>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use tensor->scalar()() to access the scalar value (both lvalue and rvalue), instead of all the ugly casting.

Tensor* out_tensor = nullptr;
mkl_context.output_shape.SetMklTensor(false);
AllocateOutputSetMklShape(ctx, 0, &out_tensor, o_shape,
mkl_context.output_shape);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad indent

@@ -246,15 +259,15 @@ class MklAddNOp : public OpKernel {
bool input1_in_mkl_format = input1_shape.IsMklTensor();
bool input2_in_mkl_format = input2_shape.IsMklTensor();
dnnDelete_F32(Eltwise);
if (!input1_in_mkl_format || !input2_in_mkl_format) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition should be

if (input1_in_mkl_format || input2_in_mkl_format) {

To be the opposite of line 81.

Copy link
Member

@rmlarsen rmlarsen Sep 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agramesh1 are you going to address this one? I think you'll leak memory otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmlarsen this part is the opposite of line 173 and 182, only in the case that input 1 and input 2 are not in mkl format, we will need to allocate the array. so we will release the buffer only in the case these two are not in mkl format. Thank you ~ please let me know if you have any suggestions. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, I guess I didn't look at the fully expanded view :-) Thanks for pointing that out.


size_t* in2_sizes;
size_t* in2_strides;
size_t* in_sizes;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set both to nullptr either here or in initializer list of constructor.

Copy link
Member

@rmlarsen rmlarsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address previous comments.

@rmlarsen rmlarsen added stat:awaiting response Status - Awaiting response from author and removed awaiting review Pull request awaiting review labels Sep 19, 2017
AllocateOutputSetMklShape(ctx, 0, &out_tensor, o_shape,
Tensor* out_tensor = nullptr;
mkl_context.output_shape.SetMklTensor(false);
AllocateOutputSetMklShape(ctx, 0, &out_tensor, o_shape,
mkl_context.output_shape);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still missing an extra indent in line 85.

@rmlarsen
Copy link
Member

@tensorflow-jenkins test this please

@rmlarsen
Copy link
Member

@tensorflow-jenkins test this please

@rmlarsen rmlarsen added awaiting testing (then merge) and removed stat:awaiting response Status - Awaiting response from author labels Sep 20, 2017
@rmlarsen rmlarsen merged commit 8f27889 into tensorflow:master Sep 20, 2017
@rmlarsen
Copy link
Member

@agramesh1 thanks for the improvement.

@nammbash nammbash deleted the mkl_addn_fixes branch April 24, 2020 22:21
copybara-service bot pushed a commit that referenced this pull request May 23, 2024
Imported from GitHub PR openxla/xla#13021

replaces EXPECT_OK with TF_EXPECT_OK and added relevant header file and dependency.

Error:
#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:134:3: error: use of undeclared identifier 'EXPECT_OK'
[1792](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1792)#10 1431.9   134 |   EXPECT_OK(dense_module);
[1793](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1793)#10 1431.9       |   ^
[1794](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1794)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:137:3: error: use of undeclared identifier 'EXPECT_OK'
[1795](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1795)#10 1431.9   137 |   EXPECT_OK(dense_result);
[1796](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1796)#10 1431.9       |   ^
[1797](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1797)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:158:3: error: use of undeclared identifier 'EXPECT_OK'
[1798](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1798)#10 1431.9   158 |   EXPECT_OK(sparse_module);
[1799](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1799)#10 1431.9       |   ^
[1800](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1800)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:161:3: error: use of undeclared identifier 'EXPECT_OK'
[1801](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1801)#10 1431.9   161 |   EXPECT_OK(sparse_result);
[1802](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1802)#10 1431.9       |   ^
Copybara import of the project:

--
a7d07b02230794d9c13175b39473666d5d067c54 by hmonishN <hmonish@nvidia.com>:

fixing build issue for this test

--
e45b3b975c40b318ac4918859b364d8e8c3b304a by hmonishN <hmonish@nvidia.com>:

fix build error

--
077b7a5b8277cb2e55b57aca64102871326afd0d by Harshit Monish <143435143+hmonishN@users.noreply.github.com>:

Incorporated review comment.

Merging this change closes #13021

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#13021 from hmonishN:hmonish/fix_gpu_sparse_dot_test_build_issue 077b7a5b8277cb2e55b57aca64102871326afd0d
PiperOrigin-RevId: 636702747
copybara-service bot pushed a commit that referenced this pull request May 24, 2024
Imported from GitHub PR openxla/xla#13021

replaces EXPECT_OK with TF_EXPECT_OK and added relevant header file and dependency.

Error:
#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:134:3: error: use of undeclared identifier 'EXPECT_OK'
[1792](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1792)#10 1431.9   134 |   EXPECT_OK(dense_module);
[1793](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1793)#10 1431.9       |   ^
[1794](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1794)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:137:3: error: use of undeclared identifier 'EXPECT_OK'
[1795](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1795)#10 1431.9   137 |   EXPECT_OK(dense_result);
[1796](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1796)#10 1431.9       |   ^
[1797](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1797)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:158:3: error: use of undeclared identifier 'EXPECT_OK'
[1798](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1798)#10 1431.9   158 |   EXPECT_OK(sparse_module);
[1799](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1799)#10 1431.9       |   ^
[1800](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1800)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:161:3: error: use of undeclared identifier 'EXPECT_OK'
[1801](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1801)#10 1431.9   161 |   EXPECT_OK(sparse_result);
[1802](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1802)#10 1431.9       |   ^
Copybara import of the project:

--
a7d07b02230794d9c13175b39473666d5d067c54 by hmonishN <hmonish@nvidia.com>:

fixing build issue for this test

--
e45b3b975c40b318ac4918859b364d8e8c3b304a by hmonishN <hmonish@nvidia.com>:

fix build error

--
077b7a5b8277cb2e55b57aca64102871326afd0d by Harshit Monish <143435143+hmonishN@users.noreply.github.com>:

Incorporated review comment.

Merging this change closes #13021

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#13021 from hmonishN:hmonish/fix_gpu_sparse_dot_test_build_issue 077b7a5b8277cb2e55b57aca64102871326afd0d
PiperOrigin-RevId: 636702747
copybara-service bot pushed a commit that referenced this pull request May 24, 2024
Imported from GitHub PR openxla/xla#13021

replaces EXPECT_OK with TF_EXPECT_OK and added relevant header file and dependency.

Error:
#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:134:3: error: use of undeclared identifier 'EXPECT_OK'
[1792](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1792)#10 1431.9   134 |   EXPECT_OK(dense_module);
[1793](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1793)#10 1431.9       |   ^
[1794](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1794)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:137:3: error: use of undeclared identifier 'EXPECT_OK'
[1795](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1795)#10 1431.9   137 |   EXPECT_OK(dense_result);
[1796](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1796)#10 1431.9       |   ^
[1797](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1797)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:158:3: error: use of undeclared identifier 'EXPECT_OK'
[1798](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1798)#10 1431.9   158 |   EXPECT_OK(sparse_module);
[1799](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1799)#10 1431.9       |   ^
[1800](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1800)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:161:3: error: use of undeclared identifier 'EXPECT_OK'
[1801](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1801)#10 1431.9   161 |   EXPECT_OK(sparse_result);
[1802](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1802)#10 1431.9       |   ^
Copybara import of the project:

--
a7d07b02230794d9c13175b39473666d5d067c54 by hmonishN <hmonish@nvidia.com>:

fixing build issue for this test

--
e45b3b975c40b318ac4918859b364d8e8c3b304a by hmonishN <hmonish@nvidia.com>:

fix build error

--
077b7a5b8277cb2e55b57aca64102871326afd0d by Harshit Monish <143435143+hmonishN@users.noreply.github.com>:

Incorporated review comment.

Merging this change closes #13021

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#13021 from hmonishN:hmonish/fix_gpu_sparse_dot_test_build_issue 077b7a5b8277cb2e55b57aca64102871326afd0d
PiperOrigin-RevId: 636702747
copybara-service bot pushed a commit that referenced this pull request May 24, 2024
Imported from GitHub PR openxla/xla#13021

replaces EXPECT_OK with TF_EXPECT_OK and added relevant header file and dependency.

Error:
#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:134:3: error: use of undeclared identifier 'EXPECT_OK'
[1792](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1792)#10 1431.9   134 |   EXPECT_OK(dense_module);
[1793](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1793)#10 1431.9       |   ^
[1794](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1794)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:137:3: error: use of undeclared identifier 'EXPECT_OK'
[1795](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1795)#10 1431.9   137 |   EXPECT_OK(dense_result);
[1796](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1796)#10 1431.9       |   ^
[1797](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1797)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:158:3: error: use of undeclared identifier 'EXPECT_OK'
[1798](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1798)#10 1431.9   158 |   EXPECT_OK(sparse_module);
[1799](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1799)#10 1431.9       |   ^
[1800](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1800)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:161:3: error: use of undeclared identifier 'EXPECT_OK'
[1801](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1801)#10 1431.9   161 |   EXPECT_OK(sparse_result);
[1802](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1802)#10 1431.9       |   ^
Copybara import of the project:

--
a7d07b02230794d9c13175b39473666d5d067c54 by hmonishN <hmonish@nvidia.com>:

fixing build issue for this test

--
e45b3b975c40b318ac4918859b364d8e8c3b304a by hmonishN <hmonish@nvidia.com>:

fix build error

--
077b7a5b8277cb2e55b57aca64102871326afd0d by Harshit Monish <143435143+hmonishN@users.noreply.github.com>:

Incorporated review comment.

Merging this change closes #13021

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#13021 from hmonishN:hmonish/fix_gpu_sparse_dot_test_build_issue 077b7a5b8277cb2e55b57aca64102871326afd0d
PiperOrigin-RevId: 636702747
copybara-service bot pushed a commit that referenced this pull request May 24, 2024
Imported from GitHub PR openxla/xla#13021

replaces EXPECT_OK with TF_EXPECT_OK and added relevant header file and dependency.

Error:
#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:134:3: error: use of undeclared identifier 'EXPECT_OK'
[1792](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1792)#10 1431.9   134 |   EXPECT_OK(dense_module);
[1793](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1793)#10 1431.9       |   ^
[1794](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1794)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:137:3: error: use of undeclared identifier 'EXPECT_OK'
[1795](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1795)#10 1431.9   137 |   EXPECT_OK(dense_result);
[1796](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1796)#10 1431.9       |   ^
[1797](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1797)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:158:3: error: use of undeclared identifier 'EXPECT_OK'
[1798](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1798)#10 1431.9   158 |   EXPECT_OK(sparse_module);
[1799](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1799)#10 1431.9       |   ^
[1800](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1800)#10 1431.9 xla/service/gpu/tests/gpu_sparse_dot_test.cc:161:3: error: use of undeclared identifier 'EXPECT_OK'
[1801](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1801)#10 1431.9   161 |   EXPECT_OK(sparse_result);
[1802](https://gitlab-master.nvidia.com/dl/openxla/ci/-/jobs/94442414#L1802)#10 1431.9       |   ^
Copybara import of the project:

--
a7d07b02230794d9c13175b39473666d5d067c54 by hmonishN <hmonish@nvidia.com>:

fixing build issue for this test

--
e45b3b975c40b318ac4918859b364d8e8c3b304a by hmonishN <hmonish@nvidia.com>:

fix build error

--
077b7a5b8277cb2e55b57aca64102871326afd0d by Harshit Monish <143435143+hmonishN@users.noreply.github.com>:

Incorporated review comment.

Merging this change closes #13021

PiperOrigin-RevId: 636832662
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants