1 /* Copyright 2022 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #include "tensorflow/compiler/xla/service/gpu/gpu_shape_verifier.h" 17 18 namespace xla { 19 Preprocess(HloInstruction * hlo)20Status GpuShapeVerifier::Preprocess(HloInstruction* hlo) { 21 TF_RETURN_IF_ERROR(ShapeUtil::ForEachSubshapeWithStatus( 22 hlo->shape(), [&](const Shape& shape, const ShapeIndex&) { 23 if (shape.has_layout()) { 24 if (LayoutUtil::IsSparseArray(shape)) { 25 return InvalidArgument( 26 "The XLA GPU backend does not support sparse shapes: %s", 27 hlo->ToString()); 28 } 29 } 30 return OkStatus(); 31 })); 32 33 return ShapeVerifier::Preprocess(hlo); 34 } 35 36 } // namespace xla 37