FTA icon indicating copy to clipboard operation
FTA copied to clipboard

Using multi output model

Open LeeHY-1 opened this issue 1 year ago • 1 comments

Hello, I have a trained model with two branches and two different outputs as well. I tried to change related codes (including configure.conf, cpp_body, fortran_extern_interface, fortran_interface) to adapt the model. After changing, I run build.sh and got the following error message:

Test CPU Start terminate called after throwing an instance of 'c10::Error' what(): Expected Tensor but got Tuple Exception raised from reportToTensorTypeError at ../aten/src/ATen/core/ivalue.cpp:942 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::string) + 0x3e (0x14603338a56e in /g5/lihy/CMA_GFS3.3_integ_cmake/MODEL/SRC_test/physics/FTA-test/libtorch/lib/libc10.so) frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::string const&) + 0x5c (0x146033354f18 in /g5/lihy/CMA_GFS3.3_integ_cmake/MODEL/SRC_test/physics/FTA-test/libtorch/lib/libc10.so) frame #2: c10::IValue::reportToTensorTypeError() const + 0x58 (0x14601ab018c8 in /g5/lihy/CMA_GFS3.3_integ_cmake/MODEL/SRC_test/physics/FTA-test/libtorch/lib/libtorch_cpu.so) frame #3: c10::IValue::toTensor() && + 0x36 (0x146035fb66ae in /g5/lihy/CMA_GFS3.3_integ_cmake/MODEL/SRC_test/physics/FTA-test/src/build/lib/libcall_ts_cpp.so) frame #4: test_model::forward(void*, void*, void*) + 0x468 (0x146035fad2f0 in /g5/lihy/CMA_GFS3.3_integ_cmake/MODEL/SRC_test/physics/FTA-test/src/build/lib/libcall_ts_cpp.so) frame #5: test_model_forward + 0x3d (0x146035facb7e in /g5/lihy/CMA_GFS3.3_integ_cmake/MODEL/SRC_test/physics/FTA-test/src/build/lib/libcall_ts_cpp.so) frame #6: torch_wrapper_mp_test_model_forward_ + 0x40 (0x146036fb6a0f in /g5/lihy/CMA_GFS3.3_integ_cmake/MODEL/SRC_test/physics/FTA-test/src/build/lib/libtorch_wrapper_F.so) frame #7: ./test_cpu() [0x40968f] frame #8: ./test_cpu() [0x409533] frame #9: ./test_cpu() [0x4094e2] frame #10: __libc_start_main + 0xf3 (0x146036672493 in /lib64/libc.so.6) frame #11: ./test_cpu() [0x4093ee]

forrtl: error (76): Abort trap signal Image PC Routine Line Source test_cpu 000000000040A5CB for__signal_handl Unknown Unknown libpthread-2.28.s 0000146036A26B20 Unknown Unknown Unknown libc-2.28.so 000014603668637F gsignal Unknown Unknown libc-2.28.so 0000146036670DB5 abort Unknown Unknown libstdc++.so.6.0. 0000146018CCD09B Unknown Unknown Unknown libstdc++.so.6.0. 0000146018CD353C Unknown Unknown Unknown libstdc++.so.6.0. 0000146018CD3597 Unknown Unknown Unknown libstdc++.so.6.0. 0000146018CD37F8 Unknown Unknown Unknown libc10.so 0000146033354F48 _ZN3c106detail14t Unknown Unknown libtorch_cpu.so 000014601AB018C8 _ZNK3c106IValue23 Unknown Unknown libcall_ts_cpp.so 0000146035FB66AE ZNO3c106IValue8t Unknown Unknown libcall_ts_cpp.so 0000146035FAD2F0 ZN10test_model7f Unknown Unknown libcall_ts_cpp.so 0000146035FACB7E test_model_forwar Unknown Unknown libtorch_wrapper 0000146036FB6A0F torch_wrapper_mp Unknown Unknown test_cpu 000000000040968F Unknown Unknown Unknown test_cpu 0000000000409533 Unknown Unknown Unknown test_cpu 00000000004094E2 Unknown Unknown Unknown libc-2.28.so 0000146036672493 __libc_start_main Unknown Unknown test_cpu 00000000004093EE Unknown Unknown Unknown Aborted (core dumped)

I guess the problem is about the cpp file. This is the changed code,

at::Tensor output1_tensor = module.forward(inputs).toTensor()[0],output2_tensor = module.forward(inputs).toTensor()[1];

is there anything wrong and how to correct it?

LeeHY-1 avatar Aug 29 '24 07:08 LeeHY-1

I guess this is the root cause? terminate called after throwing an instance of 'c10::Error' what(): Expected Tensor but got Tuple

You can check the consistency of the types in your code.

luc99hen avatar Oct 25 '24 02:10 luc99hen