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

Add op cholesky #1133

Merged
merged 16 commits into from
Jan 30, 2023
Merged

Add op cholesky #1133

merged 16 commits into from
Jan 30, 2023

Conversation

FisherWY
Copy link
Contributor

@FisherWY FisherWY commented Jan 3, 2023

#1115

Add op cholesky

@FisherWY
Copy link
Contributor Author

Cholesky算子:

  • GPU算子:C++侧,Python侧测试均通过
  • CPU算子:C++侧测试通过,Python侧出错,错误日志如下
I0120 08:53:47.877772 40414 graph.cc:38] operator [cholesky] has [1] inputs, and [1] outputs
I0120 08:53:47.878170 40414 pass.cc:26] Run Pass -> MatmulToCublasCustomCallPass
I0120 08:53:47.878217 40414 pass.cc:26] Run Pass -> GaussianRandomToCustomCallPass
I0120 08:53:47.878224 40414 pass.cc:26] Run Pass -> UniformRandomToCustomCallPass
I0120 08:53:47.878230 40414 pass.cc:26] Run Pass -> CholeskyToCustomCallPass
I0120 08:53:47.878237 40414 pass.cc:26] Run Pass -> ConvToCudnnCustomCallPass
I0120 08:53:47.878242 40414 pass.cc:26] Run Pass -> OpFusionPass
I0120 08:53:47.878247 40414 pass.cc:26] Run Pass -> FusionMergePass
I0120 08:53:47.878260 40414 custom_call_pass.cc:170] MatmulToCublasCustomCallPass...!
I0120 08:53:47.878297 40414 custom_call_pass.cc:172] MatmulToCublasCustomCallPass Finish...!
I0120 08:53:47.878304 40414 custom_call_pass.cc:182] GaussianRandomToCustomCall...!
I0120 08:53:47.878314 40414 custom_call_pass.cc:184] GaussianRandomToCustomCall Finish...!
I0120 08:53:47.878319 40414 custom_call_pass.cc:188] UniformRandomToCustomCall...!
I0120 08:53:47.878330 40414 custom_call_pass.cc:190] UniformRandomToCustomCall Finish...!
I0120 08:53:47.878335 40414 custom_call_pass.cc:194] CholeskyToCustomCallPass...!
I0120 08:53:47.878443 40414 custom_call_pass.cc:196] CholeskyToCustomCallPass Finish...!
I0120 08:53:47.878450 40414 custom_call_pass.cc:176] ConvToCudnnCustomCallPass...!
I0120 08:53:47.878463 40414 custom_call_pass.cc:178] ConvToCudnnCustomCallPass Finish...!
I0120 08:53:47.878471 40414 op_fusion_pass.cc:433] OpFusionPass...!
I0120 08:53:47.878928 40414 op_fusion_pass.cc:439] Group Id : cholesky_0
I0120 08:53:47.878943 40414 op_fusion_pass.cc:447] OpFusionPass Finish...!
I0120 08:53:47.878986 40414 fusion_merge_pass.cc:929] Before FusionMergePass:
Group 0 {
  {var_0} = custom_call{x, id=cholesky_0, custom_call=cinn_call_cholesky_host, upper=false, }
}
I0120 08:53:47.879040 40414 fusion_merge_pass.cc:931] Don't do Fusoin Merge Pass...!
I0120 08:53:47.879091 40414 scope.h:65] Scope insert Var [x]
I0120 08:53:47.879163 40414 graph_compiler.cc:1375] Tensor [x] resize to 2,3,3
I0120 08:53:47.879196 40414 scope.h:65] Scope insert Var [var_0]
I0120 08:53:47.879230 40414 graph_compiler.cc:1375] Tensor [var_0] resize to 2,3,3
I0120 08:53:47.879366 40414 graph_compiler.cc:753] Begin GraphCompiler::Build
I0120 08:53:47.879400 40414 graph_compiler.cc:786] group_id is : cholesky_0, and its number is : 1
I0120 08:53:47.879420 40414 op_lowering.cc:107] Lowering Group : cholesky_0 , Op Pattern : 8
I0120 08:53:47.879427 40414 op_lowering.cc:1241] LowerNonFusibleOp Group : cholesky_0
I0120 08:53:47.879446 40414 op_lowering.cc:1248] GetOpFunc of op cholesky_0
I0120 08:53:47.879808 40414 op_lowering.cc:1292] cinn_inputs.push_back var_0
I0120 08:53:47.880364 40414 lowered_func.cc:197] Function used 0 buffers
I0120 08:53:47.880548 40414 custom_call.cc:105] function fn_cholesky_0 (kernel_args, kernel_args_num)
cinn_call_cholesky_host(kernel_args, kernel_args_num, 2, 3, 0)
I0120 08:53:47.880700 40414 graph_compiler.cc:790] function fn_cholesky_0 (kernel_args, kernel_args_num)
cinn_call_cholesky_host(kernel_args, kernel_args_num, 2, 3, 0)
I0120 08:53:47.880733 40414 graph.cc:119] Group 0 {
  {var_0} = custom_call{x, id=cholesky_0, custom_call=cinn_call_cholesky_host, upper=false, }
}
I0120 08:53:47.880771 40414 execution_engine.cc:111] ===================== Create CINN ExecutionEngine begin ====================
I0120 08:53:47.880777 40414 execution_engine.cc:112] initialize llvm config
I0120 08:53:47.880781 40414 execution_engine.cc:113] llvm version: 12.0.0git
I0120 08:53:47.880787 40414 execution_engine.cc:114] llvm default target triple: x86_64-unknown-linux-gnu
I0120 08:53:47.882594 40414 execution_engine.cc:140] create jit execution engine
I0120 08:53:47.883177 40414 execution_engine.cc:124] create llvm compile layer
I0120 08:53:47.883186 40414 execution_engine.cc:125] Target Name: x86-64
I0120 08:53:47.883198 40414 execution_engine.cc:126] Target CPU: skylake-avx512
I0120 08:53:47.883602 40414 execution_engine.cc:148] register runtime call symbols
I0120 08:53:47.885574 40414 execution_engine.cc:152] ===================== Create CINN ExecutionEngine end ====================
I0120 08:53:47.885984 40414 graph_compiler.cc:830] End of m_builder_.Build()
I0120 08:53:47.886126 40414 graph_compiler.cc:835] [X86] C Code is:
#include <cinn_runtime.h>
#include <stdio.h>

void fn_cholesky_0(void* _args, int32_t num_args)
{
  void* kernel_args = cinn_pod_value_to_void_p(&(((cinn_pod_value_t*)(_args))[0]));
  int32_t kernel_args_num = cinn_pod_value_to_int32(&(((cinn_pod_value_t*)(_args))[1]));
  cinn_call_cholesky_host(kernel_args, kernel_args_num, 2, 3, 0);
}

I0120 08:53:47.895321 40414 execution_engine.cc:163] ir_emitter->Compile(module) Begin
I0120 08:53:47.895362 40414 codegen_llvm.cc:699] JIT Linking function [fn_cholesky_0]
I0120 08:53:47.895783 40414 extern_func_emitter_builtin.cc:79] function type cinn_call_cholesky_host: declare void @cinn_call_cholesky_host(i8*, i32, i32, i32, i1)
python: /root/github.com/hp03/CINN/THIRDS/llvm-project/llvm/lib/IR/Instructions.cpp:455: void llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, const llvm::Twine&): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"' failed.


--------------------------------------
C++ Traceback (most recent call last):
--------------------------------------
0   cinn::hlir::framework::GraphCompiler::Build(std::string const&)
1   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*)
2   cinn::backends::Compiler::Build(cinn::ir::Module const&, std::string const&)
3   cinn::backends::Compiler::CompileX86Module(cinn::ir::Module const&)
4   void cinn::backends::ExecutionEngine::Link<cinn::backends::CodeGenX86>(cinn::ir::Module const&)
5   cinn::backends::CodeGenLLVM::Compile(cinn::ir::Module const&)
6   cinn::backends::CodeGenLLVM::Visit(cinn::ir::_Module_ const*)
7   cinn::ir::IRVisitorBase<llvm::Value*>::Visit(cinn::ir::Expr const*)
8   cinn::backends::CodeGenLLVM::Visit(cinn::ir::_LoweredFunc_ const*)
9   cinn::ir::IRVisitorBase<llvm::Value*>::Visit(cinn::ir::Expr const*)
10  cinn::backends::CodeGenLLVM::Visit(cinn::ir::Block const*)
11  cinn::ir::IRVisitorBase<llvm::Value*>::Visit(cinn::ir::Expr const*)
12  cinn::backends::CodeGenLLVM::Visit(cinn::ir::Call const*)
13  cinn::backends::ExternFunctionEmitter::Emit(cinn::ir::Call const*, bool)
14  cinn::backends::ExternFunctionLLVMEmitter::EmitImpl(cinn::ir::Call const*)
15  llvm::IRBuilderBase::CreateCall(llvm::FunctionCallee, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::MDNode*)
16  llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&)

----------------------
Error Message Summary:
----------------------
FatalError: `Process abort signal` is detected by the operating system.
  [TimeInfo: *** Aborted at 1674204827 (unix time) try "date -d @1674204827" if you are using GNU date ***]
  [SignalInfo: *** SIGABRT (@0x9dde) received by PID 40414 (TID 0x7f3d0aed4740) from PID 40414 ***]

Aborted (core dumped)
λ 29590e341c28 /home/wengyu02/work/CINN 

如何复现:编辑python/tests/ops/test_cholesky_op.py,将self.target切换至DefaultHostTarget(),运行测试命令GLOG_v=6 python python/tests/ops/test_cholesky_op.py,报core dump

@FisherWY FisherWY marked this pull request as ready for review January 20, 2023 09:06
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

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.

3 participants