Implement IfOp verification

This would also make the CallOp and ExtractElementOp invocations from eliminateIfOp function always valid and removes the need for error handling.

Also, verify TensorFlowOp trait.

PiperOrigin-RevId: 221737192
This commit is contained in:
Smit Hinsu 2018-11-15 20:37:54 -08:00 committed by jpienaar
parent 8b6bc09f48
commit 2213afa784
1 changed files with 8 additions and 2 deletions

View File

@ -408,10 +408,16 @@ public:
TensorType() = default;
/* implicit */ TensorType(Type::ImplType *ptr);
/// Return true if the specified element type is a TensorFlow type that is ok
/// in a tensor.
static bool isValidTFElementType(Type type) {
return type.isa<FloatType>() || type.isa<IntegerType>() ||
type.isa<OtherType>();
}
/// Return true if the specified element type is ok in a tensor.
static bool isValidElementType(Type type) {
return type.isa<FloatType>() || type.isa<VectorType>() ||
type.isa<IntegerType>() || type.isa<OtherType>() ||
return isValidTFElementType(type) || type.isa<VectorType>() ||
type.isa<IndexType>();
}