@@ -1690,23 +1690,26 @@ class Handler : public Ffi {
16901690 if (XLA_FFI_PREDICT_FALSE (call_frame->args .size < kNumArgs )) {
16911691 return InvalidArgument (
16921692 call_frame->api ,
1693- StrCat (" Wrong number of arguments: expected at least " ,
1693+ StrCat (" [" , call_frame->stage , " ] " ,
1694+ " Wrong number of arguments: expected at least " ,
16941695 kNumArgs - kNumOptionalArgs - 1 , " but got " ,
16951696 call_frame->args .size ));
16961697 }
16971698 } else if constexpr (internal::HasOptionalArgTag<Ts...>::value) {
16981699 if (XLA_FFI_PREDICT_FALSE (call_frame->args .size < kNumArgs )) {
16991700 return InvalidArgument (
17001701 call_frame->api ,
1701- StrCat (" Wrong number of arguments: expected at least " ,
1702+ StrCat (" [" , call_frame->stage , " ] " ,
1703+ " Wrong number of arguments: expected at least " ,
17021704 kNumArgs - kNumOptionalArgs , " but got " ,
17031705 call_frame->args .size ));
17041706 }
17051707 } else {
17061708 if (XLA_FFI_PREDICT_FALSE (call_frame->args .size != kNumArgs )) {
17071709 return InvalidArgument (
17081710 call_frame->api ,
1709- StrCat (" Wrong number of arguments: expected " , kNumArgs ,
1711+ StrCat (" [" , call_frame->stage , " ] " ,
1712+ " Wrong number of arguments: expected " , kNumArgs ,
17101713 " but got " , call_frame->args .size ));
17111714 }
17121715 }
@@ -1717,23 +1720,26 @@ class Handler : public Ffi {
17171720 if (XLA_FFI_PREDICT_FALSE (call_frame->rets .size < kNumRets )) {
17181721 return InvalidArgument (
17191722 call_frame->api ,
1720- StrCat (" Wrong number of results: expected at least " ,
1723+ StrCat (" [" , call_frame->stage , " ] " ,
1724+ " Wrong number of results: expected at least " ,
17211725 kNumRets - kNumOptionalRets - 1 , " but got " ,
17221726 call_frame->rets .size ));
17231727 }
17241728 } else if constexpr (internal::HasOptionalRetTag<Ts...>::value) {
17251729 if (XLA_FFI_PREDICT_FALSE (call_frame->rets .size < kNumRets )) {
17261730 return InvalidArgument (
17271731 call_frame->api ,
1728- StrCat (" Wrong number of results: expected at least " ,
1732+ StrCat (" [" , call_frame->stage , " ] " ,
1733+ " Wrong number of results: expected at least " ,
17291734 kNumRets - kNumOptionalRets , " but got " ,
17301735 call_frame->rets .size ));
17311736 }
17321737 } else {
17331738 if (XLA_FFI_PREDICT_FALSE (call_frame->rets .size != kNumRets )) {
17341739 return InvalidArgument (
17351740 call_frame->api ,
1736- StrCat (" Wrong number of results: expected " , kNumRets , " but got " ,
1741+ StrCat (" [" , call_frame->stage , " ] " ,
1742+ " Wrong number of results: expected " , kNumRets , " but got " ,
17371743 call_frame->rets .size ));
17381744 }
17391745 }
@@ -1746,7 +1752,8 @@ class Handler : public Ffi {
17461752 if (XLA_FFI_PREDICT_FALSE (kNumDictAttrs == 0 &&
17471753 call_frame->attrs .size != kNumAttrs )) {
17481754 std::stringstream msg;
1749- msg << " Wrong number of attributes: expected " << kNumAttrs << " but got "
1755+ msg << " [" << call_frame->stage << " ] "
1756+ << " Wrong number of attributes: expected " << kNumAttrs << " but got "
17501757 << call_frame->attrs .size ;
17511758 if (call_frame->attrs .size > 0 ) {
17521759 msg << " with name(s): " ;
0 commit comments