Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Add Op UnitTest for divide #1383

Merged
merged 9 commits into from
May 6, 2023

Conversation

enkilee
Copy link
Contributor

@enkilee enkilee commented May 1, 2023

描述

为 divide 算子增加单测文件

算子类型

  • ElementWise:输入张量索引和输出张量索引之间存在一对一的对应关系
  • Broadcast:输入张量索引和输出张量索引之间存在一对多的对应关系
  • Injective:单射算子,可以将一个输出 axis 映射到一个输入 axis
  • Reduction:输入张量索引和输出张量索引之间存在多对一的对应关系
  • OutFusible:复杂算子,仍然可以将一对一的算子融合到其输出中。
  • kNonFusible:无法融合的算子

OpMapper

Test Cases Checklist

张量维度

  • 1D 张量
  • 2D 张量
  • 3D 张量
  • 4D 张量

special shape
挑选 2D/3D/4D 张量中的一个,测试下面的特殊情况。

  • 其中一个维度为 1
  • 其中一个维度小于 1024
  • 其中一个维度大于 1024
  • 向量的所有维度都是 1

张量数据类型

  • bool
  • int16
  • int32
  • int64
  • float16
  • float32
  • float64

广播

  • 这个算子是否支持广播?
  • 广播的测试样例

算子属性

算子属性的测试用例。

  • 属性:属性类型-可取值

@paddle-bot
Copy link

paddle-bot bot commented May 1, 2023

Thanks for your contribution!

@enkilee
Copy link
Contributor Author

enkilee commented May 4, 2023

2023-05-03 16:19:14 Error: /paddle/paddle/phi/kernels/funcs/elementwise_functor.h:91 Assertion b != 0 failed. InvalidArgumentError: Integer division by zero encountered in (floor) divide. Please check the input value.
2023-05-03 16:19:14 E0000 00:00:00.000000 20316 cuda_module.cc:110] RAW: PTX JIT ERROR LOG:
2023-05-03 16:19:14 .
2023-05-03 16:19:14 F0000 00:00:00.000000 20316 cuda_module.cc:115] RAW: The error CUDA_ERROR_LAUNCH_FAILED occurs while compiling the ptx! And its message is unspecified launch failure.
2023-05-03 16:19:14
2023-05-03 16:19:14
2023-05-03 16:19:14 --------------------------------------
2023-05-03 16:19:14 C++ Traceback (most recent call last):
2023-05-03 16:19:14 --------------------------------------
2023-05-03 16:19:14 0 cinn::hlir::framework::GraphCompiler::Build(cinn::hlir::framework::GraphCompiler::CompileOptions const&, std::unordered_set<std::string, std::hash<std::string >, std::equal_to<std::string >, std::allocator<std::string > >&&, void*)
2023-05-03 16:19:14 1 cinn::hlir::framework::ParallelCompiler::operator()()
2023-05-03 16:19:14 2 cinn::hlir::framework::ParallelCompiler::LaunchTask()
2023-05-03 16:19:14 3 cinn::hlir::framework::RunTask(cinn::hlir::framework::ParallelCompiler::Task*)
2023-05-03 16:19:14 4 cinn::hlir::framework::ParallelCompiler::Task::CodegenAndJit()
2023-05-03 16:19:14 5 cinn::runtime::cuda::CUDAModule::GetFunction(int, std::string const&)
2023-05-03 16:19:14 6 google::RawLog__(int, char const*, int, char const*, ...)
2023-05-03 16:19:14 7 google::LogMessage::SendToSink()
2023-05-03 16:19:14 8 google::InstallFailureFunction(void (*)())
2023-05-03 16:19:14
2023-05-03 16:19:14 ----------------------
2023-05-03 16:19:14 Error Message Summary:
2023-05-03 16:19:14 ----------------------
2023-05-03 16:19:14 FatalError: Process abort signal is detected by the operating system.
2023-05-03 16:19:14 [TimeInfo: *** Aborted at 1683101954 (unix time) try "date -d @1683101954" if you are using GNU date ***]
2023-05-03 16:19:14 [SignalInfo: *** SIGABRT (@0x4f5c) received by PID 20316 (TID 0x7f9084dc7740) from PID 20316 ***]
2023-05-03 16:19:14
2023-05-03 16:19:14 Child aborted

看报错,应该是在paddle那边,这边CINN无法测试int类型。

@thisjiang
Copy link
Collaborator

描述 From #1378

为Reduce类型算子增加新的测试用例

序号 算子名 单测文件
35 divide test_devide_op.py算子类型 divide:输入张量索引和输出张量索引之间存在一对一的对应关系 OpMapper 该算子是否 OpMapper? 如果是,请贴出在 Paddle 中对应的 OpMaker 代码路径。(给出 Github 链接更好) Test Cases Checklist 张量维度 1D 张量 2D 张量 3D 张量 4D 张量 special shape 挑选 2D/3D/4D 张量中的一个,测试下面的特殊情况。
其中一个维度为 1 其中一个维度小于 1024 其中一个维度大于 1024 向量的所有维度都是 1 张量数据类型 float32 float64 广播 这个算子是否支持广播? 广播的测试样例 算子属性 算子属性的测试用例。

属性:属性类型-可取值 op_type axis keepdim 使用 OpTestHelper 测试上述属性的笛卡尔积组合

PR描述请参考:#1379 ,建议拷贝过来并按照对应情况进行自检查(注意选项并☑️)

@FisherWY
Copy link
Contributor

FisherWY commented May 4, 2023

2023-05-03 16:19:14 Error: /paddle/paddle/phi/kernels/funcs/elementwise_functor.h:91 Assertion b != 0 failed. InvalidArgumentError: Integer division by zero encountered in (floor) divide. Please check the input value. 2023-05-03 16:19:14 E0000 00:00:00.000000 20316 cuda_module.cc:110] RAW: PTX JIT ERROR LOG: 2023-05-03 16:19:14 . 2023-05-03 16:19:14 F0000 00:00:00.000000 20316 cuda_module.cc:115] RAW: The error CUDA_ERROR_LAUNCH_FAILED occurs while compiling the ptx! And its message is unspecified launch failure. 2023-05-03 16:19:14 2023-05-03 16:19:14 2023-05-03 16:19:14 -------------------------------------- 2023-05-03 16:19:14 C++ Traceback (most recent call last): 2023-05-03 16:19:14 -------------------------------------- 2023-05-03 16:19:14 0 cinn::hlir::framework::GraphCompiler::Build(cinn::hlir::framework::GraphCompiler::CompileOptions const&, std::unordered_set<std::string, std::hash<std::string >, std::equal_to<std::string >, std::allocator<std::string > >&&, void*) 2023-05-03 16:19:14 1 cinn::hlir::framework::ParallelCompiler::operator()() 2023-05-03 16:19:14 2 cinn::hlir::framework::ParallelCompiler::LaunchTask() 2023-05-03 16:19:14 3 cinn::hlir::framework::RunTask(cinn::hlir::framework::ParallelCompiler::Task*) 2023-05-03 16:19:14 4 cinn::hlir::framework::ParallelCompiler::Task::CodegenAndJit() 2023-05-03 16:19:14 5 cinn::runtime::cuda::CUDAModule::GetFunction(int, std::string const&) 2023-05-03 16:19:14 6 google::RawLog__(int, char const*, int, char const*, ...) 2023-05-03 16:19:14 7 google::LogMessage::SendToSink() 2023-05-03 16:19:14 8 google::InstallFailureFunction(void (*)()) 2023-05-03 16:19:14 2023-05-03 16:19:14 ---------------------- 2023-05-03 16:19:14 Error Message Summary: 2023-05-03 16:19:14 ---------------------- 2023-05-03 16:19:14 FatalError: Process abort signal is detected by the operating system. 2023-05-03 16:19:14 [TimeInfo: *** Aborted at 1683101954 (unix time) try "date -d @1683101954" if you are using GNU date ***] 2023-05-03 16:19:14 [SignalInfo: *** SIGABRT (@0x4f5c) received by PID 20316 (TID 0x7f9084dc7740) from PID 20316 ***] 2023-05-03 16:19:14 2023-05-03 16:19:14 Child aborted

看报错,应该是在paddle那边,这边CINN无法测试int类型。

InvalidArgumentError: Integer division by zero encountered in (floor) divide.,应该是出现了除数为0的情况,可以调整下测试数据初始化时的数据范围

@enkilee
Copy link
Contributor Author

enkilee commented May 4, 2023

2023-05-03 16:19:14 Error: /paddle/paddle/phi/kernels/funcs/elementwise_functor.h:91 Assertion b != 0 failed. InvalidArgumentError: Integer division by zero encountered in (floor) divide. Please check the input value. 2023-05-03 16:19:14 E0000 00:00:00.000000 20316 cuda_module.cc:110] RAW: PTX JIT ERROR LOG: 2023-05-03 16:19:14 . 2023-05-03 16:19:14 F0000 00:00:00.000000 20316 cuda_module.cc:115] RAW: The error CUDA_ERROR_LAUNCH_FAILED occurs while compiling the ptx! And its message is unspecified launch failure. 2023-05-03 16:19:14 2023-05-03 16:19:14 2023-05-03 16:19:14 -------------------------------------- 2023-05-03 16:19:14 C++ Traceback (most recent call last): 2023-05-03 16:19:14 -------------------------------------- 2023-05-03 16:19:14 0 cinn::hlir::framework::GraphCompiler::Build(cinn::hlir::framework::GraphCompiler::CompileOptions const&, std::unordered_set<std::string, std::hash<std::string >, std::equal_to<std::string >, std::allocator<std::string > >&&, void*) 2023-05-03 16:19:14 1 cinn::hlir::framework::ParallelCompiler::operator()() 2023-05-03 16:19:14 2 cinn::hlir::framework::ParallelCompiler::LaunchTask() 2023-05-03 16:19:14 3 cinn::hlir::framework::RunTask(cinn::hlir::framework::ParallelCompiler::Task*) 2023-05-03 16:19:14 4 cinn::hlir::framework::ParallelCompiler::Task::CodegenAndJit() 2023-05-03 16:19:14 5 cinn::runtime::cuda::CUDAModule::GetFunction(int, std::string const&) 2023-05-03 16:19:14 6 google::RawLog__(int, char const*, int, char const*, ...) 2023-05-03 16:19:14 7 google::LogMessage::SendToSink() 2023-05-03 16:19:14 8 google::InstallFailureFunction(void (*)()) 2023-05-03 16:19:14 2023-05-03 16:19:14 ---------------------- 2023-05-03 16:19:14 Error Message Summary: 2023-05-03 16:19:14 ---------------------- 2023-05-03 16:19:14 FatalError: Process abort signal is detected by the operating system. 2023-05-03 16:19:14 [TimeInfo: *** Aborted at 1683101954 (unix time) try "date -d @1683101954" if you are using GNU date ***] 2023-05-03 16:19:14 [SignalInfo: *** SIGABRT (@0x4f5c) received by PID 20316 (TID 0x7f9084dc7740) from PID 20316 ***] 2023-05-03 16:19:14 2023-05-03 16:19:14 Child aborted
看报错,应该是在paddle那边,这边CINN无法测试int类型。

InvalidArgumentError: Integer division by zero encountered in (floor) divide.,应该是出现了除数为0的情况,可以调整下测试数据初始化时的数据范围

可否把random函数更新,加个参数,except,就是不纳入数据范围的值?

@FisherWY
Copy link
Contributor

FisherWY commented May 4, 2023

2023-05-03 16:19:14 Error: /paddle/paddle/phi/kernels/funcs/elementwise_functor.h:91 Assertion b != 0 failed. InvalidArgumentError: Integer division by zero encountered in (floor) divide. Please check the input value. 2023-05-03 16:19:14 E0000 00:00:00.000000 20316 cuda_module.cc:110] RAW: PTX JIT ERROR LOG: 2023-05-03 16:19:14 . 2023-05-03 16:19:14 F0000 00:00:00.000000 20316 cuda_module.cc:115] RAW: The error CUDA_ERROR_LAUNCH_FAILED occurs while compiling the ptx! And its message is unspecified launch failure. 2023-05-03 16:19:14 2023-05-03 16:19:14 2023-05-03 16:19:14 -------------------------------------- 2023-05-03 16:19:14 C++ Traceback (most recent call last): 2023-05-03 16:19:14 -------------------------------------- 2023-05-03 16:19:14 0 cinn::hlir::framework::GraphCompiler::Build(cinn::hlir::framework::GraphCompiler::CompileOptions const&, std::unordered_set<std::string, std::hash<std::string >, std::equal_to<std::string >, std::allocator<std::string > >&&, void*) 2023-05-03 16:19:14 1 cinn::hlir::framework::ParallelCompiler::operator()() 2023-05-03 16:19:14 2 cinn::hlir::framework::ParallelCompiler::LaunchTask() 2023-05-03 16:19:14 3 cinn::hlir::framework::RunTask(cinn::hlir::framework::ParallelCompiler::Task*) 2023-05-03 16:19:14 4 cinn::hlir::framework::ParallelCompiler::Task::CodegenAndJit() 2023-05-03 16:19:14 5 cinn::runtime::cuda::CUDAModule::GetFunction(int, std::string const&) 2023-05-03 16:19:14 6 google::RawLog__(int, char const*, int, char const*, ...) 2023-05-03 16:19:14 7 google::LogMessage::SendToSink() 2023-05-03 16:19:14 8 google::InstallFailureFunction(void (*)()) 2023-05-03 16:19:14 2023-05-03 16:19:14 ---------------------- 2023-05-03 16:19:14 Error Message Summary: 2023-05-03 16:19:14 ---------------------- 2023-05-03 16:19:14 FatalError: Process abort signal is detected by the operating system. 2023-05-03 16:19:14 [TimeInfo: *** Aborted at 1683101954 (unix time) try "date -d @1683101954" if you are using GNU date ***] 2023-05-03 16:19:14 [SignalInfo: *** SIGABRT (@0x4f5c) received by PID 20316 (TID 0x7f9084dc7740) from PID 20316 ***] 2023-05-03 16:19:14 2023-05-03 16:19:14 Child aborted
看报错,应该是在paddle那边,这边CINN无法测试int类型。

InvalidArgumentError: Integer division by zero encountered in (floor) divide.,应该是出现了除数为0的情况,可以调整下测试数据初始化时的数据范围

可否把random函数更新,加个参数,except,就是不纳入数据范围的值?

目前self.random直接使用numpy中的随机数接口,额外支持except参数虽然可行,但是并不划算

Copy link
Collaborator

@thisjiang thisjiang left a comment

Choose a reason for hiding this comment

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

LGTM

python/tests/ops/test_divide_op.py Show resolved Hide resolved
@thisjiang thisjiang merged commit 670151d into PaddlePaddle:develop May 6, 2023
jiahy0825 pushed a commit to jiahy0825/CINN that referenced this pull request May 25, 2023
* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants