Skip to content

Conversation

@pbelevich
Copy link
Contributor

@pbelevich pbelevich commented Oct 30, 2019

Stack from ghstack:

Differential Revision: D18233037

[ghstack-poisoned]
@pbelevich pbelevich requested a review from zou3519 November 18, 2019 21:01
Copy link
Contributor

@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

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

Some questions

inf
}, torch::TensorOptions().dtype(S).device(device));
ASSERT_TRUE(torch::allclose(
torch::isfinite(x).toType(torch::kInt),
Copy link
Contributor

Choose a reason for hiding this comment

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

We're taking a BoolTensor, converting to IntTensor, and then comparing it to another IntTensor that was converted from a BoolTensor. Is there a way to just directly compare the BoolTensors ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

torch::allclose does not support torch::kBool

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you toss this information into an in-line comment in the testing code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@facebook-github-bot
Copy link
Contributor

@pbelevich merged this pull request in 8df5e10.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Nov 19, 2019
Summary: Pull Request resolved: pytorch/pytorch#28918

Test Plan: Imported from OSS

Differential Revision: D18233037

Pulled By: pbelevich

fbshipit-source-id: c76b9467bbc1fbb2c9bf49855895c98438b36c12
}

TEST_F(FunctionalTest, isfinite) {
for (const auto device : {at::Device("cpu"), at::Device("cuda")}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

CPU-only tests seem to fail with

Nov 19 00:33:35 [ RUN      ] FunctionalTest.isfinite
Nov 19 00:33:35 unknown file: Failure
Nov 19 00:33:35 C++ exception with description "Cannot initialize CUDA without ATen_cuda library. PyTorch splits its backend into two shared libraries: a CPU library and a CUDA library; this error has occurred because you are trying to use some CUDA functionality, but the CUDA library has not been loaded by the dynamic linker for some reason.  The CUDA library MUST be loaded, EVEN IF you don't directly use any symbols from the CUDA library! One common culprit is a lack of -Wl,--no-as-needed in your link arguments; many dynamic linkers will delete dynamic library dependencies if you don't depend on any of their symbols.  You can check if this has occurred by using ldd on your binary to see if there is a dependency on *_cuda.so library. (initCUDA at /var/lib/jenkins/workspace/aten/src/ATen/detail/CUDAHooksInterface.h:63)
Nov 19 00:33:35 frame #0: <unknown function> + 0xcfa83 (0x7fabe4f6ca83 in /var/lib/jenkins/workspace/build/lib/libc10.so)
Nov 19 00:33:35 frame #1: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0x1c8 (0x7fabe4f6b118 in /var/lib/jenkins/workspace/build/lib/libc10.so)
Nov 19 00:33:35 frame #2: <unknown function> + 0xb1c616f (0x7fabf03e916f in /var/lib/jenkins/workspace/build/lib/libtorch.so)
Nov 19 00:33:35 frame #3: <unknown function> + 0xb12b6a2 (0x7fabf034e6a2 in /var/lib/jenkins/workspace/build/lib/libtorch.so)
Nov 19 00:33:35 frame #4: <unknown function> + 0xea99 (0x7fabdd57ba99 in /lib/x86_64-linux-gnu/libpthread.so.0)
Nov 19 00:33:35 frame #5: <unknown function> + 0xb12b363 (0x7fabf034e363 in /var/lib/jenkins/workspace/build/lib/libtorch.so)
Nov 19 00:33:35 frame #6: <unknown function> + 0xea99 (0x7fabdd57ba99 in /lib/x86_64-linux-gnu/libpthread.so.0)
Nov 19 00:33:35 frame #7: <unknown function> + 0xbcffbc (0x56250335cfbc in build/bin/test_api)
Nov 19 00:33:35 frame #8: <unknown function> + 0xbea6f1 (0x5625033776f1 in build/bin/test_api)
Nov 19 00:33:35 frame #9: <unknown function> + 0xbb270e (0x56250333f70e in build/bin/test_api)
Nov 19 00:33:35 frame #10: void test_isfinite<(c10::ScalarType)0, unsigned char>(c10::Device const&) + 0x771 (0x5625037cfe31 in build/bin/test_api)
Nov 19 00:33:35 frame #11: FunctionalTest_isfinite_Test::TestBody() + 0x2f5 (0x5625037b2195 in build/bin/test_api)
Nov 19 00:33:35 frame #12: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) + 0x2bb (0x5625040aafdb in build/bin/test_api)
Nov 19 00:33:35 frame #13: testing::Test::Run() + 0x25b (0x562504059acb in build/bin/test_api)
Nov 19 00:33:35 frame #14: testing::TestInfo::Run() + 0x543 (0x56250405c413 in build/bin/test_api)
Nov 19 00:33:35 frame #15: testing::TestCase::Run() + 0x5fb (0x56250405e33b in build/bin/test_api)
Nov 19 00:33:35 frame #16: testing::internal::UnitTestImpl::RunAllTests() + 0x13d5 (0x562504080745 in build/bin/test_api)
Nov 19 00:33:35 frame #17: bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) + 0x2b2 (0x5625040b0712 in build/bin/test_api)
Nov 19 00:33:35 frame #18: testing::UnitTest::Run() + 0x29a (0x56250407f1ea in build/bin/test_api)
Nov 19 00:33:35 frame #19: main + 0x458 (0x5625032bc328 in build/bin/test_api)
Nov 19 00:33:35 frame #20: __libc_start_main + 0xf0 (0x7fabdc9ea830 in /lib/x86_64-linux-gnu/libc.so.6)
Nov 19 00:33:35 frame #21: _start + 0x29 (0x5625032bbcd9 in build/bin/test_api)
Nov 19 00:33:35 " thrown in the test body.
Nov 19 00:33:35 [  FAILED  ] FunctionalTest.isfinite (12 ms)

We might need to split this test into TEST_F(FunctionalTest, isfinite) and TEST_F(FunctionalTest, isfinite_CUDA), and the latter would contain only the CUDA tests.

test_isfinite<torch::kInt8, char>(device);
test_isfinite<torch::kInt16, short>(device);
test_isfinite<torch::kInt32, int>(device);
test_isfinite<torch::kInt64, long>(device);
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect that long represents types of different bit-length on different platforms, and we might want to use the following list instead:

torch::kByte, uint8_t
torch::kChar, int8_t
torch::kShort, int16_t
torch::kInt, int
torch::kLong, int64_t
torch::kFloat, float
torch::kDouble, double

@yf225
Copy link
Contributor

yf225 commented Nov 19, 2019

@pbelevich This PR seems to be breaking master with errors such as:

Nov 18 19:47:30 ../test/cpp/api/functional.cpp:2001:40: error: conversion from 'const long' to 'at::Scalar' is ambiguous
Nov 18 19:47:30     const auto x = torch::full({3, 3}, value, torch::TensorOptions().dtype(S).device(device));
Nov 18 19:47:30                                        ^~~~~

I will have to revert it for now, and I commented about the possible solutions in-line :D

@pbelevich pbelevich reopened this Nov 19, 2019
@pbelevich pbelevich closed this Nov 19, 2019
@facebook-github-bot facebook-github-bot deleted the gh/pbelevich/51/head branch November 23, 2019 15:16
driazati pushed a commit that referenced this pull request Jan 8, 2020
As part of #30786, this moves `isinf` to C++. It's mostly the same as #28918.
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.

6 participants