Add ShapeCastOp to the vector ops dialect.
The shape_cast operation casts between an n-D source vector shape and a k-D result vector shape (the element type remains the same).
Differential D73635
[mlir][VectorOps] Add ShapeCastOp to the vector ops dialect. Authored by andydavis1 on Jan 29 2020, 8:45 AM.
Details Add ShapeCastOp to the vector ops dialect. The shape_cast operation casts between an n-D source vector shape and a k-D result vector shape (the element type remains the same).
Diff Detail
Event TimelineComment Actions Unit tests: fail. 62283 tests passed, 1 failed and 831 were skipped. failed: libc++.std/thread/thread_mutex/thread_mutex_requirements/thread_mutex_requirements_mutex/thread_mutex_recursive/lock.pass.cpp clang-tidy: pass. clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch. Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.
Comment Actions Unit tests: pass. 62322 tests passed, 0 failed and 838 were skipped. clang-tidy: pass. clang-format: pass. Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.
Comment Actions Unit tests: fail. 62357 tests passed, 1 failed and 839 were skipped. failed: libc++.std/containers/sequences/array/array_creation/to_array.fail.cpp clang-tidy: pass. clang-format: pass. Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project. Comment Actions Unit tests: fail. 62357 tests passed, 1 failed and 839 were skipped. failed: libc++.std/containers/sequences/array/array_creation/to_array.fail.cpp clang-tidy: pass. clang-format: pass. Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.
Comment Actions Unit tests: unknown. clang-tidy: pass. clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch. Build artifacts: clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project. Comment Actions Unit tests: unknown. clang-tidy: pass. clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch. Build artifacts: clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project. Comment Actions Unit tests: unknown. clang-tidy: pass. clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch. Build artifacts: clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project. Comment Actions Unit tests: unknown. clang-tidy: pass. clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch. Build artifacts: clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project. Comment Actions Unit tests: unknown. clang-tidy: pass. clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch. Build artifacts: clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project. | ||||||||||||||||||||||||
clang-format: please reformat the code
+def Vector_ShapeCastOp : + Vector_Op<"shape_cast", [NoSideEffect]>, + Arguments<(ins AnyTypeOf<[AnyVector, TupleOf<[AnyVector]>]>:$source)>, + Results<(outs AnyTypeOf<[AnyVector, TupleOf<[AnyVector]>]>:$result)> { + let summary = "shape_cast casts between vector shapes"; + let description = [{ + The shape_cast operation casts between an n-D source vector shape and + a k-D result vector shape (the element type remains the same). + + If reducing rank (n > k), result dimension sizes must be a product + of contiguous source dimension sizes. + If expanding rank (n < k), source dimensions must factor into a + contiguous sequence of destination dimension sizes. + Each source dim is expanded (or contiguous sequence of source dims combined) + in source dimension list order (i.e. 0 <= i < n), to produce a contiguous + sequence of result dims (or a single result dim), in result dimension list + order (i.e. 0 <= j < k). The product of all source dimension sizes and all + result dimension sizes must match. + + If the source/result types are a tuple of vectors, the casting operation + described above is applied to each source/result tuple element pair. + + It is currently assumed that this operation does not require moving data, + and that it will be canonicalized away before lowering vector operations. + + Examples: + + ```mlir + // Example casting to a lower vector rank. + %1 = vector.shape_cast %0 : vector<5x1x4x3xf32> to vector<20x3xf32> + + // Example casting to a higher vector rank. + %3 = vector.shape_cast %2 : vector<10x12x8xf32> to vector<5x2x3x4x8xf32> + + // Example casting a tuple of vectors of same rank, where tuple elements + // may have different shapes. + %5 = vector.shape_cast %4 : tuple<vector<3x4x2xf32>, vector<3x3x2xf32>> to + tuple<vector<12x2xf32>, vector<9x2xf32>> ++ }];
+ let assemblyFormat = "$source attr-dict : type($source) to type($result)";
+}
+