tensorflow/compiler/mlir/tensorflow/transforms/tpu_sharding_identification_pass.cc
// Verify sharding for all arguments and return values.
Verify sharding for all arguments and return values.
Verify sharding for all arguments and return values .
LogicalResult VerifyShardings(
    mlir::FuncOp func,
    const llvm::SmallVectorImpl<llvm::StringRef>& sharding_for_args,
    const llvm::SmallVectorImpl<llvm::StringRef>& sharding_for_rets) {
  Block& function_block = func.front();
  for (auto sharding_and_arg :
       llvm::zip(sharding_for_args, function_block.getArguments())) {
    StringRef sharding = std::get<0>(sharding_and_arg);
    BlockArgument arg = std::get<1>(sharding_and_arg);
    if (failed(VerifySharding(arg.getType(), sharding))) return failure();
  }
  Operation* terminator = function_block.getTerminator();
  for (auto sharding_and_retval :
       llvm::zip(sharding_for_rets, terminator->getOpOperands())) {
    StringRef sharding = std::get<0>(sharding_and_retval);
    OpOperand& retval = std::get<1>(sharding_and_retval);
    if (failed(VerifySharding(retval.get().getType(), sharding)))
      return failure();
  }
  return success();
}
LogicalResult VerifyShardings ( mlir :: FuncOp func , const llvm :: SmallVectorImpl < llvm :: StringRef > & sharding_for_args , const llvm :: SmallVectorImpl < llvm :: StringRef > & sharding_for_rets ) { Block & function_block = func . front ( ) ; for ( auto sharding_and_arg : llvm :: zip ( sharding_for_args , function_block . getArguments ( ) ) ) { StringRef sharding = std :: get < 0 > ( sharding_and_arg ) ; BlockArgument arg = std :: get < 1 > ( sharding_and_arg ) ; if ( failed ( VerifySharding ( arg . getType ( ) , sharding ) ) ) return failure ( ) ; } Operation * terminator = function_block . getTerminator ( ) ; for ( auto sharding_and_retval : llvm :: zip ( sharding_for_rets , terminator -> getOpOperands ( ) ) ) { StringRef sharding = std :: get < 0 > ( sharding_and_retval ) ; OpOperand & retval = std :: get < 1 > ( sharding_and_retval ) ; if ( failed ( VerifySharding ( retval . get ( ) . getType ( ) , sharding ) ) ) return failure ( ) ; } return success ( ) ; }
Verify sharding for all arguments and return values.
Verify sharding for all arguments and return values .