[Mlir-commits] [mlir] [mlir][spirv] Add definition for GL Length (PR #144041)
Igor Wodiany
llvmlistbot at llvm.org
Fri Jun 13 07:42:02 PDT 2025
================
@@ -1160,6 +1160,46 @@ def SPIRV_GLFMixOp :
// -----
+def SPIRV_GLLengthOp : SPIRV_GLOp<"Length", 66, [
+ Pure,
+ TypesMatchWith<"result type must match operand element type",
+ "operand", "result",
+ "::mlir::getElementTypeOrSelf($_self)">
+ ]> {
+ let summary = "Return the length of a vector x";
+
+ let description = [{
+ Result is the length of vector x, i.e., sqrt(x[0]**2 + x[1]**2 + ...).
+
+ The operand x must be a scalar or vector whose component type is floating-point.
+
+ Result Type must be a scalar of the same type as the component type of x.
+
+ #### Example:
+
+ ```mlir
+ %2 = spirv.GL.Length %0 : vector<3xf32> -> f32
+ %3 = spirv.GL.Length %1 : f32 -> f32
----------------
IgWod-IMG wrote:
I'm in favour of that. Should I update this PR or do we want it as a separate change? I'm happy with either.
https://github.com/llvm/llvm-project/pull/144041
More information about the Mlir-commits
mailing list