@@ -67,12 +67,6 @@ static llvm::cl::opt<bool> TFWarnScalarTransfer(
67
67
" Emit warnings for sends/receives that transfer values that are "
68
68
" known to be scalar." ));
69
69
70
- // TODO: Remove this short-term flag once we migrate over all unit tests.
71
- static llvm::cl::opt<bool > TFSendRecvOpaqueHandle (
72
- " tf-send-recv-opaque-handle" , llvm::cl::init(true ),
73
- llvm::cl::desc(" When true, variant and resource handles can be sent via "
74
- " eager API as tensor handles." ));
75
-
76
70
template <typename ... T, typename ... U>
77
71
static InFlightDiagnostic diagnose (ASTContext &Context, SourceLoc loc,
78
72
Diag<T...> diag, U &&... args) {
@@ -789,7 +783,6 @@ class TFFunctionPartition {
789
783
void diagnoseUsesFromHost (SILValue value, SILLocation loc);
790
784
void diagnoseCopyToHost (SILValue value, SILInstruction *user,
791
785
SILLocation loc);
792
- void diagnoseOpaqueHandleCopy (SILValue value, SILInstruction *user);
793
786
794
787
private:
795
788
// Marking.
@@ -932,13 +925,6 @@ void TFFunctionPartition::diagnoseCopyToAccelerator(
932
925
// Try to determine a good source location to report.
933
926
auto loc = getUserSourceLocation (value);
934
927
935
- // Opaque handles can never be sent or passed as tensor program arguments.
936
- // Type checking must have rejected host functions that are either a)
937
- // public with private ABI or b) marked @inline(never).
938
- assert (TFSendRecvOpaqueHandle ||
939
- (!isOpaqueHandle (value->getType ()) &&
940
- " Opaque handles should never have been on the host" ));
941
-
942
928
// Try to make a useful description of the value being copied to help
943
929
// disambiguate.
944
930
std::string description = " value" ;
@@ -1040,12 +1026,6 @@ void TFFunctionPartition::diagnoseUsesFromHost(SILValue value,
1040
1026
if (isUserIgnoredByPartitioning (user))
1041
1027
continue ;
1042
1028
1043
- // If the value is a non-copyable opaque handle, emit an error.
1044
- if (!TFSendRecvOpaqueHandle && isOpaqueHandle (value->getType ())) {
1045
- diagnoseOpaqueHandleCopy (value, user);
1046
- continue ;
1047
- }
1048
-
1049
1029
// If we are running this in the context of an expression run in the REPL or
1050
1030
// playgrounds, or script mode, then we should never emit a warning: we know
1051
1031
// we're going to be implicitly copying things in as warnings all the time.
@@ -1105,20 +1085,6 @@ void TFFunctionPartition::diagnoseCopyToHost(SILValue value,
1105
1085
}
1106
1086
}
1107
1087
1108
- // / Emit an error for invalid send/receive of opaque handles.
1109
- void TFFunctionPartition::diagnoseOpaqueHandleCopy (SILValue value,
1110
- SILInstruction *user) {
1111
- assert (!TFSendRecvOpaqueHandle);
1112
- assert (isOpaqueHandle (value->getType ()) &&
1113
- " Shouldn't emit an error for opaque handle copy when the value is not "
1114
- " an opaque handle" );
1115
- auto &ctx = value->getFunction ()->getASTContext ();
1116
- diagnose (ctx, getUserSourceLocation (value).getSourceLoc (),
1117
- diag::tfop_value_no_send_receive);
1118
- diagnose (ctx, getUserSourceLocation (user).getSourceLoc (),
1119
- diag::tf_value_used_here);
1120
- }
1121
-
1122
1088
// / Some instruction in the specified block needs to be split out to the
1123
1089
// / accelerator, so we mark it (and its control dependencies) as to-be-moved
1124
1090
// / over.
@@ -3718,19 +3684,6 @@ void TFFunctionPartition::balanceRetainReleaseCount(SILValue oldResult,
3718
3684
3719
3685
void TFFunctionPartition::insertReplacementGraphOp (
3720
3686
ArrayRef<SILValue> resultValues) {
3721
- // Sanity check that all result values are tensor handles. Note SIL
3722
- // accelerator functions under the "tensorflow" convention can also return
3723
- // variant and resource tensors (in addition to tensor handles), but such
3724
- // functions will not generate all host-side code, and thus this method will
3725
- // not be called.
3726
- assert (TFSendRecvOpaqueHandle ||
3727
- llvm::all_of (resultValues,
3728
- [](SILValue resultValue) {
3729
- return isTensorHandle (resultValue->getType ());
3730
- }) &&
3731
- " Cannot return a non-TensorHandle value to host in the TF program "
3732
- " -- should this function use tensorflow convention?" );
3733
-
3734
3687
auto &ctx = hostFn.getASTContext ();
3735
3688
auto loc = hostFn.getLocation ();
3736
3689
@@ -3775,17 +3728,6 @@ void TFFunctionPartition::insertReplacementGraphOp(
3775
3728
3776
3729
void TFFunctionPartition::insertTensorComputationStartEndTerminate (
3777
3730
ArrayRef<SILValue> resultValues) {
3778
- // Sanity check that all result values are tensor handles. Note SIL
3779
- // accelerator functions under the "tensorflow" convention can also return
3780
- // variant and resource tensors (in addition to tensor handles), but such
3781
- // functions will not generate all host-side code, and thus this method will
3782
- // not be called.
3783
- for (auto resultValue : resultValues) {
3784
- assert (TFSendRecvOpaqueHandle || isTensorHandle (resultValue->getType ()) &&
3785
- " Cannot return a non-TensorHandle value to host in the TF program "
3786
- " -- should this function use tensorflow convention?" );
3787
- }
3788
-
3789
3731
auto &ctx = hostFn.getASTContext ();
3790
3732
auto loc = hostFn.getLocation ();
3791
3733
@@ -3925,8 +3867,7 @@ void TFFunctionPartition::insertTensorComputationStartEndTerminate(
3925
3867
// closed over. If it is a TensorHandle<T>, load the CTensorHandle out of
3926
3868
// it. If it is a scalar, then we need to box the scalar in a
3927
3869
// CTensorHandle.
3928
- if ((TFSendRecvOpaqueHandle &&
3929
- isTensorFlowValue (tensorValue->getType ().getASTType ())) ||
3870
+ if (isTensorFlowValue (tensorValue->getType ().getASTType ()) ||
3930
3871
isTensorHandle (tensorValue->getType ().getASTType ())) {
3931
3872
// Upcast to _AnyTensorHandle.
3932
3873
tensorValue = B.createUpcast (loc, tensorValue, anyTensorHandleSILTy);
@@ -4209,15 +4150,6 @@ bool TFFunctionPartition::partition(bool isTest) {
4209
4150
continue ;
4210
4151
}
4211
4152
4212
- // If it's an opaque handle such as VariantHandle or ResourceHandle,
4213
- // it cannot be a result except when it's being returned in an
4214
- // accelerator-only function.
4215
- if (!TFSendRecvOpaqueHandle && isOpaqueHandle (result->getType ()) &&
4216
- !(isAcceleratorOnly (hostFn) && isReturning (user))) {
4217
- diagnoseOpaqueHandleCopy (result, user);
4218
- return true ;
4219
- }
4220
-
4221
4153
// Remember if the instruction has any use. If not, then it never
4222
4154
// needs to be sent or returned.
4223
4155
hasAnyUse = true ;
0 commit comments