MLIR 23.0.0git
SPIRVTosaOps.cpp
Go to the documentation of this file.
1//===- SPIRVTosaOps.cpp - MLIR SPIR-V Tosa operations ---------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the Tosa operations in the SPIR-V dialect.
10//
11//===----------------------------------------------------------------------===//
14#include "mlir/IR/Matchers.h"
16
17namespace mlir::spirv {
18
19//===----------------------------------------------------------------------===//
20// TOSA Operator Verifiers.
21//===----------------------------------------------------------------------===//
22
23//===----------------------------------------------------------------------===//
24// spirv.TosaArgmaxOp
25//===----------------------------------------------------------------------===//
26
27LogicalResult TosaArgMaxOp::verify() {
28 ShapedType inputTy = getInputType();
29 ShapedType resultTy = getResultType();
30
31 if (inputTy.hasRank() && resultTy.hasRank() &&
32 resultTy.getRank() !=
33 (inputTy.getRank() > 1 ? inputTy.getRank() - 1 : 1)) {
34 return emitOpError(
35 "result rank must be max of 1 and (input rank - 1), got ")
36 << resultTy.getRank();
37 }
38
39 const uint32_t axis = getAxis();
40 if (inputTy.hasRank() && axis >= inputTy.getRank()) {
41 return emitOpError(
42 "specified axis is greater than the rank of input, got axis = ")
43 << axis << " and input rank = " << inputTy.getRank();
44 }
45
46 return success();
47}
48
49} // namespace mlir::spirv
return success()
p<< " : "<< getMemRefType()<< ", "<< getType();}static LogicalResult verifyVectorMemoryOp(Operation *op, MemRefType memrefType, VectorType vectorType) { if(memrefType.getElementType() !=vectorType.getElementType()) return op-> emitOpError("requires memref and vector types of the same elemental type")
Given a list of lists of parsed operands, populates uniqueOperands with unique operands.