From f406df1950e981313816d7db7eaa46f19cac64c3 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Thu, 7 Aug 2025 22:31:51 +0200 Subject: [PATCH 1/2] snapshot testing --- zml/exe.zig | 6 +++- zml/module.zig | 24 +++++++++----- zml/nn.zig | 12 +++---- zml/platform.zig | 8 +++++ zml/test_runner.zig | 79 +++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 108 insertions(+), 21 deletions(-) diff --git a/zml/exe.zig b/zml/exe.zig index 0923f17c..fdab9e93 100644 --- a/zml/exe.zig +++ b/zml/exe.zig @@ -6,6 +6,7 @@ const aio = @import("aio.zig"); const Buffer = @import("buffer.zig").Buffer; const Bufferized = @import("tensor.zig").Bufferized; const CompilationContext = @import("module.zig").CompilationContext; +const hashArgs = @import("module.zig").hashArgs; const meta = @import("meta.zig"); const pjrt = @import("pjrtx.zig"); const Platform = @import("platform.zig").Platform; @@ -94,7 +95,10 @@ pub fn compileFn( ) !FnExe(func) { var pretty_name = try prettyFnName(func, allocator); defer pretty_name.deinit(allocator); - var context = try CompilationContext.init(allocator, pretty_name.items, platform); + const args_hash = hashArgs(args); + const full_name = try std.fmt.allocPrintZ(allocator, "{s}_{x}", .{ pretty_name.items, args_hash }); + defer allocator.free(full_name); + var context = try CompilationContext.init(allocator, full_name, platform); defer context.deinit(); return .{ .inner = try context.compileInternal(allocator, func, args) }; diff --git a/zml/module.zig b/zml/module.zig index f031e815..35885ba9 100644 --- a/zml/module.zig +++ b/zml/module.zig @@ -76,7 +76,7 @@ pub const CompilationContext = struct { // * leave half of the space for parent folder and XLA generated filename, // * leave 17 bytes for the module hash (16 + 1 for underscore). const max_name_len = @divFloor(std.fs.max_path_bytes, 2) - 17; - const name = full_name[0..@min(max_name_len, full_name.len)]; + const name = platform.compilation_options.name orelse full_name[0..@min(max_name_len, full_name.len)]; const loc = mlir_ctx.location(@src()).named(mlir_ctx, "main"); const module = mlir.Module.init(loc); @@ -174,6 +174,14 @@ pub const CompilationContext = struct { var module_dir: ?[]const u8 = null; var pjrt_location: ?[:0]const u8 = null; + const root = @import("root"); + if (@hasDecl(root, "snapshot_testing")) { + var module_ir: std.ArrayList(u8) = try .initCapacity(arena, 1024); + defer module_ir.deinit(); + module.op().print(module_ir.writer(), .{ .debug_info = false, .debug_info_pretty_form = false }); + try root.snapshot_testing.snapshot(try std.mem.join(arena, ".", &.{ self._name, "mlir" }), module_ir.items); + } + if (self._platform.compilation_options.xla_dump_to) |xla_dump_to| { const sep = std.fs.path.sep_str; const module_dir_name = try std.fmt.allocPrint(arena, "{s}{s}{s}{s}{s}_{x}", .{ xla_dump_to, sep, @tagName(self._platform.target), sep, self._name, module_hash }); @@ -1027,12 +1035,12 @@ test FnCache { }, }, }; - const res = try zml.testing.compileAndCall(platform, NN._fwd, .{ nn, x }); - const expected = try zml.testing.compileAndCall(platform, NN._forwardRefImpl, .{ nn, x }); + const res = try zml.testing.compileAndCall(platform.withExeName("with_cache"), NN._fwd, .{ nn, x }); + const expected = try zml.testing.compileAndCall(platform.withExeName("no_cache"), NN._forwardRefImpl, .{ nn, x }); try zml.testing.expectClose(expected, res, 1e-4); } -test "FnCache with mixed integer/tensor" { +test "FnCache with mixed integer-tensor" { const zml = @import("zml.zig"); const platform = zml.testing.env(); @@ -1091,8 +1099,8 @@ test "FnCache with mixed integer/tensor" { .{ .w = try .fromArray(platform, [3][2]f16{ .{ 1, 2 }, .{ 0, 1 }, .{ -1, 0 } }) }, }, }; - const res = try zml.testing.compileAndCall(platform, NN._fwd, .{ nn, x }); - const expected = try zml.testing.compileAndCall(platform, NN._forwardRefImpl, .{ nn, x }); + const res = try zml.testing.compileAndCall(platform.withExeName("with_cache"), NN._fwd, .{ nn, x }); + const expected = try zml.testing.compileAndCall(platform.withExeName("no_cache"), NN._forwardRefImpl, .{ nn, x }); try zml.testing.expectClose(expected, res, 1e-4); } @@ -1108,7 +1116,7 @@ pub fn hashShape(hasher: *std.hash.Wyhash, shape: Shape) void { hash(hasher, shape._dtype, .Shallow); hash(hasher, shape._sharding_info, .Shallow); for (shape.tags()) |tag| { - hash(hasher, @intFromPtr(tag), .Shallow); + hash(hasher, std.mem.sliceTo(tag, 0), .Deep); } } @@ -1175,7 +1183,7 @@ pub fn hash(hasher: *std.hash.Wyhash, key: anytype, comptime strat: std.hash.Str .many, .c, => switch (strat) { - .shallow => hash(hasher, @intFromPtr(key), .Shallow), + .Shallow => hash(hasher, @intFromPtr(key), .Shallow), else => @compileError( \\ unknown-length pointers and C pointers cannot be hashed deeply. \\ Consider providing your own hash function. diff --git a/zml/nn.zig b/zml/nn.zig index ffdb7a9c..4f5eb9b7 100644 --- a/zml/nn.zig +++ b/zml/nn.zig @@ -323,7 +323,7 @@ test invFreq { } } -test "real/img" { +test splitRealImg { const platform = zml.testing.env(); const Fns = struct { @@ -383,18 +383,18 @@ test "real/img" { } }; - const d_interleaved = try zml.testing.compileAndCall(platform, Fns.testSplitMergeIsId, .{.interleaved}); + const d_interleaved = try zml.testing.compileAndCall(platform.withExeName("interleaved"), Fns.testSplitMergeIsId, .{.interleaved}); try testing.expectEqual(20, d_interleaved.getValue(i32)); - const d_sequential = try zml.testing.compileAndCall(platform, Fns.testSplitMergeIsId, .{.sequential}); + const d_sequential = try zml.testing.compileAndCall(platform.withExeName("sequential"), Fns.testSplitMergeIsId, .{.sequential}); try testing.expectEqual(20, d_sequential.getValue(i32)); // test the function that accepts 1 void argument - const d_split_seq_void = try zml.testing.compileAndCall(platform, Fns.testSplitSeqVoid, .{{}}); + const d_split_seq_void = try zml.testing.compileAndCall(platform.withExeName("split_seq_void"), Fns.testSplitSeqVoid, .{{}}); try testing.expectEqual(20, d_split_seq_void.getValue(i32)); // test the function that takes NO arguments - const d_split_seq = try zml.testing.compileAndCall(platform, Fns.testSplitSeq, .{}); + const d_split_seq = try zml.testing.compileAndCall(platform.withExeName("split_seq"), Fns.testSplitSeq, .{}); try testing.expectEqual(20, d_split_seq.getValue(i32)); // now try compiling and calling ourselves @@ -404,7 +404,7 @@ test "real/img" { const ret = mod.call({}); try testing.expectEqual(20, ret.getValue(i32)); } - const d_split_interleaved = try zml.testing.compileAndCall(platform, Fns.testSplitInterleaved, .{}); + const d_split_interleaved = try zml.testing.compileAndCall(platform.withExeName("split_interleaved"), Fns.testSplitInterleaved, .{}); try testing.expectEqual(20, d_split_interleaved.getValue(i32)); } diff --git a/zml/platform.zig b/zml/platform.zig index a7bc87c9..bfe039d6 100644 --- a/zml/platform.zig +++ b/zml/platform.zig @@ -16,6 +16,8 @@ pub const CompilationOptions = struct { xla_dump_hlo_pass_re: ?[]const u8 = null, sharding_enabled: bool = false, sharding_axes: std.BoundedArray([*:0]const u8, 8) = .{}, + + name: ?[]const u8 = null, }; pub const Platform = struct { @@ -71,6 +73,12 @@ pub const Platform = struct { return res; } + pub fn withExeName(self: Platform, name: []const u8) Platform { + var res = self; + res.compilation_options.name = name; + return res; + } + pub fn registerFFIType(self: Platform, comptime T: type) !void { if (self.pjrt_api.ffi()) |ffi| { if (!@hasDecl(T, "type_id")) { diff --git a/zml/test_runner.zig b/zml/test_runner.zig index ed8ee113..e234b45e 100644 --- a/zml/test_runner.zig +++ b/zml/test_runner.zig @@ -22,6 +22,57 @@ pub fn main() anyerror!void { try asynk.AsyncThread.main(testing.allocator, asyncMain); } +pub const SnapshotTesting = union(enum) { + disabled, + check: std.fs.Dir, + generate: std.fs.Dir, + + pub fn snapshot(mode: SnapshotTesting, name: []const u8, x: []const u8) !void { + return switch (mode) { + .disabled => {}, + .check => |snapshot_dir| { + var test_dir = snapshot_dir.openDir(current_test_fn.name, .{}) catch |err| { + std.log.err("Failed to open snapshot dir {s}", .{current_test_fn.name}); + return err; + }; + defer test_dir.close(); + const ref_file = test_dir.openFile(name, .{ .mode = .read_only }) catch |err| { + std.log.err("Failed to open snapshot {s}/{s}", .{ current_test_fn.name, name }); + return err; + }; + defer ref_file.close(); + const ref = try ref_file.readToEndAlloc(std.testing.allocator, 128 * 1024 * 1024); + defer std.testing.allocator.free(ref); + if (!std.mem.eql(u8, x, ref)) { + const err_name = try std.mem.join(std.testing.allocator, ".", &.{ name, "new" }); + defer std.testing.allocator.free(err_name); + const err_file = test_dir.createFile(err_name, .{ .truncate = true }) catch |err| { + std.log.err("Failed to generate snapshot {s}/{s}", .{ current_test_fn.name, err_name }); + return err; + }; + defer err_file.close(); + try err_file.writeAll(x); + return error.SnapshotMismatch; + } + }, + .generate => |snapshot_dir| { + var test_dir = try snapshot_dir.makeOpenPath(current_test_fn.name, .{}); + defer test_dir.close(); + const out_file = test_dir.createFile(name, .{ .truncate = true }) catch |err| { + std.log.err("Failed to generate snapshot {s}/{s}", .{ current_test_fn.name, name }); + return err; + }; + defer out_file.close(); + try out_file.writeAll(x); + }, + }; + } +}; + +pub var current_test_fn: std.builtin.TestFn = undefined; +pub var snapshot_testing: SnapshotTesting = .disabled; +var _snapshot_in_current_test: u32 = 0; + pub fn asyncMain() !void { const test_fn_list: []const std.builtin.TestFn = builtin.test_functions; var ok_count: usize = 0; @@ -37,12 +88,26 @@ pub fn asyncMain() !void { // Skip executable path _ = args.next().?; - const identifier_query = if (args.next()) |arg| blk: { - std.debug.print("Only tests with identifiers that includes `{s}` will be run\n", .{arg}); - break :blk arg; - } else blk: { - break :blk ""; - }; + var identifier_query: []const u8 = ""; + + while (args.next()) |arg| { + if (std.mem.startsWith(u8, arg, "--filter=")) { + const filter = arg["--filter=".len..]; + std.debug.print("Only tests with identifiers that includes `{s}` will be run\n", .{filter}); + identifier_query = filter; + } else if (std.mem.startsWith(u8, arg, "--snapshot-gen=")) { + const dir = arg["--snapshot-gen=".len..]; + std.debug.print("Will output new snapshot output to `{s}`\n", .{dir}); + snapshot_testing = .{ .generate = try std.fs.cwd().makeOpenPath(dir, .{}) }; + } else if (std.mem.startsWith(u8, arg, "--snapshot-check=")) { + const dir = arg["--snapshot-check=".len..]; + std.debug.print("Will check against previous snapshot `{s}`\n", .{dir}); + snapshot_testing = .{ .check = try std.fs.cwd().makeOpenPath(dir, .{}) }; + } else { + std.debug.print("Unsupported argument: {s}\n", .{arg}); + std.process.exit(1); + } + } var leaks: usize = 0; @@ -59,6 +124,8 @@ pub fn asyncMain() !void { } const test_node = root_node.start(test_fn.name, 0); + current_test_fn = test_fn; + _snapshot_in_current_test = 0; if (!have_tty) { std.debug.print("{d}/{d} {s}...", .{ i + 1, test_fn_list.len, test_fn.name }); } From 72973d5696d4d786092d8c0893bec39fb97b0397 Mon Sep 17 00:00:00 2001 From: Guillaume Wenzek Date: Thu, 7 Aug 2025 22:31:59 +0200 Subject: [PATCH 2/2] generated mlir --- .../module.decltest.FnCache/no_cache.mlir | 17 + .../module.decltest.FnCache/with_cache.mlir | 24 ++ .../no_cache.mlir | 15 + .../with_cache.mlir | 22 ++ ...truct_141677) Tensor_35f80c47f062ba40.mlir | 15 + ...truct_141677) Tensor_53477e6bb3c9baff.mlir | 21 ++ ...truct_141677) Tensor_578d8317c4471255.mlir | 14 + ...truct_141677) Tensor_946175e65da2d207.mlir | 16 + ...truct_141677) Tensor_9a1746baa109df2c.mlir | 13 + ...(Tensor, f32) Tensor_5015dd163860654e.mlir | 21 ++ ... nn.RopeOpts) Tensor_97a02d2d4e1f55f6.mlir | 36 ++ ... nn.RopeOpts) Tensor_c8f399bc1618a73a.mlir | 42 +++ ...Tensor, Tensor.Rng }_df220299c18ba41b.mlir | 63 ++++ ...gStrategy) [2]Tensor_23acf0b9f0bb3fab.mlir | 60 ++++ ...gStrategy) [2]Tensor_63f53aa22b7507cf.mlir | 60 ++++ ...struct_155810) Tensor_91b4e3e69b5098c.mlir | 9 + ...truct_155810) Tensor_9dce10a188fca6fa.mlir | 9 + ... nn.SdpaOpts) Tensor_1baf90feb653a9f5.mlir | 36 ++ ...n.SdpaChunks) Tensor_3325120933b1fbb6.mlir | 288 ++++++++++++++++ ...nn.SdpaChunks) Tensor_b2d9d9c8840e850.mlir | 122 +++++++ .../fn () Tensor_409638ee2bde459.mlir | 50 +++ .../nn.decltest.splitRealImg/interleaved.mlir | 39 +++ .../nn.decltest.splitRealImg/sequential.mlir | 36 ++ .../split_interleaved.mlir | 40 +++ .../nn.decltest.splitRealImg/split_seq.mlir | 50 +++ .../split_seq_void.mlir | 50 +++ ...struct_155810) Tensor_91b4e3e69b5098c.mlir | 9 + ...truct_155810) Tensor_e94eca87ec879d51.mlir | 9 + ... nn.SdpaOpts) Tensor_c204f895396cd33f.mlir | 37 +++ ...n.SdpaChunks) Tensor_62dec6bb3422c159.mlir | 312 ++++++++++++++++++ ...n.SdpaChunks) Tensor_bf20962f3dae6108.mlir | 171 ++++++++++ .../fn (u63) Tensor_14376d570bdf5f73.mlir | 22 ++ .../fn (u63) Tensor_89b92f2adbf9b0a3.mlir | 25 ++ .../fn (u63) Tensor_ac3608194ddc6751.mlir | 9 + ...nsor, Tensor) Tensor_a2cfcdc950547238.mlir | 15 + ...nsor, Tensor) Tensor_da6609608556e344.mlir | 13 + .../fn (Tensor) Tensor_41691c61316b43d0.mlir | 53 +++ ...r, Tensor) [2]Tensor_ba74471b89106421.mlir | 16 + ...ltest.gumbel.Stats }_e3baa2046c4de947.mlir | 88 +++++ ...test.uniform.Stats }_babf4bd850f5fbe7.mlir | 58 ++++ ...or) Tensor.ArgMaxRes_e51ff236eeeaadfa.mlir | 24 ++ ....ArgSortOpts) Tensor_b9d3aceaaa8fce1b.mlir | 12 + ....ArgSortOpts) Tensor_d5ba130ca24deacf.mlir | 12 + ....ArgSortOpts) Tensor_ec74630dd923db38.mlir | 12 + ...r, Tensor) [2]Tensor_c363d77d6848ab99.mlir | 7 + ...nsor, Tensor) Tensor_c363d77d6848ab99.mlir | 10 + .../fn (Tensor) Tensor_779cc7a90f1d047d.mlir | 11 + ...nsor.DynSlice) Tensor_813c9ac780d541e.mlir | 7 + ...sor.DynSlice) Tensor_e2569044b377362b.mlir | 6 + ...nsor, Tensor) Tensor_a0a798addd49e74f.mlir | 7 + ...nsor, Tensor) Tensor_ff069b5e746c5326.mlir | 8 + ...6624, Tensor) Tensor_46e7a0832247bfa7.mlir | 7 + ...7079, Tensor) Tensor_d338b5d4d8f6f271.mlir | 7 + ...nsor, Tensor) Tensor_d52db17c5ad49d8c.mlir | 6 + ...(Tensor, f32) Tensor_5d1e6508b3dc3548.mlir | 8 + ...(Tensor, f32) Tensor_d30d7323e1e93b70.mlir | 8 + ...r.GatherOpts) Tensor_1cf22f2965934f5b.mlir | 6 + ...r.GatherOpts) Tensor_42b1906b87448f2a.mlir | 6 + ...r.GatherOpts) Tensor_4f75e8d518c3b3d1.mlir | 6 + ...r.GatherOpts) Tensor_57a53a95ad472953.mlir | 6 + ...r.GatherOpts) Tensor_5dec99541d53e940.mlir | 6 + ...r.GatherOpts) Tensor_6def9230a7bcb902.mlir | 6 + ...r.GatherOpts) Tensor_734d155694f71e37.mlir | 6 + ...r.GatherOpts) Tensor_77e9e196d9455f4c.mlir | 6 + ...r.GatherOpts) Tensor_79da0dfda896d57e.mlir | 6 + ...or.GatherOpts) Tensor_7c379e03680deb5.mlir | 6 + ...r.GatherOpts) Tensor_90254835651ba6f9.mlir | 6 + ...r.GatherOpts) Tensor_b1b532a17c0c7821.mlir | 6 + ...r.GatherOpts) Tensor_b5aa3ebec7cf79f1.mlir | 6 + ...r.GatherOpts) Tensor_ddbdd3f5dda057f8.mlir | 6 + ...r.GatherOpts) Tensor_e28657b86fe33ba2.mlir | 6 + ...(Tensor, f32) Tensor_381ab030e7ccb9d5.mlir | 13 + .../fn () [6]Tensor_409638ee2bde459.mlir | 11 + ...nsor, Tensor) Tensor_6ae2295e6097dde6.mlir | 19 ++ ...nsor, Tensor) Tensor_3f024338ab39284b.mlir | 11 + ...nsor, Tensor) Tensor_fb5a1da8ad9bf1fb.mlir | 11 + ...Tensor.Slice) Tensor_1b9a60f4504a79f6.mlir | 7 + ...Tensor.Slice) Tensor_6a8aa7237ca75292.mlir | 7 + ...Tensor.Slice) Tensor_ee2c6f0e350d8f21.mlir | 7 + .../fn (Tensor) Tensor_7c9528cf37407f7b.mlir | 13 + ...(Tensor, i32) Tensor_3c1415d524fbdb98.mlir | 14 + ...(Tensor, i32) Tensor_9703ef96e083c0f8.mlir | 14 + ...(Tensor, i32) Tensor_ae9f56f8c7431633.mlir | 14 + ...or) Tensor.ArgMaxRes_b92819e0050b1612.mlir | 21 ++ ...or) Tensor.ArgMaxRes_c909c10268568544.mlir | 21 ++ .../fn (Tensor) Tensor_8437cca72634e001.mlir | 5 + .../nn.Linear.forward.mlir | 6 + ...dIndexing) [2]Tensor_af34bec8622b2348.mlir | 7 + ...(Tensor, u32) Tensor_7db731f87a15127b.mlir | 8 + ..., []const u8) Tensor_95471c6a0b9cc132.mlir | 22 ++ .../fn (Tensor) Tensor_1e8d6fee27f95b51.mlir | 8 + 91 files changed, 2486 insertions(+) create mode 100644 zml/test_data/snapshot/module.decltest.FnCache/no_cache.mlir create mode 100644 zml/test_data/snapshot/module.decltest.FnCache/with_cache.mlir create mode 100644 zml/test_data/snapshot/module.test.FnCache with mixed integer-tensor/no_cache.mlir create mode 100644 zml/test_data/snapshot/module.test.FnCache with mixed integer-tensor/with_cache.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_35f80c47f062ba40.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_53477e6bb3c9baff.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_578d8317c4471255.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_946175e65da2d207.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_9a1746baa109df2c.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.normalizeL2/fn (Tensor, f32) Tensor_5015dd163860654e.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.rope/fn (Tensor, nn.RopeOpts) Tensor_97a02d2d4e1f55f6.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.rope/fn (Tensor, nn.RopeOpts) Tensor_c8f399bc1618a73a.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.sampleTokens/fn (Tensor, nn.SamplingStrategy, Tensor.Rng) struct { Tensor, Tensor.Rng }_df220299c18ba41b.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.sampleTokensDynamic/fn (Tensor, nn.DynamicSamplingStrategy) [2]Tensor_23acf0b9f0bb3fab.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.sampleTokensDynamic/fn (Tensor, nn.DynamicSamplingStrategy) [2]Tensor_63f53aa22b7507cf.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_91b4e3e69b5098c.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_9dce10a188fca6fa.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Tensor, Tensor, Tensor, nn.SdpaOpts) Tensor_1baf90feb653a9f5.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_3325120933b1fbb6.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_b2d9d9c8840e850.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.splitRealImg/fn () Tensor_409638ee2bde459.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.splitRealImg/interleaved.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.splitRealImg/sequential.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.splitRealImg/split_interleaved.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.splitRealImg/split_seq.mlir create mode 100644 zml/test_data/snapshot/nn.decltest.splitRealImg/split_seq_void.mlir create mode 100644 zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_91b4e3e69b5098c.mlir create mode 100644 zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_e94eca87ec879d51.mlir create mode 100644 zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Tensor, Tensor, Tensor, nn.SdpaOpts) Tensor_c204f895396cd33f.mlir create mode 100644 zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_62dec6bb3422c159.mlir create mode 100644 zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_bf20962f3dae6108.mlir create mode 100644 zml/test_data/snapshot/ops.decltest.for_/fn (u63) Tensor_14376d570bdf5f73.mlir create mode 100644 zml/test_data/snapshot/ops.decltest.for_/fn (u63) Tensor_89b92f2adbf9b0a3.mlir create mode 100644 zml/test_data/snapshot/ops.decltest.for_/fn (u63) Tensor_ac3608194ddc6751.mlir create mode 100644 zml/test_data/snapshot/ops.test.case/fn (Tensor, Tensor, Tensor) Tensor_a2cfcdc950547238.mlir create mode 100644 zml/test_data/snapshot/ops.test.if/fn (Tensor, Tensor, Tensor) Tensor_da6609608556e344.mlir create mode 100644 zml/test_data/snapshot/ops.test.nested for/fn (Tensor) Tensor_41691c61316b43d0.mlir create mode 100644 zml/test_data/snapshot/ops.test.simple while/fn (ops.test.simple while.CountInts, Tensor, Tensor) [2]Tensor_ba74471b89106421.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.Rng.decltest.gumbel/fn (Tensor.Rng, Tensor) struct { Tensor.Rng, Tensor.Rng.decltest.gumbel.Stats }_e3baa2046c4de947.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.Rng.decltest.uniform/fn (Tensor.Rng, Shape, Tensor.Rng.decltest.uniform.Stats.uniformStats__struct_199888) struct { Tensor.Rng, Tensor.Rng.decltest.uniform.Stats }_babf4bd850f5fbe7.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.argMax/fn (Tensor) Tensor.ArgMaxRes_e51ff236eeeaadfa.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.argsort/fn (Tensor, u3, Tensor.ArgSortOpts) Tensor_b9d3aceaaa8fce1b.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.argsort/fn (Tensor, u3, Tensor.ArgSortOpts) Tensor_d5ba130ca24deacf.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.argsort/fn (Tensor, u3, Tensor.ArgSortOpts) Tensor_ec74630dd923db38.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.cartesianProduct/fn (Tensor, Tensor) [2]Tensor_c363d77d6848ab99.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.cartesianProductStacked/fn (Tensor, Tensor) Tensor_c363d77d6848ab99.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.cumulativeSum/fn (Tensor) Tensor_779cc7a90f1d047d.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.dynamicSlice/fn (Tensor, i8, Tensor.DynSlice) Tensor_813c9ac780d541e.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.dynamicSlice/fn (Tensor, i8, Tensor.DynSlice) Tensor_e2569044b377362b.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor, Tensor) Tensor_a0a798addd49e74f.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor, Tensor) Tensor_ff069b5e746c5326.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor.decltest.dynamicUpdateSlice__struct_136623._fwd__struct_136624, Tensor) Tensor_46e7a0832247bfa7.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor.decltest.dynamicUpdateSlice__struct_137078._fwd__struct_137079, Tensor) Tensor_d338b5d4d8f6f271.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, [2]Tensor, Tensor) Tensor_d52db17c5ad49d8c.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.fmod/fn (Tensor, f32) Tensor_5d1e6508b3dc3548.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.fmod/fn (Tensor, f32) Tensor_d30d7323e1e93b70.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_1cf22f2965934f5b.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_42b1906b87448f2a.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_4f75e8d518c3b3d1.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_57a53a95ad472953.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_5dec99541d53e940.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_6def9230a7bcb902.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_734d155694f71e37.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_77e9e196d9455f4c.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_79da0dfda896d57e.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_7c379e03680deb5.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_90254835651ba6f9.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_b1b532a17c0c7821.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_b5aa3ebec7cf79f1.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_ddbdd3f5dda057f8.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_e28657b86fe33ba2.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.leakyReLU/fn (Tensor, f32) Tensor_381ab030e7ccb9d5.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.scalar/fn () [6]Tensor_409638ee2bde459.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.scatterSlices/fn (Tensor, Tensor, Tensor) Tensor_6ae2295e6097dde6.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.scatterSlices/fn (Tensor, []const Tensor, Tensor) Tensor_3f024338ab39284b.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.scatterSlices/fn (Tensor, []const Tensor, Tensor) Tensor_fb5a1da8ad9bf1fb.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.slice/fn (Tensor, i8, Tensor.Slice) Tensor_1b9a60f4504a79f6.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.slice/fn (Tensor, i8, Tensor.Slice) Tensor_6a8aa7237ca75292.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.slice/fn (Tensor, i8, Tensor.Slice) Tensor_ee2c6f0e350d8f21.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.toDiagonal/fn (Tensor) Tensor_7c9528cf37407f7b.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.triangular/fn (Tensor, i32) Tensor_3c1415d524fbdb98.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.triangular/fn (Tensor, i32) Tensor_9703ef96e083c0f8.mlir create mode 100644 zml/test_data/snapshot/tensor.Tensor.decltest.triangular/fn (Tensor, i32) Tensor_ae9f56f8c7431633.mlir create mode 100644 zml/test_data/snapshot/tensor.test.Tensor.maxPool1d/fn (Tensor) Tensor.ArgMaxRes_b92819e0050b1612.mlir create mode 100644 zml/test_data/snapshot/tensor.test.Tensor.maxPool2d/fn (Tensor) Tensor.ArgMaxRes_c909c10268568544.mlir create mode 100644 zml/test_data/snapshot/tensor.test.unused tensor/fn (Tensor) Tensor_8437cca72634e001.mlir create mode 100644 zml/test_data/snapshot/testing.decltest.testLayer/nn.Linear.forward.mlir create mode 100644 zml/test_data/snapshot/torch.decltest.meshgrid/fn (Tensor, Tensor, torch.MeshgridIndexing) [2]Tensor_af34bec8622b2348.mlir create mode 100644 zml/test_data/snapshot/torch.decltest.pixelShuffle/fn (Tensor, u32) Tensor_7db731f87a15127b.mlir create mode 100644 zml/test_data/snapshot/torch.decltest.roll/fn (Tensor, []const i64, []const u8) Tensor_95471c6a0b9cc132.mlir create mode 100644 zml/test_data/snapshot/torch.decltest.unsqueeze/fn (Tensor) Tensor_1e8d6fee27f95b51.mlir diff --git a/zml/test_data/snapshot/module.decltest.FnCache/no_cache.mlir b/zml/test_data/snapshot/module.decltest.FnCache/no_cache.mlir new file mode 100644 index 00000000..8eede0c4 --- /dev/null +++ b/zml/test_data/snapshot/module.decltest.FnCache/no_cache.mlir @@ -0,0 +1,17 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<2x2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor<2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg4: tensor<3x2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg5: tensor<3xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg6: tensor<2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<3xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %0 = stablehlo.dot_general %arg0, %arg6, contracting_dims = [1] x [0], precision = [DEFAULT, DEFAULT] : (tensor<2x2xf16>, tensor<2xf16>) -> tensor<2xf16> + %1 = stablehlo.add %0, %arg1 : tensor<2xf16> + %2 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<2xf16> + %3 = stablehlo.maximum %1, %2 : tensor<2xf16> + %4 = stablehlo.dot_general %arg2, %3, contracting_dims = [1] x [0], precision = [DEFAULT, DEFAULT] : (tensor<2x2xf16>, tensor<2xf16>) -> tensor<2xf16> + %5 = stablehlo.add %4, %arg3 : tensor<2xf16> + %6 = stablehlo.maximum %5, %2 : tensor<2xf16> + %7 = stablehlo.dot_general %arg4, %6, contracting_dims = [1] x [0], precision = [DEFAULT, DEFAULT] : (tensor<3x2xf16>, tensor<2xf16>) -> tensor<3xf16> + %8 = stablehlo.add %7, %arg5 : tensor<3xf16> + %9 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<3xf16> + %10 = stablehlo.maximum %8, %9 : tensor<3xf16> + return %10 : tensor<3xf16> + } +} diff --git a/zml/test_data/snapshot/module.decltest.FnCache/with_cache.mlir b/zml/test_data/snapshot/module.decltest.FnCache/with_cache.mlir new file mode 100644 index 00000000..50aaf6a0 --- /dev/null +++ b/zml/test_data/snapshot/module.decltest.FnCache/with_cache.mlir @@ -0,0 +1,24 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @module.decltest.FnCache.Layer._fwd_b4103d12b0fc0621(%arg0: tensor<2x2xf16>, %arg1: tensor<2xf16>, %arg2: tensor<2xf16>) -> tensor<2xf16> { + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %0 = stablehlo.dot_general %arg0, %arg2, contracting_dims = [1] x [0], precision = [DEFAULT, DEFAULT] : (tensor<2x2xf16>, tensor<2xf16>) -> tensor<2xf16> + %1 = stablehlo.add %0, %arg1 : tensor<2xf16> + %2 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<2xf16> + %3 = stablehlo.maximum %1, %2 : tensor<2xf16> + return %3 : tensor<2xf16> + } + func.func @module.decltest.FnCache.Layer._fwd_544d74fe80abb17(%arg0: tensor<3x2xf16>, %arg1: tensor<3xf16>, %arg2: tensor<2xf16>) -> tensor<3xf16> { + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %0 = stablehlo.dot_general %arg0, %arg2, contracting_dims = [1] x [0], precision = [DEFAULT, DEFAULT] : (tensor<3x2xf16>, tensor<2xf16>) -> tensor<3xf16> + %1 = stablehlo.add %0, %arg1 : tensor<3xf16> + %2 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<3xf16> + %3 = stablehlo.maximum %1, %2 : tensor<3xf16> + return %3 : tensor<3xf16> + } + func.func @main(%arg0: tensor<2x2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<2x2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor<2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg4: tensor<3x2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg5: tensor<3xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg6: tensor<2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<3xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = call @module.decltest.FnCache.Layer._fwd_b4103d12b0fc0621(%arg0, %arg1, %arg6) {operandSegmentSizes = dense<3> : tensor<1xi32>} : (tensor<2x2xf16>, tensor<2xf16>, tensor<2xf16>) -> tensor<2xf16> + %1 = call @module.decltest.FnCache.Layer._fwd_b4103d12b0fc0621(%arg2, %arg3, %0) {operandSegmentSizes = dense<3> : tensor<1xi32>} : (tensor<2x2xf16>, tensor<2xf16>, tensor<2xf16>) -> tensor<2xf16> + %2 = call @module.decltest.FnCache.Layer._fwd_544d74fe80abb17(%arg4, %arg5, %1) {operandSegmentSizes = dense<3> : tensor<1xi32>} : (tensor<3x2xf16>, tensor<3xf16>, tensor<2xf16>) -> tensor<3xf16> + return %2 : tensor<3xf16> + } +} diff --git a/zml/test_data/snapshot/module.test.FnCache with mixed integer-tensor/no_cache.mlir b/zml/test_data/snapshot/module.test.FnCache with mixed integer-tensor/no_cache.mlir new file mode 100644 index 00000000..1b192892 --- /dev/null +++ b/zml/test_data/snapshot/module.test.FnCache with mixed integer-tensor/no_cache.mlir @@ -0,0 +1,15 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<2x2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<3x2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor<2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<3xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<2.000000e+00> : tensor + %cst_0 = stablehlo.constant dense<1.000000e+00> : tensor + %0 = stablehlo.dot_general %arg0, %arg3, contracting_dims = [1] x [0], precision = [DEFAULT, DEFAULT] : (tensor<2x2xf16>, tensor<2xf16>) -> tensor<2xf16> + %1 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<2xf16> + %2 = stablehlo.add %0, %1 : tensor<2xf16> + %3 = stablehlo.dot_general %arg1, %2, contracting_dims = [1] x [0], precision = [DEFAULT, DEFAULT] : (tensor<2x2xf16>, tensor<2xf16>) -> tensor<2xf16> + %4 = stablehlo.add %3, %1 : tensor<2xf16> + %5 = stablehlo.dot_general %arg2, %4, contracting_dims = [1] x [0], precision = [DEFAULT, DEFAULT] : (tensor<3x2xf16>, tensor<2xf16>) -> tensor<3xf16> + %6 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<3xf16> + %7 = stablehlo.add %5, %6 : tensor<3xf16> + return %7 : tensor<3xf16> + } +} diff --git a/zml/test_data/snapshot/module.test.FnCache with mixed integer-tensor/with_cache.mlir b/zml/test_data/snapshot/module.test.FnCache with mixed integer-tensor/with_cache.mlir new file mode 100644 index 00000000..bd4eb069 --- /dev/null +++ b/zml/test_data/snapshot/module.test.FnCache with mixed integer-tensor/with_cache.mlir @@ -0,0 +1,22 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @"module.test.FnCache with mixed integer-tensor.Layer._fwd_975b269a9674d3be"(%arg0: tensor<2x2xf16>, %arg1: tensor<2xf16>) -> tensor<2xf16> { + %cst = stablehlo.constant dense<1.000000e+00> : tensor + %0 = stablehlo.dot_general %arg0, %arg1, contracting_dims = [1] x [0], precision = [DEFAULT, DEFAULT] : (tensor<2x2xf16>, tensor<2xf16>) -> tensor<2xf16> + %1 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<2xf16> + %2 = stablehlo.add %0, %1 : tensor<2xf16> + return %2 : tensor<2xf16> + } + func.func @"module.test.FnCache with mixed integer-tensor.Layer._fwd_9dc18e8af9fce7c1"(%arg0: tensor<3x2xf16>, %arg1: tensor<2xf16>) -> tensor<3xf16> { + %cst = stablehlo.constant dense<2.000000e+00> : tensor + %0 = stablehlo.dot_general %arg0, %arg1, contracting_dims = [1] x [0], precision = [DEFAULT, DEFAULT] : (tensor<3x2xf16>, tensor<2xf16>) -> tensor<3xf16> + %1 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<3xf16> + %2 = stablehlo.add %0, %1 : tensor<3xf16> + return %2 : tensor<3xf16> + } + func.func @main(%arg0: tensor<2x2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<2x2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<3x2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor<2xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<3xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = call @"module.test.FnCache with mixed integer-tensor.Layer._fwd_975b269a9674d3be"(%arg0, %arg3) {operandSegmentSizes = dense<2> : tensor<1xi32>} : (tensor<2x2xf16>, tensor<2xf16>) -> tensor<2xf16> + %1 = call @"module.test.FnCache with mixed integer-tensor.Layer._fwd_975b269a9674d3be"(%arg1, %0) {operandSegmentSizes = dense<2> : tensor<1xi32>} : (tensor<2x2xf16>, tensor<2xf16>) -> tensor<2xf16> + %2 = call @"module.test.FnCache with mixed integer-tensor.Layer._fwd_9dc18e8af9fce7c1"(%arg2, %1) {operandSegmentSizes = dense<2> : tensor<1xi32>} : (tensor<3x2xf16>, tensor<2xf16>) -> tensor<3xf16> + return %2 : tensor<3xf16> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_35f80c47f062ba40.mlir b/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_35f80c47f062ba40.mlir new file mode 100644 index 00000000..b3c09591 --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_35f80c47f062ba40.mlir @@ -0,0 +1,15 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x1x2xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x1x6xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<0.333333343> : tensor + %cst_0 = stablehlo.constant dense<5.000000e-01> : tensor + %0 = stablehlo.iota dim = 0 : tensor<6xf32> + %1 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<6xf32> + %2 = stablehlo.add %0, %1 : tensor<6xf32> + %3 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<6xf32> + %4 = stablehlo.multiply %2, %3 : tensor<6xf32> + %5 = stablehlo.floor %4 : tensor<6xf32> + %6 = stablehlo.convert %5 : (tensor<6xf32>) -> tensor<6xi32> + %7 = "stablehlo.gather"(%arg0, %6) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<1x1x2xi32>, tensor<6xi32>) -> tensor<1x1x6xi32> + return %7 : tensor<1x1x6xi32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_53477e6bb3c9baff.mlir b/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_53477e6bb3c9baff.mlir new file mode 100644 index 00000000..f25a45b9 --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_53477e6bb3c9baff.mlir @@ -0,0 +1,21 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x1x1x2x2xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x1x2x4x4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<5.000000e-01> : tensor + %0 = stablehlo.iota dim = 0 : tensor<2xf32> + %1 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<2xf32> + %2 = stablehlo.add %0, %1 : tensor<2xf32> + %3 = stablehlo.multiply %2, %1 : tensor<2xf32> + %4 = stablehlo.floor %3 : tensor<2xf32> + %5 = stablehlo.convert %4 : (tensor<2xf32>) -> tensor<2xi32> + %6 = "stablehlo.gather"(%arg0, %5) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<1x1x1x2x2xi32>, tensor<2xi32>) -> tensor<1x1x2x2x2xi32> + %7 = stablehlo.iota dim = 0 : tensor<4xf32> + %8 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<4xf32> + %9 = stablehlo.add %7, %8 : tensor<4xf32> + %10 = stablehlo.multiply %9, %8 : tensor<4xf32> + %11 = stablehlo.floor %10 : tensor<4xf32> + %12 = stablehlo.convert %11 : (tensor<4xf32>) -> tensor<4xi32> + %13 = "stablehlo.gather"(%6, %12) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<1x1x2x2x2xi32>, tensor<4xi32>) -> tensor<1x1x2x4x2xi32> + %14 = "stablehlo.gather"(%13, %12) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<1x1x2x4x2xi32>, tensor<4xi32>) -> tensor<1x1x2x4x4xi32> + return %14 : tensor<1x1x2x4x4xi32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_578d8317c4471255.mlir b/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_578d8317c4471255.mlir new file mode 100644 index 00000000..036cde5e --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_578d8317c4471255.mlir @@ -0,0 +1,14 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x2x2x2xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x2x4x4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<5.000000e-01> : tensor + %0 = stablehlo.iota dim = 0 : tensor<4xf32> + %1 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<4xf32> + %2 = stablehlo.add %0, %1 : tensor<4xf32> + %3 = stablehlo.multiply %2, %1 : tensor<4xf32> + %4 = stablehlo.floor %3 : tensor<4xf32> + %5 = stablehlo.convert %4 : (tensor<4xf32>) -> tensor<4xi32> + %6 = "stablehlo.gather"(%arg0, %5) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<2x2x2x2xi32>, tensor<4xi32>) -> tensor<2x2x4x2xi32> + %7 = "stablehlo.gather"(%6, %5) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<2x2x4x2xi32>, tensor<4xi32>) -> tensor<2x2x4x4xi32> + return %7 : tensor<2x2x4x4xi32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_946175e65da2d207.mlir b/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_946175e65da2d207.mlir new file mode 100644 index 00000000..bf463c26 --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_946175e65da2d207.mlir @@ -0,0 +1,16 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x1x2x2xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x1x6x6xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<0.333333343> : tensor + %cst_0 = stablehlo.constant dense<5.000000e-01> : tensor + %0 = stablehlo.iota dim = 0 : tensor<6xf32> + %1 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<6xf32> + %2 = stablehlo.add %0, %1 : tensor<6xf32> + %3 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<6xf32> + %4 = stablehlo.multiply %2, %3 : tensor<6xf32> + %5 = stablehlo.floor %4 : tensor<6xf32> + %6 = stablehlo.convert %5 : (tensor<6xf32>) -> tensor<6xi32> + %7 = "stablehlo.gather"(%arg0, %6) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<1x1x2x2xi32>, tensor<6xi32>) -> tensor<1x1x6x2xi32> + %8 = "stablehlo.gather"(%7, %6) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<1x1x6x2xi32>, tensor<6xi32>) -> tensor<1x1x6x6xi32> + return %8 : tensor<1x1x6x6xi32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_9a1746baa109df2c.mlir b/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_9a1746baa109df2c.mlir new file mode 100644 index 00000000..a106dcfc --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.nearest/fn (Tensor, nn.upsample__struct_141677) Tensor_9a1746baa109df2c.mlir @@ -0,0 +1,13 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x3x4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x3x8xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<5.000000e-01> : tensor + %0 = stablehlo.iota dim = 0 : tensor<8xf32> + %1 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<8xf32> + %2 = stablehlo.add %0, %1 : tensor<8xf32> + %3 = stablehlo.multiply %2, %1 : tensor<8xf32> + %4 = stablehlo.floor %3 : tensor<8xf32> + %5 = stablehlo.convert %4 : (tensor<8xf32>) -> tensor<8xi32> + %6 = "stablehlo.gather"(%arg0, %5) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<2x3x4xi32>, tensor<8xi32>) -> tensor<2x3x8xi32> + return %6 : tensor<2x3x8xi32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.normalizeL2/fn (Tensor, f32) Tensor_5015dd163860654e.mlir b/zml/test_data/snapshot/nn.decltest.normalizeL2/fn (Tensor, f32) Tensor_5015dd163860654e.mlir new file mode 100644 index 00000000..43d2d4ec --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.normalizeL2/fn (Tensor, f32) Tensor_5015dd163860654e.mlir @@ -0,0 +1,21 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<9.99999996E-13> : tensor + %cst_0 = stablehlo.constant dense<0.000000e+00> : tensor + %cst_1 = stablehlo.constant dense<2.000000e+00> : tensor + %0 = stablehlo.broadcast_in_dim %cst_1, dims = [] : (tensor) -> tensor<2x2xf32> + %1 = stablehlo.power %arg0, %0 : tensor<2x2xf32> + %2 = stablehlo.reduce(%1 init: %cst_0) across dimensions = [1] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<2x2xf32>, tensor) -> tensor<2xf32> + reducer(%arg1: tensor, %arg2: tensor) { + %9 = stablehlo.add %arg2, %arg1 : tensor + stablehlo.return %9 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %3 = stablehlo.broadcast_in_dim %2, dims = [0] : (tensor<2xf32>) -> tensor<2x1xf32> + %4 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<2x1xf32> + %5 = stablehlo.add %3, %4 : tensor<2x1xf32> + %6 = stablehlo.rsqrt %5 : tensor<2x1xf32> + %7 = stablehlo.broadcast_in_dim %6, dims = [0, 1] : (tensor<2x1xf32>) -> tensor<2x2xf32> + %8 = stablehlo.multiply %arg0, %7 : tensor<2x2xf32> + return %8 : tensor<2x2xf32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.rope/fn (Tensor, nn.RopeOpts) Tensor_97a02d2d4e1f55f6.mlir b/zml/test_data/snapshot/nn.decltest.rope/fn (Tensor, nn.RopeOpts) Tensor_97a02d2d4e1f55f6.mlir new file mode 100644 index 00000000..fb17812a --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.rope/fn (Tensor, nn.RopeOpts) Tensor_97a02d2d4e1f55f6.mlir @@ -0,0 +1,36 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x5x4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<5x4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<[1.000000e+00, 0.00999999977]> : tensor<2xf32> + %0 = stablehlo.slice %arg0 [0:1, 0:5, 0:2] : (tensor<1x5x4xf32>) -> tensor<1x5x2xf32> + %1 = stablehlo.reshape %0 : (tensor<1x5x2xf32>) -> tensor<1x5x2xf32> + %2 = stablehlo.slice %arg0 [0:1, 0:5, 2:4] : (tensor<1x5x4xf32>) -> tensor<1x5x2xf32> + %3 = stablehlo.reshape %2 : (tensor<1x5x2xf32>) -> tensor<1x5x2xf32> + %4 = stablehlo.concatenate %1, %3, dim = 2 : (tensor<1x5x2xf32>, tensor<1x5x2xf32>) -> tensor<1x5x4xf32> + %5 = stablehlo.slice %4 [0:1, 0:5, 0:2] : (tensor<1x5x4xf32>) -> tensor<1x5x2xf32> + %6 = stablehlo.reshape %5 : (tensor<1x5x2xf32>) -> tensor<1x5x2xf32> + %7 = stablehlo.iota dim = 0 : tensor<5xf32> + %8 = stablehlo.broadcast_in_dim %7, dims = [0] : (tensor<5xf32>) -> tensor<5x2xf32> + %9 = stablehlo.broadcast_in_dim %cst, dims = [1] : (tensor<2xf32>) -> tensor<5x2xf32> + %10 = stablehlo.multiply %8, %9 : tensor<5x2xf32> + %11 = stablehlo.cosine %10 : tensor<5x2xf32> + %12 = stablehlo.broadcast_in_dim %11, dims = [1, 2] : (tensor<5x2xf32>) -> tensor<1x5x2xf32> + %13 = stablehlo.multiply %6, %12 : tensor<1x5x2xf32> + %14 = stablehlo.slice %4 [0:1, 0:5, 2:4] : (tensor<1x5x4xf32>) -> tensor<1x5x2xf32> + %15 = stablehlo.reshape %14 : (tensor<1x5x2xf32>) -> tensor<1x5x2xf32> + %16 = stablehlo.sine %10 : tensor<5x2xf32> + %17 = stablehlo.broadcast_in_dim %16, dims = [1, 2] : (tensor<5x2xf32>) -> tensor<1x5x2xf32> + %18 = stablehlo.multiply %15, %17 : tensor<1x5x2xf32> + %19 = stablehlo.subtract %13, %18 : tensor<1x5x2xf32> + %20 = stablehlo.multiply %6, %17 : tensor<1x5x2xf32> + %21 = stablehlo.multiply %15, %12 : tensor<1x5x2xf32> + %22 = stablehlo.add %20, %21 : tensor<1x5x2xf32> + %23 = stablehlo.concatenate %19, %22, dim = 2 : (tensor<1x5x2xf32>, tensor<1x5x2xf32>) -> tensor<1x5x4xf32> + %24 = stablehlo.reshape %23 : (tensor<1x5x4xf32>) -> tensor<5x4xf32> + %25 = stablehlo.slice %24 [0:5, 0:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %26 = stablehlo.reshape %25 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %27 = stablehlo.slice %24 [0:5, 2:4] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %28 = stablehlo.reshape %27 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %29 = stablehlo.concatenate %26, %28, dim = 1 : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x4xf32> + return %29 : tensor<5x4xf32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.rope/fn (Tensor, nn.RopeOpts) Tensor_c8f399bc1618a73a.mlir b/zml/test_data/snapshot/nn.decltest.rope/fn (Tensor, nn.RopeOpts) Tensor_c8f399bc1618a73a.mlir new file mode 100644 index 00000000..b41909ba --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.rope/fn (Tensor, nn.RopeOpts) Tensor_c8f399bc1618a73a.mlir @@ -0,0 +1,42 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x5x4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<5x4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<[1.000000e+00, 0.00999999977]> : tensor<2xf32> + %0 = stablehlo.slice %arg0 [0:1, 0:5, 0:2] : (tensor<1x5x4xf32>) -> tensor<1x5x2xf32> + %1 = stablehlo.reshape %0 : (tensor<1x5x2xf32>) -> tensor<1x5x2xf32> + %2 = stablehlo.reshape %1 : (tensor<1x5x2xf32>) -> tensor<1x5x2x1xf32> + %3 = stablehlo.slice %arg0 [0:1, 0:5, 2:4] : (tensor<1x5x4xf32>) -> tensor<1x5x2xf32> + %4 = stablehlo.reshape %3 : (tensor<1x5x2xf32>) -> tensor<1x5x2xf32> + %5 = stablehlo.reshape %4 : (tensor<1x5x2xf32>) -> tensor<1x5x2x1xf32> + %6 = stablehlo.concatenate %2, %5, dim = 3 : (tensor<1x5x2x1xf32>, tensor<1x5x2x1xf32>) -> tensor<1x5x2x2xf32> + %7 = stablehlo.reshape %6 : (tensor<1x5x2x2xf32>) -> tensor<1x5x4xf32> + %8 = stablehlo.slice %7 [0:1, 0:5, 0:4:2] : (tensor<1x5x4xf32>) -> tensor<1x5x2xf32> + %9 = stablehlo.reshape %8 : (tensor<1x5x2xf32>) -> tensor<1x5x2xf32> + %10 = stablehlo.iota dim = 0 : tensor<5xf32> + %11 = stablehlo.broadcast_in_dim %10, dims = [0] : (tensor<5xf32>) -> tensor<5x2xf32> + %12 = stablehlo.broadcast_in_dim %cst, dims = [1] : (tensor<2xf32>) -> tensor<5x2xf32> + %13 = stablehlo.multiply %11, %12 : tensor<5x2xf32> + %14 = stablehlo.cosine %13 : tensor<5x2xf32> + %15 = stablehlo.broadcast_in_dim %14, dims = [1, 2] : (tensor<5x2xf32>) -> tensor<1x5x2xf32> + %16 = stablehlo.multiply %9, %15 : tensor<1x5x2xf32> + %17 = stablehlo.slice %7 [0:1, 0:5, 1:4:2] : (tensor<1x5x4xf32>) -> tensor<1x5x2xf32> + %18 = stablehlo.reshape %17 : (tensor<1x5x2xf32>) -> tensor<1x5x2xf32> + %19 = stablehlo.sine %13 : tensor<5x2xf32> + %20 = stablehlo.broadcast_in_dim %19, dims = [1, 2] : (tensor<5x2xf32>) -> tensor<1x5x2xf32> + %21 = stablehlo.multiply %18, %20 : tensor<1x5x2xf32> + %22 = stablehlo.subtract %16, %21 : tensor<1x5x2xf32> + %23 = stablehlo.reshape %22 : (tensor<1x5x2xf32>) -> tensor<1x5x2x1xf32> + %24 = stablehlo.multiply %9, %20 : tensor<1x5x2xf32> + %25 = stablehlo.multiply %18, %15 : tensor<1x5x2xf32> + %26 = stablehlo.add %24, %25 : tensor<1x5x2xf32> + %27 = stablehlo.reshape %26 : (tensor<1x5x2xf32>) -> tensor<1x5x2x1xf32> + %28 = stablehlo.concatenate %23, %27, dim = 3 : (tensor<1x5x2x1xf32>, tensor<1x5x2x1xf32>) -> tensor<1x5x2x2xf32> + %29 = stablehlo.reshape %28 : (tensor<1x5x2x2xf32>) -> tensor<1x5x4xf32> + %30 = stablehlo.reshape %29 : (tensor<1x5x4xf32>) -> tensor<5x4xf32> + %31 = stablehlo.slice %30 [0:5, 0:4:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %32 = stablehlo.reshape %31 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %33 = stablehlo.slice %30 [0:5, 1:4:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %34 = stablehlo.reshape %33 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %35 = stablehlo.concatenate %32, %34, dim = 1 : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x4xf32> + return %35 : tensor<5x4xf32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.sampleTokens/fn (Tensor, nn.SamplingStrategy, Tensor.Rng) struct { Tensor, Tensor.Rng }_df220299c18ba41b.mlir b/zml/test_data/snapshot/nn.decltest.sampleTokens/fn (Tensor, nn.SamplingStrategy, Tensor.Rng) struct { Tensor, Tensor.Rng }_df220299c18ba41b.mlir new file mode 100644 index 00000000..136c5d23 --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.sampleTokens/fn (Tensor, nn.SamplingStrategy, Tensor.Rng) struct { Tensor, Tensor.Rng }_df220299c18ba41b.mlir @@ -0,0 +1,63 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<2xui64> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}", tf.aliasing_output = 1 : i32}) -> (tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<2xui64> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %cst = stablehlo.constant dense<0xFF800000> : tensor + %cst_0 = stablehlo.constant dense<-1.000000e+00> : tensor + %cst_1 = stablehlo.constant dense<1.1920929E-7> : tensor + %cst_2 = stablehlo.constant dense<0.99999988> : tensor + %cst_3 = stablehlo.constant dense<1.000000e+00> : tensor + %c_4 = stablehlo.constant dense<9> : tensor + %cst_5 = stablehlo.constant dense<5.000000e-01> : tensor + %0 = stablehlo.iota dim = 0 : tensor<4xi32> + %1:2 = "stablehlo.sort"(%arg0, %0) <{dimension = 0 : i64, is_stable = true}> ({ + ^bb0(%arg2: tensor, %arg3: tensor, %arg4: tensor, %arg5: tensor): + %33 = stablehlo.compare GT, %arg2, %arg3, FLOAT : (tensor, tensor) -> tensor + stablehlo.return %33 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + }) {operandSegmentSizes = dense<2> : tensor<1xi32>} : (tensor<4xf32>, tensor<4xi32>) -> (tensor<4xf32>, tensor<4xi32>) + %2 = stablehlo.slice %1#1 [0:4] : (tensor<4xi32>) -> tensor<4xi32> + %3 = stablehlo.reshape %2 : (tensor<4xi32>) -> tensor<4xi32> + %4 = stablehlo.slice %1#0 [0:4] : (tensor<4xf32>) -> tensor<4xf32> + %5 = stablehlo.reshape %4 : (tensor<4xf32>) -> tensor<4xf32> + %6 = stablehlo.broadcast_in_dim %cst_5, dims = [] : (tensor) -> tensor<4xf32> + %7 = stablehlo.multiply %5, %6 : tensor<4xf32> + %output_state, %output = stablehlo.rng_bit_generator %arg1, algorithm = DEFAULT : (tensor<2xui64>) -> (tensor<2xui64>, tensor<4xui32>) + %8 = stablehlo.broadcast_in_dim %c_4, dims = [] : (tensor) -> tensor<4xui32> + %9 = stablehlo.shift_right_logical %output, %8 : tensor<4xui32> + %10 = stablehlo.bitcast_convert %cst_3 : (tensor) -> tensor + %11 = stablehlo.broadcast_in_dim %10, dims = [] : (tensor) -> tensor<4xui32> + %12 = stablehlo.or %9, %11 : tensor<4xui32> + %13 = stablehlo.bitcast_convert %12 : (tensor<4xui32>) -> tensor<4xf32> + %14 = stablehlo.broadcast_in_dim %cst_3, dims = [] : (tensor) -> tensor<4xf32> + %15 = stablehlo.subtract %13, %14 : tensor<4xf32> + %16 = stablehlo.broadcast_in_dim %cst_2, dims = [] : (tensor) -> tensor<4xf32> + %17 = stablehlo.multiply %15, %16 : tensor<4xf32> + %18 = stablehlo.broadcast_in_dim %cst_1, dims = [] : (tensor) -> tensor<4xf32> + %19 = stablehlo.add %17, %18 : tensor<4xf32> + %20 = stablehlo.log %19 : tensor<4xf32> + %21 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<4xf32> + %22 = stablehlo.multiply %20, %21 : tensor<4xf32> + %23 = stablehlo.log %22 : tensor<4xf32> + %24 = stablehlo.multiply %23, %21 : tensor<4xf32> + %25 = stablehlo.add %7, %24 : tensor<4xf32> + %26:2 = stablehlo.reduce(%25 init: %cst), (%0 init: %c) across dimensions = [0] {operandSegmentSizes = dense<2> : tensor<2xi32>} : (tensor<4xf32>, tensor<4xi32>, tensor, tensor) -> (tensor, tensor) + reducer(%arg2: tensor, %arg4: tensor) (%arg3: tensor, %arg5: tensor) { + %33 = stablehlo.compare GT, %arg2, %arg4, FLOAT : (tensor, tensor) -> tensor + %34 = stablehlo.compare NE, %arg2, %arg2, FLOAT : (tensor, tensor) -> tensor + %35 = stablehlo.or %33, %34 : tensor + %36 = stablehlo.select %35, %arg2, %arg4 : tensor, tensor + %37 = stablehlo.compare EQ, %arg2, %arg4, FLOAT : (tensor, tensor) -> tensor + %38 = stablehlo.compare LT, %arg3, %arg5, SIGNED : (tensor, tensor) -> tensor + %39 = stablehlo.and %37, %38 : tensor + %40 = stablehlo.or %35, %39 : tensor + %41 = stablehlo.select %40, %arg3, %arg5 : tensor, tensor + stablehlo.return %36, %41 {operandSegmentSizes = dense<2> : tensor<1xi32>} : tensor, tensor + } + %27 = stablehlo.broadcast_in_dim %26#1, dims = [] : (tensor) -> tensor<1xi32> + %28 = stablehlo.reshape %27 : (tensor<1xi32>) -> tensor + %29 = stablehlo.reshape %28 : (tensor) -> tensor<1xi32> + %30 = stablehlo.reshape %29 : (tensor<1xi32>) -> tensor + %31 = stablehlo.dynamic_slice %3, %30, sizes = [1] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<4xi32>, tensor) -> tensor<1xi32> + %32 = stablehlo.reshape %31 : (tensor<1xi32>) -> tensor + return %32, %output_state : tensor, tensor<2xui64> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.sampleTokensDynamic/fn (Tensor, nn.DynamicSamplingStrategy) [2]Tensor_23acf0b9f0bb3fab.mlir b/zml/test_data/snapshot/nn.decltest.sampleTokensDynamic/fn (Tensor, nn.DynamicSamplingStrategy) [2]Tensor_23acf0b9f0bb3fab.mlir new file mode 100644 index 00000000..4f69d23e --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.sampleTokensDynamic/fn (Tensor, nn.DynamicSamplingStrategy) [2]Tensor_23acf0b9f0bb3fab.mlir @@ -0,0 +1,60 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<4xbf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg4: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<4xbf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %cst_0 = stablehlo.constant dense<0xFF80> : tensor + %0 = stablehlo.iota dim = 0 : tensor<4xi32> + %1 = stablehlo.broadcast_in_dim %arg1, dims = [] : (tensor) -> tensor<4xi32> + %2 = stablehlo.compare GE, %0, %1, SIGNED : (tensor<4xi32>, tensor<4xi32>) -> tensor<4xi1> + %3 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<4xbf16> + %4:2 = "stablehlo.sort"(%arg0, %0) <{dimension = 0 : i64, is_stable = true}> ({ + ^bb0(%arg5: tensor, %arg6: tensor, %arg7: tensor, %arg8: tensor): + %36 = stablehlo.compare GT, %arg5, %arg6, FLOAT : (tensor, tensor) -> tensor + stablehlo.return %36 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + }) {operandSegmentSizes = dense<2> : tensor<1xi32>} : (tensor<4xbf16>, tensor<4xi32>) -> (tensor<4xbf16>, tensor<4xi32>) + %5 = stablehlo.select %2, %3, %4#0 : tensor<4xi1>, tensor<4xbf16> + %6 = stablehlo.broadcast_in_dim %arg2, dims = [] : (tensor) -> tensor<4xbf16> + %7 = stablehlo.multiply %5, %6 : tensor<4xbf16> + %8 = stablehlo.reduce(%7 init: %cst_0) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<4xbf16>, tensor) -> tensor + reducer(%arg5: tensor, %arg6: tensor) { + %36 = stablehlo.maximum %arg6, %arg5 : tensor + stablehlo.return %36 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %9 = stablehlo.broadcast_in_dim %8, dims = [] : (tensor) -> tensor<1xbf16> + %10 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<1xbf16> + %11 = stablehlo.compare GT, %9, %10, FLOAT : (tensor<1xbf16>, tensor<1xbf16>) -> tensor<1xi1> + %12 = stablehlo.broadcast_in_dim %11, dims = [0] : (tensor<1xi1>) -> tensor<4xi1> + %13 = stablehlo.broadcast_in_dim %9, dims = [0] : (tensor<1xbf16>) -> tensor<4xbf16> + %14 = stablehlo.subtract %7, %13 : tensor<4xbf16> + %15 = stablehlo.exponential %14 : tensor<4xbf16> + %16 = stablehlo.reduce(%15 init: %cst) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<4xbf16>, tensor) -> tensor + reducer(%arg5: tensor, %arg6: tensor) { + %36 = stablehlo.add %arg6, %arg5 : tensor + stablehlo.return %36 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %17 = stablehlo.broadcast_in_dim %16, dims = [] : (tensor) -> tensor<1xbf16> + %18 = stablehlo.broadcast_in_dim %17, dims = [0] : (tensor<1xbf16>) -> tensor<4xbf16> + %19 = stablehlo.divide %15, %18 : tensor<4xbf16> + %20 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<4xbf16> + %21 = stablehlo.select %12, %19, %20 : tensor<4xi1>, tensor<4xbf16> + %22 = "stablehlo.reduce_window"(%21, %cst) <{base_dilations = array, padding = dense<[[3, 0]]> : tensor<1x2xi64>, window_dilations = array, window_dimensions = array, window_strides = array}> ({ + ^bb0(%arg5: tensor, %arg6: tensor): + %36 = stablehlo.add %arg5, %arg6 : tensor + stablehlo.return %36 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + }) {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<4xbf16>, tensor) -> tensor<4xbf16> + %23 = stablehlo.broadcast_in_dim %arg3, dims = [] : (tensor) -> tensor<4xbf16> + %24 = stablehlo.compare LE, %22, %23, FLOAT : (tensor<4xbf16>, tensor<4xbf16>) -> tensor<4xi1> + %25 = stablehlo.slice %21 [0:1] : (tensor<4xbf16>) -> tensor<1xbf16> + %26 = stablehlo.reshape %25 : (tensor<1xbf16>) -> tensor<1xbf16> + %27 = stablehlo.broadcast_in_dim %arg4, dims = [] : (tensor) -> tensor<1xbf16> + %28 = stablehlo.multiply %26, %27 : tensor<1xbf16> + %29 = stablehlo.broadcast_in_dim %28, dims = [0] : (tensor<1xbf16>) -> tensor<4xbf16> + %30 = stablehlo.compare GE, %21, %29, FLOAT : (tensor<4xbf16>, tensor<4xbf16>) -> tensor<4xi1> + %31 = stablehlo.and %24, %30 : tensor<4xi1> + %32 = stablehlo.broadcast_in_dim %c, dims = [] : (tensor) -> tensor<4xi32> + %33 = stablehlo.compare EQ, %0, %32, SIGNED : (tensor<4xi32>, tensor<4xi32>) -> tensor<4xi1> + %34 = stablehlo.or %31, %33 : tensor<4xi1> + %35 = stablehlo.select %34, %7, %3 : tensor<4xi1>, tensor<4xbf16> + return %35, %4#1 : tensor<4xbf16>, tensor<4xi32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.sampleTokensDynamic/fn (Tensor, nn.DynamicSamplingStrategy) [2]Tensor_63f53aa22b7507cf.mlir b/zml/test_data/snapshot/nn.decltest.sampleTokensDynamic/fn (Tensor, nn.DynamicSamplingStrategy) [2]Tensor_63f53aa22b7507cf.mlir new file mode 100644 index 00000000..76a9b394 --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.sampleTokensDynamic/fn (Tensor, nn.DynamicSamplingStrategy) [2]Tensor_63f53aa22b7507cf.mlir @@ -0,0 +1,60 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg4: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %cst_0 = stablehlo.constant dense<0xFF800000> : tensor + %0 = stablehlo.iota dim = 0 : tensor<4xi32> + %1 = stablehlo.broadcast_in_dim %arg1, dims = [] : (tensor) -> tensor<4xi32> + %2 = stablehlo.compare GE, %0, %1, SIGNED : (tensor<4xi32>, tensor<4xi32>) -> tensor<4xi1> + %3 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<4xf32> + %4:2 = "stablehlo.sort"(%arg0, %0) <{dimension = 0 : i64, is_stable = true}> ({ + ^bb0(%arg5: tensor, %arg6: tensor, %arg7: tensor, %arg8: tensor): + %36 = stablehlo.compare GT, %arg5, %arg6, FLOAT : (tensor, tensor) -> tensor + stablehlo.return %36 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + }) {operandSegmentSizes = dense<2> : tensor<1xi32>} : (tensor<4xf32>, tensor<4xi32>) -> (tensor<4xf32>, tensor<4xi32>) + %5 = stablehlo.select %2, %3, %4#0 : tensor<4xi1>, tensor<4xf32> + %6 = stablehlo.broadcast_in_dim %arg2, dims = [] : (tensor) -> tensor<4xf32> + %7 = stablehlo.multiply %5, %6 : tensor<4xf32> + %8 = stablehlo.reduce(%7 init: %cst_0) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<4xf32>, tensor) -> tensor + reducer(%arg5: tensor, %arg6: tensor) { + %36 = stablehlo.maximum %arg6, %arg5 : tensor + stablehlo.return %36 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %9 = stablehlo.broadcast_in_dim %8, dims = [] : (tensor) -> tensor<1xf32> + %10 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<1xf32> + %11 = stablehlo.compare GT, %9, %10, FLOAT : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xi1> + %12 = stablehlo.broadcast_in_dim %11, dims = [0] : (tensor<1xi1>) -> tensor<4xi1> + %13 = stablehlo.broadcast_in_dim %9, dims = [0] : (tensor<1xf32>) -> tensor<4xf32> + %14 = stablehlo.subtract %7, %13 : tensor<4xf32> + %15 = stablehlo.exponential %14 : tensor<4xf32> + %16 = stablehlo.reduce(%15 init: %cst) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<4xf32>, tensor) -> tensor + reducer(%arg5: tensor, %arg6: tensor) { + %36 = stablehlo.add %arg6, %arg5 : tensor + stablehlo.return %36 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %17 = stablehlo.broadcast_in_dim %16, dims = [] : (tensor) -> tensor<1xf32> + %18 = stablehlo.broadcast_in_dim %17, dims = [0] : (tensor<1xf32>) -> tensor<4xf32> + %19 = stablehlo.divide %15, %18 : tensor<4xf32> + %20 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<4xf32> + %21 = stablehlo.select %12, %19, %20 : tensor<4xi1>, tensor<4xf32> + %22 = "stablehlo.reduce_window"(%21, %cst) <{base_dilations = array, padding = dense<[[3, 0]]> : tensor<1x2xi64>, window_dilations = array, window_dimensions = array, window_strides = array}> ({ + ^bb0(%arg5: tensor, %arg6: tensor): + %36 = stablehlo.add %arg5, %arg6 : tensor + stablehlo.return %36 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + }) {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<4xf32>, tensor) -> tensor<4xf32> + %23 = stablehlo.broadcast_in_dim %arg3, dims = [] : (tensor) -> tensor<4xf32> + %24 = stablehlo.compare LE, %22, %23, FLOAT : (tensor<4xf32>, tensor<4xf32>) -> tensor<4xi1> + %25 = stablehlo.slice %21 [0:1] : (tensor<4xf32>) -> tensor<1xf32> + %26 = stablehlo.reshape %25 : (tensor<1xf32>) -> tensor<1xf32> + %27 = stablehlo.broadcast_in_dim %arg4, dims = [] : (tensor) -> tensor<1xf32> + %28 = stablehlo.multiply %26, %27 : tensor<1xf32> + %29 = stablehlo.broadcast_in_dim %28, dims = [0] : (tensor<1xf32>) -> tensor<4xf32> + %30 = stablehlo.compare GE, %21, %29, FLOAT : (tensor<4xf32>, tensor<4xf32>) -> tensor<4xi1> + %31 = stablehlo.and %24, %30 : tensor<4xi1> + %32 = stablehlo.broadcast_in_dim %c, dims = [] : (tensor) -> tensor<4xi32> + %33 = stablehlo.compare EQ, %0, %32, SIGNED : (tensor<4xi32>, tensor<4xi32>) -> tensor<4xi1> + %34 = stablehlo.or %31, %33 : tensor<4xi1> + %35 = stablehlo.select %34, %7, %3 : tensor<4xi1>, tensor<4xf32> + return %35, %4#1 : tensor<4xf32>, tensor<4xi32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_91b4e3e69b5098c.mlir b/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_91b4e3e69b5098c.mlir new file mode 100644 index 00000000..1d6d71e4 --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_91b4e3e69b5098c.mlir @@ -0,0 +1,9 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor<512x512xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %cst_0 = stablehlo.constant dense<1.000000e+00> : tensor + %c = stablehlo.constant dense<512> : tensor<2xi64> + %0 = stablehlo.rng %cst, %cst_0, %c, distribution = NORMAL : (tensor, tensor, tensor<2xi64>) -> tensor<512x512xf32> + return %0 : tensor<512x512xf32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_9dce10a188fca6fa.mlir b/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_9dce10a188fca6fa.mlir new file mode 100644 index 00000000..88c829e8 --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_9dce10a188fca6fa.mlir @@ -0,0 +1,9 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor<1x10x512x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %cst_0 = stablehlo.constant dense<1.000000e+00> : tensor + %c = stablehlo.constant dense<[1, 10, 512, 64]> : tensor<4xi64> + %0 = stablehlo.rng %cst, %cst_0, %c, distribution = NORMAL : (tensor, tensor, tensor<4xi64>) -> tensor<1x10x512x64xf32> + return %0 : tensor<1x10x512x64xf32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Tensor, Tensor, Tensor, nn.SdpaOpts) Tensor_1baf90feb653a9f5.mlir b/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Tensor, Tensor, Tensor, nn.SdpaOpts) Tensor_1baf90feb653a9f5.mlir new file mode 100644 index 00000000..6290bfee --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Tensor, Tensor, Tensor, nn.SdpaOpts) Tensor_1baf90feb653a9f5.mlir @@ -0,0 +1,36 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x10x512x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<1x10x512x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<1x10x512x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor<512x512xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x10x512x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %cst_0 = stablehlo.constant dense<0xFF800000> : tensor + %cst_1 = stablehlo.constant dense<1.250000e-01> : tensor + %0 = stablehlo.broadcast_in_dim %cst_1, dims = [] : (tensor) -> tensor<1x10x512x64xf32> + %1 = stablehlo.multiply %arg1, %0 : tensor<1x10x512x64xf32> + %2 = stablehlo.dot_general %arg0, %1, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x10x512x64xf32>, tensor<1x10x512x64xf32>) -> tensor<1x10x512x512xf32> + %3 = stablehlo.broadcast_in_dim %arg3, dims = [2, 3] : (tensor<512x512xf32>) -> tensor<1x10x512x512xf32> + %4 = stablehlo.add %2, %3 : tensor<1x10x512x512xf32> + %5 = stablehlo.reduce(%4 init: %cst_0) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x512x512xf32>, tensor) -> tensor<1x10x512xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %20 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %20 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %6 = stablehlo.broadcast_in_dim %5, dims = [0, 1, 2] : (tensor<1x10x512xf32>) -> tensor<1x10x512x1xf32> + %7 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<1x10x512x1xf32> + %8 = stablehlo.compare GT, %6, %7, FLOAT : (tensor<1x10x512x1xf32>, tensor<1x10x512x1xf32>) -> tensor<1x10x512x1xi1> + %9 = stablehlo.broadcast_in_dim %8, dims = [0, 1, 2, 3] : (tensor<1x10x512x1xi1>) -> tensor<1x10x512x512xi1> + %10 = stablehlo.broadcast_in_dim %6, dims = [0, 1, 2, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x10x512x512xf32> + %11 = stablehlo.subtract %4, %10 : tensor<1x10x512x512xf32> + %12 = stablehlo.exponential %11 : tensor<1x10x512x512xf32> + %13 = stablehlo.reduce(%12 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x512x512xf32>, tensor) -> tensor<1x10x512xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %20 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %20 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %14 = stablehlo.broadcast_in_dim %13, dims = [0, 1, 2] : (tensor<1x10x512xf32>) -> tensor<1x10x512x1xf32> + %15 = stablehlo.broadcast_in_dim %14, dims = [0, 1, 2, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x10x512x512xf32> + %16 = stablehlo.divide %12, %15 : tensor<1x10x512x512xf32> + %17 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<1x10x512x512xf32> + %18 = stablehlo.select %9, %16, %17 : tensor<1x10x512x512xi1>, tensor<1x10x512x512xf32> + %19 = stablehlo.dot_general %18, %arg2, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [2], precision = [DEFAULT, DEFAULT] : (tensor<1x10x512x512xf32>, tensor<1x10x512x64xf32>) -> tensor<1x10x512x64xf32> + return %19 : tensor<1x10x512x64xf32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_3325120933b1fbb6.mlir b/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_3325120933b1fbb6.mlir new file mode 100644 index 00000000..604112d4 --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_3325120933b1fbb6.mlir @@ -0,0 +1,288 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x10x512x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<1x10x512x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<1x10x512x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor<512x512xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x10x512x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<256> : tensor + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %c_0 = stablehlo.constant dense<3> : tensor + %c_1 = stablehlo.constant dense<2> : tensor + %c_2 = stablehlo.constant dense<1> : tensor + %cst_3 = stablehlo.constant dense<-1.000000e+16> : tensor + %cst_4 = stablehlo.constant dense<0xFF800000> : tensor + %cst_5 = stablehlo.constant dense<1.250000e-01> : tensor + %c_6 = stablehlo.constant dense<128> : tensor + %c_7 = stablehlo.constant dense<0> : tensor + %0 = stablehlo.dynamic_slice %arg0, %c_7, %c_7, %c_7, %c_7, sizes = [1, 10, 256, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x256x64xf32> + %1 = stablehlo.multiply %c_7, %c_6 : tensor + %2 = stablehlo.dynamic_slice %arg1, %c_7, %c_7, %1, %c_7, sizes = [1, 10, 128, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x128x64xf32> + %3 = stablehlo.broadcast_in_dim %cst_5, dims = [] : (tensor) -> tensor<1x10x128x64xf32> + %4 = stablehlo.multiply %2, %3 : tensor<1x10x128x64xf32> + %5 = stablehlo.dot_general %0, %4, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x64xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x128xf32> + %6 = stablehlo.dynamic_slice %arg3, %c_7, %c_7, sizes = [256, 512] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<512x512xf32>, tensor, tensor) -> tensor<256x512xf32> + %7 = stablehlo.dynamic_slice %6, %c_7, %1, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %8 = stablehlo.broadcast_in_dim %7, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %9 = stablehlo.add %5, %8 : tensor<1x10x256x128xf32> + %10 = stablehlo.reduce(%9 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %11 = stablehlo.broadcast_in_dim %10, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %12 = stablehlo.broadcast_in_dim %cst_3, dims = [] : (tensor) -> tensor<1x10x256x1xf32> + %13 = stablehlo.maximum %11, %12 : tensor<1x10x256x1xf32> + %14 = stablehlo.broadcast_in_dim %13, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %15 = stablehlo.subtract %9, %14 : tensor<1x10x256x128xf32> + %16 = stablehlo.exponential %15 : tensor<1x10x256x128xf32> + %17 = stablehlo.dynamic_slice %arg2, %c_7, %c_7, %1, %c_7, sizes = [1, 10, 128, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x128x64xf32> + %18 = stablehlo.dot_general %16, %17, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [2], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x64xf32> + %19 = stablehlo.multiply %c_2, %c_6 : tensor + %20 = stablehlo.dynamic_slice %arg1, %c_7, %c_7, %19, %c_7, sizes = [1, 10, 128, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x128x64xf32> + %21 = stablehlo.multiply %20, %3 : tensor<1x10x128x64xf32> + %22 = stablehlo.dot_general %0, %21, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x64xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x128xf32> + %23 = stablehlo.dynamic_slice %6, %c_7, %19, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %24 = stablehlo.broadcast_in_dim %23, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %25 = stablehlo.add %22, %24 : tensor<1x10x256x128xf32> + %26 = stablehlo.reduce(%25 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %27 = stablehlo.broadcast_in_dim %26, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %28 = stablehlo.maximum %27, %12 : tensor<1x10x256x1xf32> + %29 = stablehlo.maximum %13, %28 : tensor<1x10x256x1xf32> + %30 = stablehlo.subtract %13, %29 : tensor<1x10x256x1xf32> + %31 = stablehlo.exponential %30 : tensor<1x10x256x1xf32> + %32 = stablehlo.broadcast_in_dim %31, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %33 = stablehlo.multiply %18, %32 : tensor<1x10x256x64xf32> + %34 = stablehlo.broadcast_in_dim %28, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %35 = stablehlo.subtract %25, %34 : tensor<1x10x256x128xf32> + %36 = stablehlo.exponential %35 : tensor<1x10x256x128xf32> + %37 = stablehlo.dynamic_slice %arg2, %c_7, %c_7, %19, %c_7, sizes = [1, 10, 128, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x128x64xf32> + %38 = stablehlo.dot_general %36, %37, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [2], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x64xf32> + %39 = stablehlo.subtract %28, %29 : tensor<1x10x256x1xf32> + %40 = stablehlo.exponential %39 : tensor<1x10x256x1xf32> + %41 = stablehlo.broadcast_in_dim %40, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %42 = stablehlo.multiply %38, %41 : tensor<1x10x256x64xf32> + %43 = stablehlo.add %33, %42 : tensor<1x10x256x64xf32> + %44 = stablehlo.multiply %c_1, %c_6 : tensor + %45 = stablehlo.dynamic_slice %arg1, %c_7, %c_7, %44, %c_7, sizes = [1, 10, 128, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x128x64xf32> + %46 = stablehlo.multiply %45, %3 : tensor<1x10x128x64xf32> + %47 = stablehlo.dot_general %0, %46, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x64xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x128xf32> + %48 = stablehlo.dynamic_slice %6, %c_7, %44, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %49 = stablehlo.broadcast_in_dim %48, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %50 = stablehlo.add %47, %49 : tensor<1x10x256x128xf32> + %51 = stablehlo.reduce(%50 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %52 = stablehlo.broadcast_in_dim %51, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %53 = stablehlo.maximum %52, %12 : tensor<1x10x256x1xf32> + %54 = stablehlo.maximum %29, %53 : tensor<1x10x256x1xf32> + %55 = stablehlo.subtract %29, %54 : tensor<1x10x256x1xf32> + %56 = stablehlo.exponential %55 : tensor<1x10x256x1xf32> + %57 = stablehlo.broadcast_in_dim %56, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %58 = stablehlo.multiply %43, %57 : tensor<1x10x256x64xf32> + %59 = stablehlo.broadcast_in_dim %53, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %60 = stablehlo.subtract %50, %59 : tensor<1x10x256x128xf32> + %61 = stablehlo.exponential %60 : tensor<1x10x256x128xf32> + %62 = stablehlo.dynamic_slice %arg2, %c_7, %c_7, %44, %c_7, sizes = [1, 10, 128, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x128x64xf32> + %63 = stablehlo.dot_general %61, %62, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [2], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x64xf32> + %64 = stablehlo.subtract %53, %54 : tensor<1x10x256x1xf32> + %65 = stablehlo.exponential %64 : tensor<1x10x256x1xf32> + %66 = stablehlo.broadcast_in_dim %65, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %67 = stablehlo.multiply %63, %66 : tensor<1x10x256x64xf32> + %68 = stablehlo.add %58, %67 : tensor<1x10x256x64xf32> + %69 = stablehlo.multiply %c_0, %c_6 : tensor + %70 = stablehlo.dynamic_slice %arg1, %c_7, %c_7, %69, %c_7, sizes = [1, 10, 128, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x128x64xf32> + %71 = stablehlo.multiply %70, %3 : tensor<1x10x128x64xf32> + %72 = stablehlo.dot_general %0, %71, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x64xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x128xf32> + %73 = stablehlo.dynamic_slice %6, %c_7, %69, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %74 = stablehlo.broadcast_in_dim %73, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %75 = stablehlo.add %72, %74 : tensor<1x10x256x128xf32> + %76 = stablehlo.reduce(%75 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %77 = stablehlo.broadcast_in_dim %76, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %78 = stablehlo.maximum %77, %12 : tensor<1x10x256x1xf32> + %79 = stablehlo.maximum %54, %78 : tensor<1x10x256x1xf32> + %80 = stablehlo.subtract %54, %79 : tensor<1x10x256x1xf32> + %81 = stablehlo.exponential %80 : tensor<1x10x256x1xf32> + %82 = stablehlo.broadcast_in_dim %81, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %83 = stablehlo.multiply %68, %82 : tensor<1x10x256x64xf32> + %84 = stablehlo.broadcast_in_dim %78, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %85 = stablehlo.subtract %75, %84 : tensor<1x10x256x128xf32> + %86 = stablehlo.exponential %85 : tensor<1x10x256x128xf32> + %87 = stablehlo.dynamic_slice %arg2, %c_7, %c_7, %69, %c_7, sizes = [1, 10, 128, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x128x64xf32> + %88 = stablehlo.dot_general %86, %87, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [2], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x64xf32> + %89 = stablehlo.subtract %78, %79 : tensor<1x10x256x1xf32> + %90 = stablehlo.exponential %89 : tensor<1x10x256x1xf32> + %91 = stablehlo.broadcast_in_dim %90, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %92 = stablehlo.multiply %88, %91 : tensor<1x10x256x64xf32> + %93 = stablehlo.add %83, %92 : tensor<1x10x256x64xf32> + %94 = stablehlo.reduce(%16 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %95 = stablehlo.broadcast_in_dim %94, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %96 = stablehlo.multiply %95, %31 : tensor<1x10x256x1xf32> + %97 = stablehlo.reduce(%36 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %98 = stablehlo.broadcast_in_dim %97, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %99 = stablehlo.multiply %98, %40 : tensor<1x10x256x1xf32> + %100 = stablehlo.add %96, %99 : tensor<1x10x256x1xf32> + %101 = stablehlo.multiply %100, %56 : tensor<1x10x256x1xf32> + %102 = stablehlo.reduce(%61 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %103 = stablehlo.broadcast_in_dim %102, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %104 = stablehlo.multiply %103, %65 : tensor<1x10x256x1xf32> + %105 = stablehlo.add %101, %104 : tensor<1x10x256x1xf32> + %106 = stablehlo.multiply %105, %81 : tensor<1x10x256x1xf32> + %107 = stablehlo.reduce(%86 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %108 = stablehlo.broadcast_in_dim %107, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %109 = stablehlo.multiply %108, %90 : tensor<1x10x256x1xf32> + %110 = stablehlo.add %106, %109 : tensor<1x10x256x1xf32> + %111 = stablehlo.broadcast_in_dim %110, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %112 = stablehlo.divide %93, %111 : tensor<1x10x256x64xf32> + %113 = stablehlo.dynamic_slice %arg0, %c_7, %c_7, %c, %c_7, sizes = [1, 10, 256, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x256x64xf32> + %114 = stablehlo.dot_general %113, %4, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x64xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x128xf32> + %115 = stablehlo.dynamic_slice %arg3, %c, %c_7, sizes = [256, 512] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<512x512xf32>, tensor, tensor) -> tensor<256x512xf32> + %116 = stablehlo.dynamic_slice %115, %c_7, %1, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %117 = stablehlo.broadcast_in_dim %116, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %118 = stablehlo.add %114, %117 : tensor<1x10x256x128xf32> + %119 = stablehlo.reduce(%118 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %120 = stablehlo.broadcast_in_dim %119, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %121 = stablehlo.maximum %120, %12 : tensor<1x10x256x1xf32> + %122 = stablehlo.broadcast_in_dim %121, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %123 = stablehlo.subtract %118, %122 : tensor<1x10x256x128xf32> + %124 = stablehlo.exponential %123 : tensor<1x10x256x128xf32> + %125 = stablehlo.dot_general %124, %17, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [2], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x64xf32> + %126 = stablehlo.dot_general %113, %21, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x64xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x128xf32> + %127 = stablehlo.dynamic_slice %115, %c_7, %19, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %128 = stablehlo.broadcast_in_dim %127, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %129 = stablehlo.add %126, %128 : tensor<1x10x256x128xf32> + %130 = stablehlo.reduce(%129 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %131 = stablehlo.broadcast_in_dim %130, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %132 = stablehlo.maximum %131, %12 : tensor<1x10x256x1xf32> + %133 = stablehlo.maximum %121, %132 : tensor<1x10x256x1xf32> + %134 = stablehlo.subtract %121, %133 : tensor<1x10x256x1xf32> + %135 = stablehlo.exponential %134 : tensor<1x10x256x1xf32> + %136 = stablehlo.broadcast_in_dim %135, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %137 = stablehlo.multiply %125, %136 : tensor<1x10x256x64xf32> + %138 = stablehlo.broadcast_in_dim %132, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %139 = stablehlo.subtract %129, %138 : tensor<1x10x256x128xf32> + %140 = stablehlo.exponential %139 : tensor<1x10x256x128xf32> + %141 = stablehlo.dot_general %140, %37, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [2], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x64xf32> + %142 = stablehlo.subtract %132, %133 : tensor<1x10x256x1xf32> + %143 = stablehlo.exponential %142 : tensor<1x10x256x1xf32> + %144 = stablehlo.broadcast_in_dim %143, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %145 = stablehlo.multiply %141, %144 : tensor<1x10x256x64xf32> + %146 = stablehlo.add %137, %145 : tensor<1x10x256x64xf32> + %147 = stablehlo.dot_general %113, %46, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x64xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x128xf32> + %148 = stablehlo.dynamic_slice %115, %c_7, %44, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %149 = stablehlo.broadcast_in_dim %148, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %150 = stablehlo.add %147, %149 : tensor<1x10x256x128xf32> + %151 = stablehlo.reduce(%150 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %152 = stablehlo.broadcast_in_dim %151, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %153 = stablehlo.maximum %152, %12 : tensor<1x10x256x1xf32> + %154 = stablehlo.maximum %133, %153 : tensor<1x10x256x1xf32> + %155 = stablehlo.subtract %133, %154 : tensor<1x10x256x1xf32> + %156 = stablehlo.exponential %155 : tensor<1x10x256x1xf32> + %157 = stablehlo.broadcast_in_dim %156, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %158 = stablehlo.multiply %146, %157 : tensor<1x10x256x64xf32> + %159 = stablehlo.broadcast_in_dim %153, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %160 = stablehlo.subtract %150, %159 : tensor<1x10x256x128xf32> + %161 = stablehlo.exponential %160 : tensor<1x10x256x128xf32> + %162 = stablehlo.dot_general %161, %62, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [2], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x64xf32> + %163 = stablehlo.subtract %153, %154 : tensor<1x10x256x1xf32> + %164 = stablehlo.exponential %163 : tensor<1x10x256x1xf32> + %165 = stablehlo.broadcast_in_dim %164, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %166 = stablehlo.multiply %162, %165 : tensor<1x10x256x64xf32> + %167 = stablehlo.add %158, %166 : tensor<1x10x256x64xf32> + %168 = stablehlo.dot_general %113, %71, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x64xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x128xf32> + %169 = stablehlo.dynamic_slice %115, %c_7, %69, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %170 = stablehlo.broadcast_in_dim %169, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %171 = stablehlo.add %168, %170 : tensor<1x10x256x128xf32> + %172 = stablehlo.reduce(%171 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %173 = stablehlo.broadcast_in_dim %172, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %174 = stablehlo.maximum %173, %12 : tensor<1x10x256x1xf32> + %175 = stablehlo.maximum %154, %174 : tensor<1x10x256x1xf32> + %176 = stablehlo.subtract %154, %175 : tensor<1x10x256x1xf32> + %177 = stablehlo.exponential %176 : tensor<1x10x256x1xf32> + %178 = stablehlo.broadcast_in_dim %177, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %179 = stablehlo.multiply %167, %178 : tensor<1x10x256x64xf32> + %180 = stablehlo.broadcast_in_dim %174, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %181 = stablehlo.subtract %171, %180 : tensor<1x10x256x128xf32> + %182 = stablehlo.exponential %181 : tensor<1x10x256x128xf32> + %183 = stablehlo.dot_general %182, %87, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [2], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x10x128x64xf32>) -> tensor<1x10x256x64xf32> + %184 = stablehlo.subtract %174, %175 : tensor<1x10x256x1xf32> + %185 = stablehlo.exponential %184 : tensor<1x10x256x1xf32> + %186 = stablehlo.broadcast_in_dim %185, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %187 = stablehlo.multiply %183, %186 : tensor<1x10x256x64xf32> + %188 = stablehlo.add %179, %187 : tensor<1x10x256x64xf32> + %189 = stablehlo.reduce(%124 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %190 = stablehlo.broadcast_in_dim %189, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %191 = stablehlo.multiply %190, %135 : tensor<1x10x256x1xf32> + %192 = stablehlo.reduce(%140 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %193 = stablehlo.broadcast_in_dim %192, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %194 = stablehlo.multiply %193, %143 : tensor<1x10x256x1xf32> + %195 = stablehlo.add %191, %194 : tensor<1x10x256x1xf32> + %196 = stablehlo.multiply %195, %156 : tensor<1x10x256x1xf32> + %197 = stablehlo.reduce(%161 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %198 = stablehlo.broadcast_in_dim %197, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %199 = stablehlo.multiply %198, %164 : tensor<1x10x256x1xf32> + %200 = stablehlo.add %196, %199 : tensor<1x10x256x1xf32> + %201 = stablehlo.multiply %200, %177 : tensor<1x10x256x1xf32> + %202 = stablehlo.reduce(%182 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %209 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %209 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %203 = stablehlo.broadcast_in_dim %202, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %204 = stablehlo.multiply %203, %185 : tensor<1x10x256x1xf32> + %205 = stablehlo.add %201, %204 : tensor<1x10x256x1xf32> + %206 = stablehlo.broadcast_in_dim %205, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %207 = stablehlo.divide %188, %206 : tensor<1x10x256x64xf32> + %208 = stablehlo.concatenate %112, %207, dim = 2 : (tensor<1x10x256x64xf32>, tensor<1x10x256x64xf32>) -> tensor<1x10x512x64xf32> + return %208 : tensor<1x10x512x64xf32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_b2d9d9c8840e850.mlir b/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_b2d9d9c8840e850.mlir new file mode 100644 index 00000000..e392edc4 --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.sdpaMemEfficient/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_b2d9d9c8840e850.mlir @@ -0,0 +1,122 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x10x512x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<1x10x512x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<1x10x512x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor<512x512xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x10x512x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<1> : tensor + %cst = stablehlo.constant dense<-1.000000e+16> : tensor + %cst_0 = stablehlo.constant dense<1.250000e-01> : tensor + %c_1 = stablehlo.constant dense<32> : tensor + %c_2 = stablehlo.constant dense<16> : tensor + %cst_3 = stablehlo.constant dense<0xFF800000> : tensor + %cst_4 = stablehlo.constant dense<0.000000e+00> : tensor + %c_5 = stablehlo.constant dense<256> : tensor + %c_6 = stablehlo.constant dense<0> : tensor + %0 = stablehlo.dynamic_slice %arg0, %c_6, %c_6, %c_6, %c_6, sizes = [1, 10, 256, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x256x64xf32> + %1 = stablehlo.dynamic_slice %arg3, %c_6, %c_6, sizes = [256, 512] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<512x512xf32>, tensor, tensor) -> tensor<256x512xf32> + %2 = stablehlo.dynamic_slice %arg0, %c_6, %c_6, %c_5, %c_6, sizes = [1, 10, 256, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x256x64xf32> + %3 = stablehlo.dynamic_slice %arg3, %c_5, %c_6, sizes = [256, 512] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<512x512xf32>, tensor, tensor) -> tensor<256x512xf32> + %4 = stablehlo.broadcast_in_dim %cst_4, dims = [] : (tensor) -> tensor<1x10x256x64xf32> + %5 = stablehlo.broadcast_in_dim %cst_4, dims = [] : (tensor) -> tensor<1x10x256x1xf32> + %6 = stablehlo.broadcast_in_dim %cst_3, dims = [] : (tensor) -> tensor<1x10x256x1xf32> + %7:4 = stablehlo.while(%iterArg = %4, %iterArg_7 = %5, %iterArg_8 = %6, %iterArg_9 = %c_6) : tensor<1x10x256x64xf32>, tensor<1x10x256x1xf32>, tensor<1x10x256x1xf32>, tensor attributes {operandSegmentSizes = dense<4> : tensor<1xi32>} + cond { + %14 = stablehlo.compare LT, %iterArg_9, %c_2, SIGNED : (tensor, tensor) -> tensor + stablehlo.return %14 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } do { + %14 = stablehlo.multiply %iterArg_9, %c_1 : tensor + %15 = stablehlo.dynamic_slice %arg1, %c_6, %c_6, %14, %c_6, sizes = [1, 10, 32, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x32x64xf32> + %16 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<1x10x32x64xf32> + %17 = stablehlo.multiply %15, %16 : tensor<1x10x32x64xf32> + %18 = stablehlo.dot_general %0, %17, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x64xf32>, tensor<1x10x32x64xf32>) -> tensor<1x10x256x32xf32> + %19 = stablehlo.dynamic_slice %1, %c_6, %14, sizes = [256, 32] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x32xf32> + %20 = stablehlo.broadcast_in_dim %19, dims = [2, 3] : (tensor<256x32xf32>) -> tensor<1x10x256x32xf32> + %21 = stablehlo.add %18, %20 : tensor<1x10x256x32xf32> + %22 = stablehlo.reduce(%21 init: %cst_3) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x32xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %47 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %47 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %23 = stablehlo.broadcast_in_dim %22, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %24 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<1x10x256x1xf32> + %25 = stablehlo.maximum %23, %24 : tensor<1x10x256x1xf32> + %26 = stablehlo.maximum %iterArg_8, %25 : tensor<1x10x256x1xf32> + %27 = stablehlo.subtract %iterArg_8, %26 : tensor<1x10x256x1xf32> + %28 = stablehlo.exponential %27 : tensor<1x10x256x1xf32> + %29 = stablehlo.broadcast_in_dim %28, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %30 = stablehlo.multiply %iterArg, %29 : tensor<1x10x256x64xf32> + %31 = stablehlo.broadcast_in_dim %25, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x32xf32> + %32 = stablehlo.subtract %21, %31 : tensor<1x10x256x32xf32> + %33 = stablehlo.exponential %32 : tensor<1x10x256x32xf32> + %34 = stablehlo.dynamic_slice %arg2, %c_6, %c_6, %14, %c_6, sizes = [1, 10, 32, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x32x64xf32> + %35 = stablehlo.dot_general %33, %34, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [2], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x32xf32>, tensor<1x10x32x64xf32>) -> tensor<1x10x256x64xf32> + %36 = stablehlo.subtract %25, %26 : tensor<1x10x256x1xf32> + %37 = stablehlo.exponential %36 : tensor<1x10x256x1xf32> + %38 = stablehlo.broadcast_in_dim %37, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %39 = stablehlo.multiply %35, %38 : tensor<1x10x256x64xf32> + %40 = stablehlo.add %30, %39 : tensor<1x10x256x64xf32> + %41 = stablehlo.multiply %iterArg_7, %28 : tensor<1x10x256x1xf32> + %42 = stablehlo.reduce(%33 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x32xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %47 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %47 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %43 = stablehlo.broadcast_in_dim %42, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %44 = stablehlo.multiply %43, %37 : tensor<1x10x256x1xf32> + %45 = stablehlo.add %41, %44 : tensor<1x10x256x1xf32> + %46 = stablehlo.add %iterArg_9, %c : tensor + stablehlo.return %40, %45, %26, %46 {operandSegmentSizes = dense<4> : tensor<1xi32>} : tensor<1x10x256x64xf32>, tensor<1x10x256x1xf32>, tensor<1x10x256x1xf32>, tensor + } + %8 = stablehlo.broadcast_in_dim %7#1, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %9 = stablehlo.divide %7#0, %8 : tensor<1x10x256x64xf32> + %10:4 = stablehlo.while(%iterArg = %4, %iterArg_7 = %5, %iterArg_8 = %6, %iterArg_9 = %c_6) : tensor<1x10x256x64xf32>, tensor<1x10x256x1xf32>, tensor<1x10x256x1xf32>, tensor attributes {operandSegmentSizes = dense<4> : tensor<1xi32>} + cond { + %14 = stablehlo.compare LT, %iterArg_9, %c_2, SIGNED : (tensor, tensor) -> tensor + stablehlo.return %14 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } do { + %14 = stablehlo.multiply %iterArg_9, %c_1 : tensor + %15 = stablehlo.dynamic_slice %arg1, %c_6, %c_6, %14, %c_6, sizes = [1, 10, 32, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x32x64xf32> + %16 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<1x10x32x64xf32> + %17 = stablehlo.multiply %15, %16 : tensor<1x10x32x64xf32> + %18 = stablehlo.dot_general %2, %17, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x64xf32>, tensor<1x10x32x64xf32>) -> tensor<1x10x256x32xf32> + %19 = stablehlo.dynamic_slice %3, %c_6, %14, sizes = [256, 32] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x32xf32> + %20 = stablehlo.broadcast_in_dim %19, dims = [2, 3] : (tensor<256x32xf32>) -> tensor<1x10x256x32xf32> + %21 = stablehlo.add %18, %20 : tensor<1x10x256x32xf32> + %22 = stablehlo.reduce(%21 init: %cst_3) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x32xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %47 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %47 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %23 = stablehlo.broadcast_in_dim %22, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %24 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<1x10x256x1xf32> + %25 = stablehlo.maximum %23, %24 : tensor<1x10x256x1xf32> + %26 = stablehlo.maximum %iterArg_8, %25 : tensor<1x10x256x1xf32> + %27 = stablehlo.subtract %iterArg_8, %26 : tensor<1x10x256x1xf32> + %28 = stablehlo.exponential %27 : tensor<1x10x256x1xf32> + %29 = stablehlo.broadcast_in_dim %28, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %30 = stablehlo.multiply %iterArg, %29 : tensor<1x10x256x64xf32> + %31 = stablehlo.broadcast_in_dim %25, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x32xf32> + %32 = stablehlo.subtract %21, %31 : tensor<1x10x256x32xf32> + %33 = stablehlo.exponential %32 : tensor<1x10x256x32xf32> + %34 = stablehlo.dynamic_slice %arg2, %c_6, %c_6, %14, %c_6, sizes = [1, 10, 32, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x10x512x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x10x32x64xf32> + %35 = stablehlo.dot_general %33, %34, batching_dims = [0, 1] x [0, 1], contracting_dims = [3] x [2], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x32xf32>, tensor<1x10x32x64xf32>) -> tensor<1x10x256x64xf32> + %36 = stablehlo.subtract %25, %26 : tensor<1x10x256x1xf32> + %37 = stablehlo.exponential %36 : tensor<1x10x256x1xf32> + %38 = stablehlo.broadcast_in_dim %37, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %39 = stablehlo.multiply %35, %38 : tensor<1x10x256x64xf32> + %40 = stablehlo.add %30, %39 : tensor<1x10x256x64xf32> + %41 = stablehlo.multiply %iterArg_7, %28 : tensor<1x10x256x1xf32> + %42 = stablehlo.reduce(%33 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x32xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %47 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %47 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %43 = stablehlo.broadcast_in_dim %42, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %44 = stablehlo.multiply %43, %37 : tensor<1x10x256x1xf32> + %45 = stablehlo.add %41, %44 : tensor<1x10x256x1xf32> + %46 = stablehlo.add %iterArg_9, %c : tensor + stablehlo.return %40, %45, %26, %46 {operandSegmentSizes = dense<4> : tensor<1xi32>} : tensor<1x10x256x64xf32>, tensor<1x10x256x1xf32>, tensor<1x10x256x1xf32>, tensor + } + %11 = stablehlo.broadcast_in_dim %10#1, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x64xf32> + %12 = stablehlo.divide %10#0, %11 : tensor<1x10x256x64xf32> + %13 = stablehlo.concatenate %9, %12, dim = 2 : (tensor<1x10x256x64xf32>, tensor<1x10x256x64xf32>) -> tensor<1x10x512x64xf32> + return %13 : tensor<1x10x512x64xf32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.splitRealImg/fn () Tensor_409638ee2bde459.mlir b/zml/test_data/snapshot/nn.decltest.splitRealImg/fn () Tensor_409638ee2bde459.mlir new file mode 100644 index 00000000..ee4d600a --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.splitRealImg/fn () Tensor_409638ee2bde459.mlir @@ -0,0 +1,50 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor<1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<3.000000e+00> : tensor + %cst_0 = stablehlo.constant dense<2.000000e+00> : tensor + %c = stablehlo.constant dense<0> : tensor + %cst_1 = stablehlo.constant dense<1.000000e+00> : tensor + %cst_2 = stablehlo.constant dense<4.000000e+00> : tensor + %0 = stablehlo.iota dim = 0 : tensor<20xf32> + %1 = stablehlo.reshape %0 : (tensor<20xf32>) -> tensor<5x4xf32> + %2 = stablehlo.slice %1 [0:5, 0:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %3 = stablehlo.reshape %2 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %4 = stablehlo.iota dim = 0 : tensor<5xf32> + %5 = stablehlo.broadcast_in_dim %cst_2, dims = [] : (tensor) -> tensor<5xf32> + %6 = stablehlo.multiply %4, %5 : tensor<5xf32> + %7 = stablehlo.reshape %6 : (tensor<5xf32>) -> tensor<5x1xf32> + %8 = stablehlo.broadcast_in_dim %cst_1, dims = [] : (tensor) -> tensor<5xf32> + %9 = stablehlo.add %6, %8 : tensor<5xf32> + %10 = stablehlo.reshape %9 : (tensor<5xf32>) -> tensor<5x1xf32> + %11 = stablehlo.concatenate %7, %10, dim = 1 : (tensor<5x1xf32>, tensor<5x1xf32>) -> tensor<5x2xf32> + %12 = stablehlo.compare EQ, %3, %11, FLOAT : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x2xi1> + %13 = stablehlo.reshape %12 : (tensor<5x2xi1>) -> tensor<10xi1> + %14 = stablehlo.convert %13 : (tensor<10xi1>) -> tensor<10xi32> + %15 = stablehlo.reduce(%14 init: %c) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<10xi32>, tensor) -> tensor + reducer(%arg0: tensor, %arg1: tensor) { + %32 = stablehlo.add %arg1, %arg0 : tensor + stablehlo.return %32 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %16 = stablehlo.broadcast_in_dim %15, dims = [] : (tensor) -> tensor<1xi32> + %17 = stablehlo.slice %1 [0:5, 2:4] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %18 = stablehlo.reshape %17 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %19 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<5xf32> + %20 = stablehlo.add %6, %19 : tensor<5xf32> + %21 = stablehlo.reshape %20 : (tensor<5xf32>) -> tensor<5x1xf32> + %22 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<5xf32> + %23 = stablehlo.add %6, %22 : tensor<5xf32> + %24 = stablehlo.reshape %23 : (tensor<5xf32>) -> tensor<5x1xf32> + %25 = stablehlo.concatenate %21, %24, dim = 1 : (tensor<5x1xf32>, tensor<5x1xf32>) -> tensor<5x2xf32> + %26 = stablehlo.compare EQ, %18, %25, FLOAT : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x2xi1> + %27 = stablehlo.reshape %26 : (tensor<5x2xi1>) -> tensor<10xi1> + %28 = stablehlo.convert %27 : (tensor<10xi1>) -> tensor<10xi32> + %29 = stablehlo.reduce(%28 init: %c) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<10xi32>, tensor) -> tensor + reducer(%arg0: tensor, %arg1: tensor) { + %32 = stablehlo.add %arg1, %arg0 : tensor + stablehlo.return %32 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %30 = stablehlo.broadcast_in_dim %29, dims = [] : (tensor) -> tensor<1xi32> + %31 = stablehlo.add %16, %30 : tensor<1xi32> + return %31 : tensor<1xi32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.splitRealImg/interleaved.mlir b/zml/test_data/snapshot/nn.decltest.splitRealImg/interleaved.mlir new file mode 100644 index 00000000..0456d225 --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.splitRealImg/interleaved.mlir @@ -0,0 +1,39 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor<1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %0 = stablehlo.iota dim = 0 : tensor<20xf32> + %1 = stablehlo.reshape %0 : (tensor<20xf32>) -> tensor<5x4xf32> + %2 = stablehlo.slice %1 [0:5, 0:4:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %3 = stablehlo.reshape %2 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %4 = stablehlo.reshape %3 : (tensor<5x2xf32>) -> tensor<5x2x1xf32> + %5 = stablehlo.slice %1 [0:5, 1:4:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %6 = stablehlo.reshape %5 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %7 = stablehlo.reshape %6 : (tensor<5x2xf32>) -> tensor<5x2x1xf32> + %8 = stablehlo.concatenate %4, %7, dim = 2 : (tensor<5x2x1xf32>, tensor<5x2x1xf32>) -> tensor<5x2x2xf32> + %9 = stablehlo.reshape %8 : (tensor<5x2x2xf32>) -> tensor<5x4xf32> + %10 = stablehlo.slice %9 [0:5, 0:4:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %11 = stablehlo.reshape %10 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %12 = stablehlo.compare EQ, %3, %11, FLOAT : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x2xi1> + %13 = stablehlo.reshape %12 : (tensor<5x2xi1>) -> tensor<10xi1> + %14 = stablehlo.convert %13 : (tensor<10xi1>) -> tensor<10xi32> + %15 = stablehlo.reduce(%14 init: %c) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<10xi32>, tensor) -> tensor + reducer(%arg0: tensor, %arg1: tensor) { + %25 = stablehlo.add %arg1, %arg0 : tensor + stablehlo.return %25 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %16 = stablehlo.broadcast_in_dim %15, dims = [] : (tensor) -> tensor<1xi32> + %17 = stablehlo.slice %9 [0:5, 1:4:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %18 = stablehlo.reshape %17 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %19 = stablehlo.compare EQ, %6, %18, FLOAT : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x2xi1> + %20 = stablehlo.reshape %19 : (tensor<5x2xi1>) -> tensor<10xi1> + %21 = stablehlo.convert %20 : (tensor<10xi1>) -> tensor<10xi32> + %22 = stablehlo.reduce(%21 init: %c) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<10xi32>, tensor) -> tensor + reducer(%arg0: tensor, %arg1: tensor) { + %25 = stablehlo.add %arg1, %arg0 : tensor + stablehlo.return %25 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %23 = stablehlo.broadcast_in_dim %22, dims = [] : (tensor) -> tensor<1xi32> + %24 = stablehlo.add %16, %23 : tensor<1xi32> + return %24 : tensor<1xi32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.splitRealImg/sequential.mlir b/zml/test_data/snapshot/nn.decltest.splitRealImg/sequential.mlir new file mode 100644 index 00000000..469c6d4e --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.splitRealImg/sequential.mlir @@ -0,0 +1,36 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor<1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %0 = stablehlo.iota dim = 0 : tensor<20xf32> + %1 = stablehlo.reshape %0 : (tensor<20xf32>) -> tensor<5x4xf32> + %2 = stablehlo.slice %1 [0:5, 0:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %3 = stablehlo.reshape %2 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %4 = stablehlo.slice %1 [0:5, 2:4] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %5 = stablehlo.reshape %4 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %6 = stablehlo.concatenate %3, %5, dim = 1 : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x4xf32> + %7 = stablehlo.slice %6 [0:5, 0:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %8 = stablehlo.reshape %7 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %9 = stablehlo.compare EQ, %3, %8, FLOAT : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x2xi1> + %10 = stablehlo.reshape %9 : (tensor<5x2xi1>) -> tensor<10xi1> + %11 = stablehlo.convert %10 : (tensor<10xi1>) -> tensor<10xi32> + %12 = stablehlo.reduce(%11 init: %c) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<10xi32>, tensor) -> tensor + reducer(%arg0: tensor, %arg1: tensor) { + %22 = stablehlo.add %arg1, %arg0 : tensor + stablehlo.return %22 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %13 = stablehlo.broadcast_in_dim %12, dims = [] : (tensor) -> tensor<1xi32> + %14 = stablehlo.slice %6 [0:5, 2:4] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %15 = stablehlo.reshape %14 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %16 = stablehlo.compare EQ, %5, %15, FLOAT : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x2xi1> + %17 = stablehlo.reshape %16 : (tensor<5x2xi1>) -> tensor<10xi1> + %18 = stablehlo.convert %17 : (tensor<10xi1>) -> tensor<10xi32> + %19 = stablehlo.reduce(%18 init: %c) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<10xi32>, tensor) -> tensor + reducer(%arg0: tensor, %arg1: tensor) { + %22 = stablehlo.add %arg1, %arg0 : tensor + stablehlo.return %22 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %20 = stablehlo.broadcast_in_dim %19, dims = [] : (tensor) -> tensor<1xi32> + %21 = stablehlo.add %13, %20 : tensor<1xi32> + return %21 : tensor<1xi32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.splitRealImg/split_interleaved.mlir b/zml/test_data/snapshot/nn.decltest.splitRealImg/split_interleaved.mlir new file mode 100644 index 00000000..efb84871 --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.splitRealImg/split_interleaved.mlir @@ -0,0 +1,40 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor<1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<1.000000e+00> : tensor + %c = stablehlo.constant dense<0> : tensor + %cst_0 = stablehlo.constant dense<2.000000e+00> : tensor + %0 = stablehlo.iota dim = 0 : tensor<20xf32> + %1 = stablehlo.reshape %0 : (tensor<20xf32>) -> tensor<5x4xf32> + %2 = stablehlo.slice %1 [0:5, 0:4:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %3 = stablehlo.reshape %2 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %4 = stablehlo.iota dim = 0 : tensor<10xf32> + %5 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<10xf32> + %6 = stablehlo.multiply %4, %5 : tensor<10xf32> + %7 = stablehlo.reshape %6 : (tensor<10xf32>) -> tensor<5x2xf32> + %8 = stablehlo.compare EQ, %3, %7, FLOAT : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x2xi1> + %9 = stablehlo.reshape %8 : (tensor<5x2xi1>) -> tensor<10xi1> + %10 = stablehlo.convert %9 : (tensor<10xi1>) -> tensor<10xi32> + %11 = stablehlo.reduce(%10 init: %c) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<10xi32>, tensor) -> tensor + reducer(%arg0: tensor, %arg1: tensor) { + %24 = stablehlo.add %arg1, %arg0 : tensor + stablehlo.return %24 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %12 = stablehlo.broadcast_in_dim %11, dims = [] : (tensor) -> tensor<1xi32> + %13 = stablehlo.slice %1 [0:5, 1:4:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %14 = stablehlo.reshape %13 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %15 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<10xf32> + %16 = stablehlo.add %6, %15 : tensor<10xf32> + %17 = stablehlo.reshape %16 : (tensor<10xf32>) -> tensor<5x2xf32> + %18 = stablehlo.compare EQ, %14, %17, FLOAT : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x2xi1> + %19 = stablehlo.reshape %18 : (tensor<5x2xi1>) -> tensor<10xi1> + %20 = stablehlo.convert %19 : (tensor<10xi1>) -> tensor<10xi32> + %21 = stablehlo.reduce(%20 init: %c) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<10xi32>, tensor) -> tensor + reducer(%arg0: tensor, %arg1: tensor) { + %24 = stablehlo.add %arg1, %arg0 : tensor + stablehlo.return %24 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %22 = stablehlo.broadcast_in_dim %21, dims = [] : (tensor) -> tensor<1xi32> + %23 = stablehlo.add %12, %22 : tensor<1xi32> + return %23 : tensor<1xi32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.splitRealImg/split_seq.mlir b/zml/test_data/snapshot/nn.decltest.splitRealImg/split_seq.mlir new file mode 100644 index 00000000..ee4d600a --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.splitRealImg/split_seq.mlir @@ -0,0 +1,50 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor<1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<3.000000e+00> : tensor + %cst_0 = stablehlo.constant dense<2.000000e+00> : tensor + %c = stablehlo.constant dense<0> : tensor + %cst_1 = stablehlo.constant dense<1.000000e+00> : tensor + %cst_2 = stablehlo.constant dense<4.000000e+00> : tensor + %0 = stablehlo.iota dim = 0 : tensor<20xf32> + %1 = stablehlo.reshape %0 : (tensor<20xf32>) -> tensor<5x4xf32> + %2 = stablehlo.slice %1 [0:5, 0:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %3 = stablehlo.reshape %2 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %4 = stablehlo.iota dim = 0 : tensor<5xf32> + %5 = stablehlo.broadcast_in_dim %cst_2, dims = [] : (tensor) -> tensor<5xf32> + %6 = stablehlo.multiply %4, %5 : tensor<5xf32> + %7 = stablehlo.reshape %6 : (tensor<5xf32>) -> tensor<5x1xf32> + %8 = stablehlo.broadcast_in_dim %cst_1, dims = [] : (tensor) -> tensor<5xf32> + %9 = stablehlo.add %6, %8 : tensor<5xf32> + %10 = stablehlo.reshape %9 : (tensor<5xf32>) -> tensor<5x1xf32> + %11 = stablehlo.concatenate %7, %10, dim = 1 : (tensor<5x1xf32>, tensor<5x1xf32>) -> tensor<5x2xf32> + %12 = stablehlo.compare EQ, %3, %11, FLOAT : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x2xi1> + %13 = stablehlo.reshape %12 : (tensor<5x2xi1>) -> tensor<10xi1> + %14 = stablehlo.convert %13 : (tensor<10xi1>) -> tensor<10xi32> + %15 = stablehlo.reduce(%14 init: %c) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<10xi32>, tensor) -> tensor + reducer(%arg0: tensor, %arg1: tensor) { + %32 = stablehlo.add %arg1, %arg0 : tensor + stablehlo.return %32 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %16 = stablehlo.broadcast_in_dim %15, dims = [] : (tensor) -> tensor<1xi32> + %17 = stablehlo.slice %1 [0:5, 2:4] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %18 = stablehlo.reshape %17 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %19 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<5xf32> + %20 = stablehlo.add %6, %19 : tensor<5xf32> + %21 = stablehlo.reshape %20 : (tensor<5xf32>) -> tensor<5x1xf32> + %22 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<5xf32> + %23 = stablehlo.add %6, %22 : tensor<5xf32> + %24 = stablehlo.reshape %23 : (tensor<5xf32>) -> tensor<5x1xf32> + %25 = stablehlo.concatenate %21, %24, dim = 1 : (tensor<5x1xf32>, tensor<5x1xf32>) -> tensor<5x2xf32> + %26 = stablehlo.compare EQ, %18, %25, FLOAT : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x2xi1> + %27 = stablehlo.reshape %26 : (tensor<5x2xi1>) -> tensor<10xi1> + %28 = stablehlo.convert %27 : (tensor<10xi1>) -> tensor<10xi32> + %29 = stablehlo.reduce(%28 init: %c) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<10xi32>, tensor) -> tensor + reducer(%arg0: tensor, %arg1: tensor) { + %32 = stablehlo.add %arg1, %arg0 : tensor + stablehlo.return %32 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %30 = stablehlo.broadcast_in_dim %29, dims = [] : (tensor) -> tensor<1xi32> + %31 = stablehlo.add %16, %30 : tensor<1xi32> + return %31 : tensor<1xi32> + } +} diff --git a/zml/test_data/snapshot/nn.decltest.splitRealImg/split_seq_void.mlir b/zml/test_data/snapshot/nn.decltest.splitRealImg/split_seq_void.mlir new file mode 100644 index 00000000..ee4d600a --- /dev/null +++ b/zml/test_data/snapshot/nn.decltest.splitRealImg/split_seq_void.mlir @@ -0,0 +1,50 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor<1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<3.000000e+00> : tensor + %cst_0 = stablehlo.constant dense<2.000000e+00> : tensor + %c = stablehlo.constant dense<0> : tensor + %cst_1 = stablehlo.constant dense<1.000000e+00> : tensor + %cst_2 = stablehlo.constant dense<4.000000e+00> : tensor + %0 = stablehlo.iota dim = 0 : tensor<20xf32> + %1 = stablehlo.reshape %0 : (tensor<20xf32>) -> tensor<5x4xf32> + %2 = stablehlo.slice %1 [0:5, 0:2] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %3 = stablehlo.reshape %2 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %4 = stablehlo.iota dim = 0 : tensor<5xf32> + %5 = stablehlo.broadcast_in_dim %cst_2, dims = [] : (tensor) -> tensor<5xf32> + %6 = stablehlo.multiply %4, %5 : tensor<5xf32> + %7 = stablehlo.reshape %6 : (tensor<5xf32>) -> tensor<5x1xf32> + %8 = stablehlo.broadcast_in_dim %cst_1, dims = [] : (tensor) -> tensor<5xf32> + %9 = stablehlo.add %6, %8 : tensor<5xf32> + %10 = stablehlo.reshape %9 : (tensor<5xf32>) -> tensor<5x1xf32> + %11 = stablehlo.concatenate %7, %10, dim = 1 : (tensor<5x1xf32>, tensor<5x1xf32>) -> tensor<5x2xf32> + %12 = stablehlo.compare EQ, %3, %11, FLOAT : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x2xi1> + %13 = stablehlo.reshape %12 : (tensor<5x2xi1>) -> tensor<10xi1> + %14 = stablehlo.convert %13 : (tensor<10xi1>) -> tensor<10xi32> + %15 = stablehlo.reduce(%14 init: %c) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<10xi32>, tensor) -> tensor + reducer(%arg0: tensor, %arg1: tensor) { + %32 = stablehlo.add %arg1, %arg0 : tensor + stablehlo.return %32 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %16 = stablehlo.broadcast_in_dim %15, dims = [] : (tensor) -> tensor<1xi32> + %17 = stablehlo.slice %1 [0:5, 2:4] : (tensor<5x4xf32>) -> tensor<5x2xf32> + %18 = stablehlo.reshape %17 : (tensor<5x2xf32>) -> tensor<5x2xf32> + %19 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<5xf32> + %20 = stablehlo.add %6, %19 : tensor<5xf32> + %21 = stablehlo.reshape %20 : (tensor<5xf32>) -> tensor<5x1xf32> + %22 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<5xf32> + %23 = stablehlo.add %6, %22 : tensor<5xf32> + %24 = stablehlo.reshape %23 : (tensor<5xf32>) -> tensor<5x1xf32> + %25 = stablehlo.concatenate %21, %24, dim = 1 : (tensor<5x1xf32>, tensor<5x1xf32>) -> tensor<5x2xf32> + %26 = stablehlo.compare EQ, %18, %25, FLOAT : (tensor<5x2xf32>, tensor<5x2xf32>) -> tensor<5x2xi1> + %27 = stablehlo.reshape %26 : (tensor<5x2xi1>) -> tensor<10xi1> + %28 = stablehlo.convert %27 : (tensor<10xi1>) -> tensor<10xi32> + %29 = stablehlo.reduce(%28 init: %c) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<10xi32>, tensor) -> tensor + reducer(%arg0: tensor, %arg1: tensor) { + %32 = stablehlo.add %arg1, %arg0 : tensor + stablehlo.return %32 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %30 = stablehlo.broadcast_in_dim %29, dims = [] : (tensor) -> tensor<1xi32> + %31 = stablehlo.add %16, %30 : tensor<1xi32> + return %31 : tensor<1xi32> + } +} diff --git a/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_91b4e3e69b5098c.mlir b/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_91b4e3e69b5098c.mlir new file mode 100644 index 00000000..1d6d71e4 --- /dev/null +++ b/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_91b4e3e69b5098c.mlir @@ -0,0 +1,9 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor<512x512xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %cst_0 = stablehlo.constant dense<1.000000e+00> : tensor + %c = stablehlo.constant dense<512> : tensor<2xi64> + %0 = stablehlo.rng %cst, %cst_0, %c, distribution = NORMAL : (tensor, tensor, tensor<2xi64>) -> tensor<512x512xf32> + return %0 : tensor<512x512xf32> + } +} diff --git a/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_e94eca87ec879d51.mlir b/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_e94eca87ec879d51.mlir new file mode 100644 index 00000000..8056b41e --- /dev/null +++ b/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Shape, Tensor.Rng.normal__struct_155810) Tensor_e94eca87ec879d51.mlir @@ -0,0 +1,9 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor<1x512x10x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %cst_0 = stablehlo.constant dense<1.000000e+00> : tensor + %c = stablehlo.constant dense<[1, 512, 10, 64]> : tensor<4xi64> + %0 = stablehlo.rng %cst, %cst_0, %c, distribution = NORMAL : (tensor, tensor, tensor<4xi64>) -> tensor<1x512x10x64xf32> + return %0 : tensor<1x512x10x64xf32> + } +} diff --git a/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Tensor, Tensor, Tensor, nn.SdpaOpts) Tensor_c204f895396cd33f.mlir b/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Tensor, Tensor, Tensor, nn.SdpaOpts) Tensor_c204f895396cd33f.mlir new file mode 100644 index 00000000..8c9b020d --- /dev/null +++ b/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Tensor, Tensor, Tensor, nn.SdpaOpts) Tensor_c204f895396cd33f.mlir @@ -0,0 +1,37 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x512x10x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<1x512x10x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<1x512x10x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor<512x512xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x512x10x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %cst_0 = stablehlo.constant dense<0xFF800000> : tensor + %cst_1 = stablehlo.constant dense<1.250000e-01> : tensor + %0 = stablehlo.broadcast_in_dim %cst_1, dims = [] : (tensor) -> tensor<1x512x10x64xf32> + %1 = stablehlo.multiply %arg1, %0 : tensor<1x512x10x64xf32> + %2 = stablehlo.dot_general %arg0, %1, batching_dims = [0, 2] x [0, 2], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x512x10x64xf32>, tensor<1x512x10x64xf32>) -> tensor<1x10x512x512xf32> + %3 = stablehlo.broadcast_in_dim %arg3, dims = [2, 3] : (tensor<512x512xf32>) -> tensor<1x10x512x512xf32> + %4 = stablehlo.add %2, %3 : tensor<1x10x512x512xf32> + %5 = stablehlo.reduce(%4 init: %cst_0) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x512x512xf32>, tensor) -> tensor<1x10x512xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %21 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %21 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %6 = stablehlo.broadcast_in_dim %5, dims = [0, 1, 2] : (tensor<1x10x512xf32>) -> tensor<1x10x512x1xf32> + %7 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<1x10x512x1xf32> + %8 = stablehlo.compare GT, %6, %7, FLOAT : (tensor<1x10x512x1xf32>, tensor<1x10x512x1xf32>) -> tensor<1x10x512x1xi1> + %9 = stablehlo.broadcast_in_dim %8, dims = [0, 1, 2, 3] : (tensor<1x10x512x1xi1>) -> tensor<1x10x512x512xi1> + %10 = stablehlo.broadcast_in_dim %6, dims = [0, 1, 2, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x10x512x512xf32> + %11 = stablehlo.subtract %4, %10 : tensor<1x10x512x512xf32> + %12 = stablehlo.exponential %11 : tensor<1x10x512x512xf32> + %13 = stablehlo.reduce(%12 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x512x512xf32>, tensor) -> tensor<1x10x512xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %21 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %21 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %14 = stablehlo.broadcast_in_dim %13, dims = [0, 1, 2] : (tensor<1x10x512xf32>) -> tensor<1x10x512x1xf32> + %15 = stablehlo.broadcast_in_dim %14, dims = [0, 1, 2, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x10x512x512xf32> + %16 = stablehlo.divide %12, %15 : tensor<1x10x512x512xf32> + %17 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<1x10x512x512xf32> + %18 = stablehlo.select %9, %16, %17 : tensor<1x10x512x512xi1>, tensor<1x10x512x512xf32> + %19 = stablehlo.dot_general %18, %arg2, batching_dims = [0, 1] x [0, 2], contracting_dims = [3] x [1], precision = [DEFAULT, DEFAULT] : (tensor<1x10x512x512xf32>, tensor<1x512x10x64xf32>) -> tensor<1x10x512x64xf32> + %20 = stablehlo.transpose %19, dims = [0, 2, 1, 3] : (tensor<1x10x512x64xf32>) -> tensor<1x512x10x64xf32> + return %20 : tensor<1x512x10x64xf32> + } +} diff --git a/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_62dec6bb3422c159.mlir b/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_62dec6bb3422c159.mlir new file mode 100644 index 00000000..778e65ca --- /dev/null +++ b/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_62dec6bb3422c159.mlir @@ -0,0 +1,312 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x512x10x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<1x512x10x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<1x512x10x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor<512x512xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x512x10x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<256> : tensor + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %c_0 = stablehlo.constant dense<3> : tensor + %c_1 = stablehlo.constant dense<2> : tensor + %c_2 = stablehlo.constant dense<1> : tensor + %cst_3 = stablehlo.constant dense<-1.000000e+16> : tensor + %cst_4 = stablehlo.constant dense<0xFF800000> : tensor + %cst_5 = stablehlo.constant dense<1.250000e-01> : tensor + %c_6 = stablehlo.constant dense<128> : tensor + %c_7 = stablehlo.constant dense<0> : tensor + %0 = stablehlo.dynamic_slice %arg0, %c_7, %c_7, %c_7, %c_7, sizes = [1, 256, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x256x10x64xf32> + %1 = stablehlo.multiply %c_7, %c_6 : tensor + %2 = stablehlo.dynamic_slice %arg1, %c_7, %1, %c_7, %c_7, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %3 = stablehlo.broadcast_in_dim %cst_5, dims = [] : (tensor) -> tensor<1x128x10x64xf32> + %4 = stablehlo.multiply %2, %3 : tensor<1x128x10x64xf32> + %5 = stablehlo.dot_general %0, %4, batching_dims = [0, 2] x [0, 2], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x256x10x64xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x128xf32> + %6 = stablehlo.dynamic_slice %arg3, %c_7, %c_7, sizes = [256, 512] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<512x512xf32>, tensor, tensor) -> tensor<256x512xf32> + %7 = stablehlo.dynamic_slice %6, %c_7, %1, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %8 = stablehlo.broadcast_in_dim %7, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %9 = stablehlo.add %5, %8 : tensor<1x10x256x128xf32> + %10 = stablehlo.reduce(%9 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %11 = stablehlo.broadcast_in_dim %10, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %12 = stablehlo.broadcast_in_dim %cst_3, dims = [] : (tensor) -> tensor<1x10x256x1xf32> + %13 = stablehlo.maximum %11, %12 : tensor<1x10x256x1xf32> + %14 = stablehlo.broadcast_in_dim %13, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %15 = stablehlo.subtract %9, %14 : tensor<1x10x256x128xf32> + %16 = stablehlo.exponential %15 : tensor<1x10x256x128xf32> + %17 = stablehlo.dynamic_slice %arg2, %c_7, %1, %c_7, %c_7, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %18 = stablehlo.dot_general %16, %17, batching_dims = [0, 1] x [0, 2], contracting_dims = [3] x [1], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x64xf32> + %19 = stablehlo.transpose %18, dims = [0, 2, 1, 3] : (tensor<1x10x256x64xf32>) -> tensor<1x256x10x64xf32> + %20 = stablehlo.transpose %13, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %21 = stablehlo.multiply %c_2, %c_6 : tensor + %22 = stablehlo.dynamic_slice %arg1, %c_7, %21, %c_7, %c_7, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %23 = stablehlo.multiply %22, %3 : tensor<1x128x10x64xf32> + %24 = stablehlo.dot_general %0, %23, batching_dims = [0, 2] x [0, 2], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x256x10x64xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x128xf32> + %25 = stablehlo.dynamic_slice %6, %c_7, %21, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %26 = stablehlo.broadcast_in_dim %25, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %27 = stablehlo.add %24, %26 : tensor<1x10x256x128xf32> + %28 = stablehlo.reduce(%27 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %29 = stablehlo.broadcast_in_dim %28, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %30 = stablehlo.maximum %29, %12 : tensor<1x10x256x1xf32> + %31 = stablehlo.transpose %30, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %32 = stablehlo.maximum %20, %31 : tensor<1x256x10x1xf32> + %33 = stablehlo.subtract %20, %32 : tensor<1x256x10x1xf32> + %34 = stablehlo.exponential %33 : tensor<1x256x10x1xf32> + %35 = stablehlo.broadcast_in_dim %34, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %36 = stablehlo.multiply %19, %35 : tensor<1x256x10x64xf32> + %37 = stablehlo.broadcast_in_dim %30, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %38 = stablehlo.subtract %27, %37 : tensor<1x10x256x128xf32> + %39 = stablehlo.exponential %38 : tensor<1x10x256x128xf32> + %40 = stablehlo.dynamic_slice %arg2, %c_7, %21, %c_7, %c_7, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %41 = stablehlo.dot_general %39, %40, batching_dims = [0, 1] x [0, 2], contracting_dims = [3] x [1], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x64xf32> + %42 = stablehlo.transpose %41, dims = [0, 2, 1, 3] : (tensor<1x10x256x64xf32>) -> tensor<1x256x10x64xf32> + %43 = stablehlo.subtract %31, %32 : tensor<1x256x10x1xf32> + %44 = stablehlo.exponential %43 : tensor<1x256x10x1xf32> + %45 = stablehlo.broadcast_in_dim %44, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %46 = stablehlo.multiply %42, %45 : tensor<1x256x10x64xf32> + %47 = stablehlo.add %36, %46 : tensor<1x256x10x64xf32> + %48 = stablehlo.multiply %c_1, %c_6 : tensor + %49 = stablehlo.dynamic_slice %arg1, %c_7, %48, %c_7, %c_7, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %50 = stablehlo.multiply %49, %3 : tensor<1x128x10x64xf32> + %51 = stablehlo.dot_general %0, %50, batching_dims = [0, 2] x [0, 2], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x256x10x64xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x128xf32> + %52 = stablehlo.dynamic_slice %6, %c_7, %48, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %53 = stablehlo.broadcast_in_dim %52, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %54 = stablehlo.add %51, %53 : tensor<1x10x256x128xf32> + %55 = stablehlo.reduce(%54 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %56 = stablehlo.broadcast_in_dim %55, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %57 = stablehlo.maximum %56, %12 : tensor<1x10x256x1xf32> + %58 = stablehlo.transpose %57, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %59 = stablehlo.maximum %32, %58 : tensor<1x256x10x1xf32> + %60 = stablehlo.subtract %32, %59 : tensor<1x256x10x1xf32> + %61 = stablehlo.exponential %60 : tensor<1x256x10x1xf32> + %62 = stablehlo.broadcast_in_dim %61, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %63 = stablehlo.multiply %47, %62 : tensor<1x256x10x64xf32> + %64 = stablehlo.broadcast_in_dim %57, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %65 = stablehlo.subtract %54, %64 : tensor<1x10x256x128xf32> + %66 = stablehlo.exponential %65 : tensor<1x10x256x128xf32> + %67 = stablehlo.dynamic_slice %arg2, %c_7, %48, %c_7, %c_7, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %68 = stablehlo.dot_general %66, %67, batching_dims = [0, 1] x [0, 2], contracting_dims = [3] x [1], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x64xf32> + %69 = stablehlo.transpose %68, dims = [0, 2, 1, 3] : (tensor<1x10x256x64xf32>) -> tensor<1x256x10x64xf32> + %70 = stablehlo.subtract %58, %59 : tensor<1x256x10x1xf32> + %71 = stablehlo.exponential %70 : tensor<1x256x10x1xf32> + %72 = stablehlo.broadcast_in_dim %71, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %73 = stablehlo.multiply %69, %72 : tensor<1x256x10x64xf32> + %74 = stablehlo.add %63, %73 : tensor<1x256x10x64xf32> + %75 = stablehlo.multiply %c_0, %c_6 : tensor + %76 = stablehlo.dynamic_slice %arg1, %c_7, %75, %c_7, %c_7, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %77 = stablehlo.multiply %76, %3 : tensor<1x128x10x64xf32> + %78 = stablehlo.dot_general %0, %77, batching_dims = [0, 2] x [0, 2], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x256x10x64xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x128xf32> + %79 = stablehlo.dynamic_slice %6, %c_7, %75, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %80 = stablehlo.broadcast_in_dim %79, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %81 = stablehlo.add %78, %80 : tensor<1x10x256x128xf32> + %82 = stablehlo.reduce(%81 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %83 = stablehlo.broadcast_in_dim %82, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %84 = stablehlo.maximum %83, %12 : tensor<1x10x256x1xf32> + %85 = stablehlo.transpose %84, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %86 = stablehlo.maximum %59, %85 : tensor<1x256x10x1xf32> + %87 = stablehlo.subtract %59, %86 : tensor<1x256x10x1xf32> + %88 = stablehlo.exponential %87 : tensor<1x256x10x1xf32> + %89 = stablehlo.broadcast_in_dim %88, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %90 = stablehlo.multiply %74, %89 : tensor<1x256x10x64xf32> + %91 = stablehlo.broadcast_in_dim %84, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %92 = stablehlo.subtract %81, %91 : tensor<1x10x256x128xf32> + %93 = stablehlo.exponential %92 : tensor<1x10x256x128xf32> + %94 = stablehlo.dynamic_slice %arg2, %c_7, %75, %c_7, %c_7, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %95 = stablehlo.dot_general %93, %94, batching_dims = [0, 1] x [0, 2], contracting_dims = [3] x [1], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x64xf32> + %96 = stablehlo.transpose %95, dims = [0, 2, 1, 3] : (tensor<1x10x256x64xf32>) -> tensor<1x256x10x64xf32> + %97 = stablehlo.subtract %85, %86 : tensor<1x256x10x1xf32> + %98 = stablehlo.exponential %97 : tensor<1x256x10x1xf32> + %99 = stablehlo.broadcast_in_dim %98, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %100 = stablehlo.multiply %96, %99 : tensor<1x256x10x64xf32> + %101 = stablehlo.add %90, %100 : tensor<1x256x10x64xf32> + %102 = stablehlo.reduce(%16 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %103 = stablehlo.broadcast_in_dim %102, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %104 = stablehlo.transpose %103, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %105 = stablehlo.multiply %104, %34 : tensor<1x256x10x1xf32> + %106 = stablehlo.reduce(%39 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %107 = stablehlo.broadcast_in_dim %106, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %108 = stablehlo.transpose %107, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %109 = stablehlo.multiply %108, %44 : tensor<1x256x10x1xf32> + %110 = stablehlo.add %105, %109 : tensor<1x256x10x1xf32> + %111 = stablehlo.multiply %110, %61 : tensor<1x256x10x1xf32> + %112 = stablehlo.reduce(%66 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %113 = stablehlo.broadcast_in_dim %112, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %114 = stablehlo.transpose %113, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %115 = stablehlo.multiply %114, %71 : tensor<1x256x10x1xf32> + %116 = stablehlo.add %111, %115 : tensor<1x256x10x1xf32> + %117 = stablehlo.multiply %116, %88 : tensor<1x256x10x1xf32> + %118 = stablehlo.reduce(%93 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %119 = stablehlo.broadcast_in_dim %118, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %120 = stablehlo.transpose %119, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %121 = stablehlo.multiply %120, %98 : tensor<1x256x10x1xf32> + %122 = stablehlo.add %117, %121 : tensor<1x256x10x1xf32> + %123 = stablehlo.broadcast_in_dim %122, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %124 = stablehlo.divide %101, %123 : tensor<1x256x10x64xf32> + %125 = stablehlo.dynamic_slice %arg0, %c_7, %c, %c_7, %c_7, sizes = [1, 256, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x256x10x64xf32> + %126 = stablehlo.dot_general %125, %4, batching_dims = [0, 2] x [0, 2], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x256x10x64xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x128xf32> + %127 = stablehlo.dynamic_slice %arg3, %c, %c_7, sizes = [256, 512] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<512x512xf32>, tensor, tensor) -> tensor<256x512xf32> + %128 = stablehlo.dynamic_slice %127, %c_7, %1, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %129 = stablehlo.broadcast_in_dim %128, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %130 = stablehlo.add %126, %129 : tensor<1x10x256x128xf32> + %131 = stablehlo.reduce(%130 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %132 = stablehlo.broadcast_in_dim %131, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %133 = stablehlo.maximum %132, %12 : tensor<1x10x256x1xf32> + %134 = stablehlo.broadcast_in_dim %133, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %135 = stablehlo.subtract %130, %134 : tensor<1x10x256x128xf32> + %136 = stablehlo.exponential %135 : tensor<1x10x256x128xf32> + %137 = stablehlo.dot_general %136, %17, batching_dims = [0, 1] x [0, 2], contracting_dims = [3] x [1], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x64xf32> + %138 = stablehlo.transpose %137, dims = [0, 2, 1, 3] : (tensor<1x10x256x64xf32>) -> tensor<1x256x10x64xf32> + %139 = stablehlo.transpose %133, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %140 = stablehlo.dot_general %125, %23, batching_dims = [0, 2] x [0, 2], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x256x10x64xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x128xf32> + %141 = stablehlo.dynamic_slice %127, %c_7, %21, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %142 = stablehlo.broadcast_in_dim %141, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %143 = stablehlo.add %140, %142 : tensor<1x10x256x128xf32> + %144 = stablehlo.reduce(%143 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %145 = stablehlo.broadcast_in_dim %144, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %146 = stablehlo.maximum %145, %12 : tensor<1x10x256x1xf32> + %147 = stablehlo.transpose %146, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %148 = stablehlo.maximum %139, %147 : tensor<1x256x10x1xf32> + %149 = stablehlo.subtract %139, %148 : tensor<1x256x10x1xf32> + %150 = stablehlo.exponential %149 : tensor<1x256x10x1xf32> + %151 = stablehlo.broadcast_in_dim %150, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %152 = stablehlo.multiply %138, %151 : tensor<1x256x10x64xf32> + %153 = stablehlo.broadcast_in_dim %146, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %154 = stablehlo.subtract %143, %153 : tensor<1x10x256x128xf32> + %155 = stablehlo.exponential %154 : tensor<1x10x256x128xf32> + %156 = stablehlo.dot_general %155, %40, batching_dims = [0, 1] x [0, 2], contracting_dims = [3] x [1], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x64xf32> + %157 = stablehlo.transpose %156, dims = [0, 2, 1, 3] : (tensor<1x10x256x64xf32>) -> tensor<1x256x10x64xf32> + %158 = stablehlo.subtract %147, %148 : tensor<1x256x10x1xf32> + %159 = stablehlo.exponential %158 : tensor<1x256x10x1xf32> + %160 = stablehlo.broadcast_in_dim %159, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %161 = stablehlo.multiply %157, %160 : tensor<1x256x10x64xf32> + %162 = stablehlo.add %152, %161 : tensor<1x256x10x64xf32> + %163 = stablehlo.dot_general %125, %50, batching_dims = [0, 2] x [0, 2], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x256x10x64xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x128xf32> + %164 = stablehlo.dynamic_slice %127, %c_7, %48, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %165 = stablehlo.broadcast_in_dim %164, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %166 = stablehlo.add %163, %165 : tensor<1x10x256x128xf32> + %167 = stablehlo.reduce(%166 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %168 = stablehlo.broadcast_in_dim %167, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %169 = stablehlo.maximum %168, %12 : tensor<1x10x256x1xf32> + %170 = stablehlo.transpose %169, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %171 = stablehlo.maximum %148, %170 : tensor<1x256x10x1xf32> + %172 = stablehlo.subtract %148, %171 : tensor<1x256x10x1xf32> + %173 = stablehlo.exponential %172 : tensor<1x256x10x1xf32> + %174 = stablehlo.broadcast_in_dim %173, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %175 = stablehlo.multiply %162, %174 : tensor<1x256x10x64xf32> + %176 = stablehlo.broadcast_in_dim %169, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %177 = stablehlo.subtract %166, %176 : tensor<1x10x256x128xf32> + %178 = stablehlo.exponential %177 : tensor<1x10x256x128xf32> + %179 = stablehlo.dot_general %178, %67, batching_dims = [0, 1] x [0, 2], contracting_dims = [3] x [1], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x64xf32> + %180 = stablehlo.transpose %179, dims = [0, 2, 1, 3] : (tensor<1x10x256x64xf32>) -> tensor<1x256x10x64xf32> + %181 = stablehlo.subtract %170, %171 : tensor<1x256x10x1xf32> + %182 = stablehlo.exponential %181 : tensor<1x256x10x1xf32> + %183 = stablehlo.broadcast_in_dim %182, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %184 = stablehlo.multiply %180, %183 : tensor<1x256x10x64xf32> + %185 = stablehlo.add %175, %184 : tensor<1x256x10x64xf32> + %186 = stablehlo.dot_general %125, %77, batching_dims = [0, 2] x [0, 2], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x256x10x64xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x128xf32> + %187 = stablehlo.dynamic_slice %127, %c_7, %75, sizes = [256, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<256x512xf32>, tensor, tensor) -> tensor<256x128xf32> + %188 = stablehlo.broadcast_in_dim %187, dims = [2, 3] : (tensor<256x128xf32>) -> tensor<1x10x256x128xf32> + %189 = stablehlo.add %186, %188 : tensor<1x10x256x128xf32> + %190 = stablehlo.reduce(%189 init: %cst_4) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %191 = stablehlo.broadcast_in_dim %190, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %192 = stablehlo.maximum %191, %12 : tensor<1x10x256x1xf32> + %193 = stablehlo.transpose %192, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %194 = stablehlo.maximum %171, %193 : tensor<1x256x10x1xf32> + %195 = stablehlo.subtract %171, %194 : tensor<1x256x10x1xf32> + %196 = stablehlo.exponential %195 : tensor<1x256x10x1xf32> + %197 = stablehlo.broadcast_in_dim %196, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %198 = stablehlo.multiply %185, %197 : tensor<1x256x10x64xf32> + %199 = stablehlo.broadcast_in_dim %192, dims = [0, 1, 2, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x10x256x128xf32> + %200 = stablehlo.subtract %189, %199 : tensor<1x10x256x128xf32> + %201 = stablehlo.exponential %200 : tensor<1x10x256x128xf32> + %202 = stablehlo.dot_general %201, %94, batching_dims = [0, 1] x [0, 2], contracting_dims = [3] x [1], precision = [DEFAULT, DEFAULT] : (tensor<1x10x256x128xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x256x64xf32> + %203 = stablehlo.transpose %202, dims = [0, 2, 1, 3] : (tensor<1x10x256x64xf32>) -> tensor<1x256x10x64xf32> + %204 = stablehlo.subtract %193, %194 : tensor<1x256x10x1xf32> + %205 = stablehlo.exponential %204 : tensor<1x256x10x1xf32> + %206 = stablehlo.broadcast_in_dim %205, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %207 = stablehlo.multiply %203, %206 : tensor<1x256x10x64xf32> + %208 = stablehlo.add %198, %207 : tensor<1x256x10x64xf32> + %209 = stablehlo.reduce(%136 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %210 = stablehlo.broadcast_in_dim %209, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %211 = stablehlo.transpose %210, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %212 = stablehlo.multiply %211, %150 : tensor<1x256x10x1xf32> + %213 = stablehlo.reduce(%155 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %214 = stablehlo.broadcast_in_dim %213, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %215 = stablehlo.transpose %214, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %216 = stablehlo.multiply %215, %159 : tensor<1x256x10x1xf32> + %217 = stablehlo.add %212, %216 : tensor<1x256x10x1xf32> + %218 = stablehlo.multiply %217, %173 : tensor<1x256x10x1xf32> + %219 = stablehlo.reduce(%178 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %220 = stablehlo.broadcast_in_dim %219, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %221 = stablehlo.transpose %220, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %222 = stablehlo.multiply %221, %182 : tensor<1x256x10x1xf32> + %223 = stablehlo.add %218, %222 : tensor<1x256x10x1xf32> + %224 = stablehlo.multiply %223, %196 : tensor<1x256x10x1xf32> + %225 = stablehlo.reduce(%201 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x256x128xf32>, tensor) -> tensor<1x10x256xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %233 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %233 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %226 = stablehlo.broadcast_in_dim %225, dims = [0, 1, 2] : (tensor<1x10x256xf32>) -> tensor<1x10x256x1xf32> + %227 = stablehlo.transpose %226, dims = [0, 2, 1, 3] : (tensor<1x10x256x1xf32>) -> tensor<1x256x10x1xf32> + %228 = stablehlo.multiply %227, %205 : tensor<1x256x10x1xf32> + %229 = stablehlo.add %224, %228 : tensor<1x256x10x1xf32> + %230 = stablehlo.broadcast_in_dim %229, dims = [0, 1, 2, 3] : (tensor<1x256x10x1xf32>) -> tensor<1x256x10x64xf32> + %231 = stablehlo.divide %208, %230 : tensor<1x256x10x64xf32> + %232 = stablehlo.concatenate %124, %231, dim = 1 : (tensor<1x256x10x64xf32>, tensor<1x256x10x64xf32>) -> tensor<1x512x10x64xf32> + return %232 : tensor<1x512x10x64xf32> + } +} diff --git a/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_bf20962f3dae6108.mlir b/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_bf20962f3dae6108.mlir new file mode 100644 index 00000000..8977a7b5 --- /dev/null +++ b/zml/test_data/snapshot/nn.test.sdpaMemEfficient transposed/fn (Tensor, Tensor, Tensor, nn.SdpaOpts, nn.SdpaChunks) Tensor_bf20962f3dae6108.mlir @@ -0,0 +1,171 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x512x10x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<1x512x10x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<1x512x10x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor<512x512xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x512x10x64xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %c = stablehlo.constant dense<3> : tensor + %c_0 = stablehlo.constant dense<2> : tensor + %c_1 = stablehlo.constant dense<1> : tensor + %cst_2 = stablehlo.constant dense<-1.000000e+16> : tensor + %cst_3 = stablehlo.constant dense<0xFF800000> : tensor + %cst_4 = stablehlo.constant dense<1.250000e-01> : tensor + %c_5 = stablehlo.constant dense<128> : tensor + %c_6 = stablehlo.constant dense<0> : tensor + %0 = stablehlo.dynamic_slice %arg0, %c_6, %c_6, %c_6, %c_6, sizes = [1, 512, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x512x10x64xf32> + %1 = stablehlo.multiply %c_6, %c_5 : tensor + %2 = stablehlo.dynamic_slice %arg1, %c_6, %1, %c_6, %c_6, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %3 = stablehlo.broadcast_in_dim %cst_4, dims = [] : (tensor) -> tensor<1x128x10x64xf32> + %4 = stablehlo.multiply %2, %3 : tensor<1x128x10x64xf32> + %5 = stablehlo.dot_general %0, %4, batching_dims = [0, 2] x [0, 2], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x512x10x64xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x512x128xf32> + %6 = stablehlo.dynamic_slice %arg3, %c_6, %c_6, sizes = [512, 512] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<512x512xf32>, tensor, tensor) -> tensor<512x512xf32> + %7 = stablehlo.dynamic_slice %6, %c_6, %1, sizes = [512, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<512x512xf32>, tensor, tensor) -> tensor<512x128xf32> + %8 = stablehlo.broadcast_in_dim %7, dims = [2, 3] : (tensor<512x128xf32>) -> tensor<1x10x512x128xf32> + %9 = stablehlo.add %5, %8 : tensor<1x10x512x128xf32> + %10 = stablehlo.reduce(%9 init: %cst_3) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x512x128xf32>, tensor) -> tensor<1x10x512xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %125 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %125 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %11 = stablehlo.broadcast_in_dim %10, dims = [0, 1, 2] : (tensor<1x10x512xf32>) -> tensor<1x10x512x1xf32> + %12 = stablehlo.broadcast_in_dim %cst_2, dims = [] : (tensor) -> tensor<1x10x512x1xf32> + %13 = stablehlo.maximum %11, %12 : tensor<1x10x512x1xf32> + %14 = stablehlo.broadcast_in_dim %13, dims = [0, 1, 2, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x10x512x128xf32> + %15 = stablehlo.subtract %9, %14 : tensor<1x10x512x128xf32> + %16 = stablehlo.exponential %15 : tensor<1x10x512x128xf32> + %17 = stablehlo.dynamic_slice %arg2, %c_6, %1, %c_6, %c_6, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %18 = stablehlo.dot_general %16, %17, batching_dims = [0, 1] x [0, 2], contracting_dims = [3] x [1], precision = [DEFAULT, DEFAULT] : (tensor<1x10x512x128xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x512x64xf32> + %19 = stablehlo.transpose %18, dims = [0, 2, 1, 3] : (tensor<1x10x512x64xf32>) -> tensor<1x512x10x64xf32> + %20 = stablehlo.transpose %13, dims = [0, 2, 1, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x512x10x1xf32> + %21 = stablehlo.multiply %c_1, %c_5 : tensor + %22 = stablehlo.dynamic_slice %arg1, %c_6, %21, %c_6, %c_6, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %23 = stablehlo.multiply %22, %3 : tensor<1x128x10x64xf32> + %24 = stablehlo.dot_general %0, %23, batching_dims = [0, 2] x [0, 2], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x512x10x64xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x512x128xf32> + %25 = stablehlo.dynamic_slice %6, %c_6, %21, sizes = [512, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<512x512xf32>, tensor, tensor) -> tensor<512x128xf32> + %26 = stablehlo.broadcast_in_dim %25, dims = [2, 3] : (tensor<512x128xf32>) -> tensor<1x10x512x128xf32> + %27 = stablehlo.add %24, %26 : tensor<1x10x512x128xf32> + %28 = stablehlo.reduce(%27 init: %cst_3) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x512x128xf32>, tensor) -> tensor<1x10x512xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %125 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %125 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %29 = stablehlo.broadcast_in_dim %28, dims = [0, 1, 2] : (tensor<1x10x512xf32>) -> tensor<1x10x512x1xf32> + %30 = stablehlo.maximum %29, %12 : tensor<1x10x512x1xf32> + %31 = stablehlo.transpose %30, dims = [0, 2, 1, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x512x10x1xf32> + %32 = stablehlo.maximum %20, %31 : tensor<1x512x10x1xf32> + %33 = stablehlo.subtract %20, %32 : tensor<1x512x10x1xf32> + %34 = stablehlo.exponential %33 : tensor<1x512x10x1xf32> + %35 = stablehlo.broadcast_in_dim %34, dims = [0, 1, 2, 3] : (tensor<1x512x10x1xf32>) -> tensor<1x512x10x64xf32> + %36 = stablehlo.multiply %19, %35 : tensor<1x512x10x64xf32> + %37 = stablehlo.broadcast_in_dim %30, dims = [0, 1, 2, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x10x512x128xf32> + %38 = stablehlo.subtract %27, %37 : tensor<1x10x512x128xf32> + %39 = stablehlo.exponential %38 : tensor<1x10x512x128xf32> + %40 = stablehlo.dynamic_slice %arg2, %c_6, %21, %c_6, %c_6, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %41 = stablehlo.dot_general %39, %40, batching_dims = [0, 1] x [0, 2], contracting_dims = [3] x [1], precision = [DEFAULT, DEFAULT] : (tensor<1x10x512x128xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x512x64xf32> + %42 = stablehlo.transpose %41, dims = [0, 2, 1, 3] : (tensor<1x10x512x64xf32>) -> tensor<1x512x10x64xf32> + %43 = stablehlo.subtract %31, %32 : tensor<1x512x10x1xf32> + %44 = stablehlo.exponential %43 : tensor<1x512x10x1xf32> + %45 = stablehlo.broadcast_in_dim %44, dims = [0, 1, 2, 3] : (tensor<1x512x10x1xf32>) -> tensor<1x512x10x64xf32> + %46 = stablehlo.multiply %42, %45 : tensor<1x512x10x64xf32> + %47 = stablehlo.add %36, %46 : tensor<1x512x10x64xf32> + %48 = stablehlo.multiply %c_0, %c_5 : tensor + %49 = stablehlo.dynamic_slice %arg1, %c_6, %48, %c_6, %c_6, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %50 = stablehlo.multiply %49, %3 : tensor<1x128x10x64xf32> + %51 = stablehlo.dot_general %0, %50, batching_dims = [0, 2] x [0, 2], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x512x10x64xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x512x128xf32> + %52 = stablehlo.dynamic_slice %6, %c_6, %48, sizes = [512, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<512x512xf32>, tensor, tensor) -> tensor<512x128xf32> + %53 = stablehlo.broadcast_in_dim %52, dims = [2, 3] : (tensor<512x128xf32>) -> tensor<1x10x512x128xf32> + %54 = stablehlo.add %51, %53 : tensor<1x10x512x128xf32> + %55 = stablehlo.reduce(%54 init: %cst_3) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x512x128xf32>, tensor) -> tensor<1x10x512xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %125 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %125 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %56 = stablehlo.broadcast_in_dim %55, dims = [0, 1, 2] : (tensor<1x10x512xf32>) -> tensor<1x10x512x1xf32> + %57 = stablehlo.maximum %56, %12 : tensor<1x10x512x1xf32> + %58 = stablehlo.transpose %57, dims = [0, 2, 1, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x512x10x1xf32> + %59 = stablehlo.maximum %32, %58 : tensor<1x512x10x1xf32> + %60 = stablehlo.subtract %32, %59 : tensor<1x512x10x1xf32> + %61 = stablehlo.exponential %60 : tensor<1x512x10x1xf32> + %62 = stablehlo.broadcast_in_dim %61, dims = [0, 1, 2, 3] : (tensor<1x512x10x1xf32>) -> tensor<1x512x10x64xf32> + %63 = stablehlo.multiply %47, %62 : tensor<1x512x10x64xf32> + %64 = stablehlo.broadcast_in_dim %57, dims = [0, 1, 2, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x10x512x128xf32> + %65 = stablehlo.subtract %54, %64 : tensor<1x10x512x128xf32> + %66 = stablehlo.exponential %65 : tensor<1x10x512x128xf32> + %67 = stablehlo.dynamic_slice %arg2, %c_6, %48, %c_6, %c_6, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %68 = stablehlo.dot_general %66, %67, batching_dims = [0, 1] x [0, 2], contracting_dims = [3] x [1], precision = [DEFAULT, DEFAULT] : (tensor<1x10x512x128xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x512x64xf32> + %69 = stablehlo.transpose %68, dims = [0, 2, 1, 3] : (tensor<1x10x512x64xf32>) -> tensor<1x512x10x64xf32> + %70 = stablehlo.subtract %58, %59 : tensor<1x512x10x1xf32> + %71 = stablehlo.exponential %70 : tensor<1x512x10x1xf32> + %72 = stablehlo.broadcast_in_dim %71, dims = [0, 1, 2, 3] : (tensor<1x512x10x1xf32>) -> tensor<1x512x10x64xf32> + %73 = stablehlo.multiply %69, %72 : tensor<1x512x10x64xf32> + %74 = stablehlo.add %63, %73 : tensor<1x512x10x64xf32> + %75 = stablehlo.multiply %c, %c_5 : tensor + %76 = stablehlo.dynamic_slice %arg1, %c_6, %75, %c_6, %c_6, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %77 = stablehlo.multiply %76, %3 : tensor<1x128x10x64xf32> + %78 = stablehlo.dot_general %0, %77, batching_dims = [0, 2] x [0, 2], contracting_dims = [3] x [3], precision = [DEFAULT, DEFAULT] : (tensor<1x512x10x64xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x512x128xf32> + %79 = stablehlo.dynamic_slice %6, %c_6, %75, sizes = [512, 128] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<512x512xf32>, tensor, tensor) -> tensor<512x128xf32> + %80 = stablehlo.broadcast_in_dim %79, dims = [2, 3] : (tensor<512x128xf32>) -> tensor<1x10x512x128xf32> + %81 = stablehlo.add %78, %80 : tensor<1x10x512x128xf32> + %82 = stablehlo.reduce(%81 init: %cst_3) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x512x128xf32>, tensor) -> tensor<1x10x512xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %125 = stablehlo.maximum %arg5, %arg4 : tensor + stablehlo.return %125 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %83 = stablehlo.broadcast_in_dim %82, dims = [0, 1, 2] : (tensor<1x10x512xf32>) -> tensor<1x10x512x1xf32> + %84 = stablehlo.maximum %83, %12 : tensor<1x10x512x1xf32> + %85 = stablehlo.transpose %84, dims = [0, 2, 1, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x512x10x1xf32> + %86 = stablehlo.maximum %59, %85 : tensor<1x512x10x1xf32> + %87 = stablehlo.subtract %59, %86 : tensor<1x512x10x1xf32> + %88 = stablehlo.exponential %87 : tensor<1x512x10x1xf32> + %89 = stablehlo.broadcast_in_dim %88, dims = [0, 1, 2, 3] : (tensor<1x512x10x1xf32>) -> tensor<1x512x10x64xf32> + %90 = stablehlo.multiply %74, %89 : tensor<1x512x10x64xf32> + %91 = stablehlo.broadcast_in_dim %84, dims = [0, 1, 2, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x10x512x128xf32> + %92 = stablehlo.subtract %81, %91 : tensor<1x10x512x128xf32> + %93 = stablehlo.exponential %92 : tensor<1x10x512x128xf32> + %94 = stablehlo.dynamic_slice %arg2, %c_6, %75, %c_6, %c_6, sizes = [1, 128, 10, 64] {operandSegmentSizes = dense<[1, 4]> : tensor<2xi32>} : (tensor<1x512x10x64xf32>, tensor, tensor, tensor, tensor) -> tensor<1x128x10x64xf32> + %95 = stablehlo.dot_general %93, %94, batching_dims = [0, 1] x [0, 2], contracting_dims = [3] x [1], precision = [DEFAULT, DEFAULT] : (tensor<1x10x512x128xf32>, tensor<1x128x10x64xf32>) -> tensor<1x10x512x64xf32> + %96 = stablehlo.transpose %95, dims = [0, 2, 1, 3] : (tensor<1x10x512x64xf32>) -> tensor<1x512x10x64xf32> + %97 = stablehlo.subtract %85, %86 : tensor<1x512x10x1xf32> + %98 = stablehlo.exponential %97 : tensor<1x512x10x1xf32> + %99 = stablehlo.broadcast_in_dim %98, dims = [0, 1, 2, 3] : (tensor<1x512x10x1xf32>) -> tensor<1x512x10x64xf32> + %100 = stablehlo.multiply %96, %99 : tensor<1x512x10x64xf32> + %101 = stablehlo.add %90, %100 : tensor<1x512x10x64xf32> + %102 = stablehlo.reduce(%16 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x512x128xf32>, tensor) -> tensor<1x10x512xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %125 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %125 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %103 = stablehlo.broadcast_in_dim %102, dims = [0, 1, 2] : (tensor<1x10x512xf32>) -> tensor<1x10x512x1xf32> + %104 = stablehlo.transpose %103, dims = [0, 2, 1, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x512x10x1xf32> + %105 = stablehlo.multiply %104, %34 : tensor<1x512x10x1xf32> + %106 = stablehlo.reduce(%39 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x512x128xf32>, tensor) -> tensor<1x10x512xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %125 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %125 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %107 = stablehlo.broadcast_in_dim %106, dims = [0, 1, 2] : (tensor<1x10x512xf32>) -> tensor<1x10x512x1xf32> + %108 = stablehlo.transpose %107, dims = [0, 2, 1, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x512x10x1xf32> + %109 = stablehlo.multiply %108, %44 : tensor<1x512x10x1xf32> + %110 = stablehlo.add %105, %109 : tensor<1x512x10x1xf32> + %111 = stablehlo.multiply %110, %61 : tensor<1x512x10x1xf32> + %112 = stablehlo.reduce(%66 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x512x128xf32>, tensor) -> tensor<1x10x512xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %125 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %125 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %113 = stablehlo.broadcast_in_dim %112, dims = [0, 1, 2] : (tensor<1x10x512xf32>) -> tensor<1x10x512x1xf32> + %114 = stablehlo.transpose %113, dims = [0, 2, 1, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x512x10x1xf32> + %115 = stablehlo.multiply %114, %71 : tensor<1x512x10x1xf32> + %116 = stablehlo.add %111, %115 : tensor<1x512x10x1xf32> + %117 = stablehlo.multiply %116, %88 : tensor<1x512x10x1xf32> + %118 = stablehlo.reduce(%93 init: %cst) across dimensions = [3] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1x10x512x128xf32>, tensor) -> tensor<1x10x512xf32> + reducer(%arg4: tensor, %arg5: tensor) { + %125 = stablehlo.add %arg5, %arg4 : tensor + stablehlo.return %125 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %119 = stablehlo.broadcast_in_dim %118, dims = [0, 1, 2] : (tensor<1x10x512xf32>) -> tensor<1x10x512x1xf32> + %120 = stablehlo.transpose %119, dims = [0, 2, 1, 3] : (tensor<1x10x512x1xf32>) -> tensor<1x512x10x1xf32> + %121 = stablehlo.multiply %120, %98 : tensor<1x512x10x1xf32> + %122 = stablehlo.add %117, %121 : tensor<1x512x10x1xf32> + %123 = stablehlo.broadcast_in_dim %122, dims = [0, 1, 2, 3] : (tensor<1x512x10x1xf32>) -> tensor<1x512x10x64xf32> + %124 = stablehlo.divide %101, %123 : tensor<1x512x10x64xf32> + return %124 : tensor<1x512x10x64xf32> + } +} diff --git a/zml/test_data/snapshot/ops.decltest.for_/fn (u63) Tensor_14376d570bdf5f73.mlir b/zml/test_data/snapshot/ops.decltest.for_/fn (u63) Tensor_14376d570bdf5f73.mlir new file mode 100644 index 00000000..9a8d8d1c --- /dev/null +++ b/zml/test_data/snapshot/ops.decltest.for_/fn (u63) Tensor_14376d570bdf5f73.mlir @@ -0,0 +1,22 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor<4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<3> : tensor + %c_0 = stablehlo.constant dense<2> : tensor + %c_1 = stablehlo.constant dense<1> : tensor + %c_2 = stablehlo.constant dense<0> : tensor + %0 = stablehlo.convert %c_2 : (tensor) -> tensor + %1 = stablehlo.multiply %0, %0 : tensor + %2 = stablehlo.reshape %1 : (tensor) -> tensor<1xf32> + %3 = stablehlo.convert %c_1 : (tensor) -> tensor + %4 = stablehlo.multiply %3, %3 : tensor + %5 = stablehlo.reshape %4 : (tensor) -> tensor<1xf32> + %6 = stablehlo.convert %c_0 : (tensor) -> tensor + %7 = stablehlo.multiply %6, %6 : tensor + %8 = stablehlo.reshape %7 : (tensor) -> tensor<1xf32> + %9 = stablehlo.convert %c : (tensor) -> tensor + %10 = stablehlo.multiply %9, %9 : tensor + %11 = stablehlo.reshape %10 : (tensor) -> tensor<1xf32> + %12 = stablehlo.concatenate %2, %5, %8, %11, dim = 0 : (tensor<1xf32>, tensor<1xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<4xf32> + return %12 : tensor<4xf32> + } +} diff --git a/zml/test_data/snapshot/ops.decltest.for_/fn (u63) Tensor_89b92f2adbf9b0a3.mlir b/zml/test_data/snapshot/ops.decltest.for_/fn (u63) Tensor_89b92f2adbf9b0a3.mlir new file mode 100644 index 00000000..1649052b --- /dev/null +++ b/zml/test_data/snapshot/ops.decltest.for_/fn (u63) Tensor_89b92f2adbf9b0a3.mlir @@ -0,0 +1,25 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor<10xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<10> : tensor + %c_0 = stablehlo.constant dense<1> : tensor + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %c_1 = stablehlo.constant dense<0> : tensor + %0 = stablehlo.convert %c_1 : (tensor) -> tensor + %1 = stablehlo.multiply %0, %0 : tensor + %2 = stablehlo.reshape %1 : (tensor) -> tensor<1xf32> + %3 = stablehlo.pad %2, %cst, low = [0], high = [9], interior = [0] : (tensor<1xf32>, tensor) -> tensor<10xf32> + %4:2 = stablehlo.while(%iterArg = %3, %iterArg_2 = %c_0) : tensor<10xf32>, tensor attributes {operandSegmentSizes = dense<2> : tensor<1xi32>} + cond { + %5 = stablehlo.compare LT, %iterArg_2, %c, SIGNED : (tensor, tensor) -> tensor + stablehlo.return %5 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } do { + %5 = stablehlo.convert %iterArg_2 : (tensor) -> tensor + %6 = stablehlo.multiply %5, %5 : tensor + %7 = stablehlo.reshape %6 : (tensor) -> tensor<1xf32> + %8 = stablehlo.dynamic_update_slice %iterArg, %7, %iterArg_2 {operandSegmentSizes = dense<1> : tensor<3xi32>} : (tensor<10xf32>, tensor<1xf32>, tensor) -> tensor<10xf32> + %9 = stablehlo.add %iterArg_2, %c_0 : tensor + stablehlo.return %8, %9 {operandSegmentSizes = dense<2> : tensor<1xi32>} : tensor<10xf32>, tensor + } + return %4#0 : tensor<10xf32> + } +} diff --git a/zml/test_data/snapshot/ops.decltest.for_/fn (u63) Tensor_ac3608194ddc6751.mlir b/zml/test_data/snapshot/ops.decltest.for_/fn (u63) Tensor_ac3608194ddc6751.mlir new file mode 100644 index 00000000..dacc717b --- /dev/null +++ b/zml/test_data/snapshot/ops.decltest.for_/fn (u63) Tensor_ac3608194ddc6751.mlir @@ -0,0 +1,9 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor<1xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %0 = stablehlo.convert %c : (tensor) -> tensor + %1 = stablehlo.multiply %0, %0 : tensor + %2 = stablehlo.reshape %1 : (tensor) -> tensor<1xf32> + return %2 : tensor<1xf32> + } +} diff --git a/zml/test_data/snapshot/ops.test.case/fn (Tensor, Tensor, Tensor) Tensor_a2cfcdc950547238.mlir b/zml/test_data/snapshot/ops.test.case/fn (Tensor, Tensor, Tensor) Tensor_a2cfcdc950547238.mlir new file mode 100644 index 00000000..bbe3cbf9 --- /dev/null +++ b/zml/test_data/snapshot/ops.test.case/fn (Tensor, Tensor, Tensor) Tensor_a2cfcdc950547238.mlir @@ -0,0 +1,15 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<2x2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<2x2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.case"(%arg0) ({ + %1 = stablehlo.dot_general %arg1, %arg2, contracting_dims = [1] x [0], precision = [DEFAULT, DEFAULT] : (tensor<2x2xf32>, tensor<2x2xf32>) -> tensor<2x2xf32> + stablehlo.return %1 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor<2x2xf32> + }, { + %1 = stablehlo.add %arg1, %arg2 : tensor<2x2xf32> + stablehlo.return %1 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor<2x2xf32> + }, { + %1 = stablehlo.subtract %arg1, %arg2 : tensor<2x2xf32> + stablehlo.return %1 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor<2x2xf32> + }) : (tensor) -> tensor<2x2xf32> + return %0 : tensor<2x2xf32> + } +} diff --git a/zml/test_data/snapshot/ops.test.if/fn (Tensor, Tensor, Tensor) Tensor_da6609608556e344.mlir b/zml/test_data/snapshot/ops.test.if/fn (Tensor, Tensor, Tensor) Tensor_da6609608556e344.mlir new file mode 100644 index 00000000..a48dbcae --- /dev/null +++ b/zml/test_data/snapshot/ops.test.if/fn (Tensor, Tensor, Tensor) Tensor_da6609608556e344.mlir @@ -0,0 +1,13 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<4x4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<4x4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<4x4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.convert %arg0 : (tensor) -> tensor + %1 = "stablehlo.if"(%0) ({ + %2 = stablehlo.dot_general %arg1, %arg2, contracting_dims = [1] x [0], precision = [DEFAULT, DEFAULT] : (tensor<4x4xf32>, tensor<4x4xf32>) -> tensor<4x4xf32> + stablehlo.return %2 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor<4x4xf32> + }, { + %2 = stablehlo.dot_general %arg2, %arg1, contracting_dims = [1] x [0], precision = [DEFAULT, DEFAULT] : (tensor<4x4xf32>, tensor<4x4xf32>) -> tensor<4x4xf32> + stablehlo.return %2 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor<4x4xf32> + }) : (tensor) -> tensor<4x4xf32> + return %1 : tensor<4x4xf32> + } +} diff --git a/zml/test_data/snapshot/ops.test.nested for/fn (Tensor) Tensor_41691c61316b43d0.mlir b/zml/test_data/snapshot/ops.test.nested for/fn (Tensor) Tensor_41691c61316b43d0.mlir new file mode 100644 index 00000000..700084f4 --- /dev/null +++ b/zml/test_data/snapshot/ops.test.nested for/fn (Tensor) Tensor_41691c61316b43d0.mlir @@ -0,0 +1,53 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<5x5x1xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<5> : tensor + %c_0 = stablehlo.constant dense<1> : tensor + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %c_1 = stablehlo.constant dense<0> : tensor + %0 = stablehlo.dynamic_slice %arg0, %c_1, sizes = [1] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<5xf32>, tensor) -> tensor<1xf32> + %1 = stablehlo.multiply %0, %0 : tensor<1xf32> + %2 = stablehlo.reshape %1 : (tensor<1xf32>) -> tensor<1x1xf32> + %3 = stablehlo.pad %2, %cst, low = [0, 0], high = [4, 0], interior = [0, 0] : (tensor<1x1xf32>, tensor) -> tensor<5x1xf32> + %4:2 = stablehlo.while(%iterArg = %3, %iterArg_2 = %c_0) : tensor<5x1xf32>, tensor attributes {operandSegmentSizes = dense<2> : tensor<1xi32>} + cond { + %8 = stablehlo.compare LT, %iterArg_2, %c, SIGNED : (tensor, tensor) -> tensor + stablehlo.return %8 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } do { + %8 = stablehlo.dynamic_slice %arg0, %iterArg_2, sizes = [1] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<5xf32>, tensor) -> tensor<1xf32> + %9 = stablehlo.multiply %0, %8 : tensor<1xf32> + %10 = stablehlo.reshape %9 : (tensor<1xf32>) -> tensor<1x1xf32> + %11 = stablehlo.dynamic_update_slice %iterArg, %10, %iterArg_2, %c_1 {operandSegmentSizes = dense<[1, 1, 2]> : tensor<3xi32>} : (tensor<5x1xf32>, tensor<1x1xf32>, tensor, tensor) -> tensor<5x1xf32> + %12 = stablehlo.add %iterArg_2, %c_0 : tensor + stablehlo.return %11, %12 {operandSegmentSizes = dense<2> : tensor<1xi32>} : tensor<5x1xf32>, tensor + } + %5 = stablehlo.reshape %4#0 : (tensor<5x1xf32>) -> tensor<1x5x1xf32> + %6 = stablehlo.pad %5, %cst, low = [0, 0, 0], high = [4, 0, 0], interior = [0, 0, 0] : (tensor<1x5x1xf32>, tensor) -> tensor<5x5x1xf32> + %7:2 = stablehlo.while(%iterArg = %6, %iterArg_2 = %c_0) : tensor<5x5x1xf32>, tensor attributes {operandSegmentSizes = dense<2> : tensor<1xi32>} + cond { + %8 = stablehlo.compare LT, %iterArg_2, %c, SIGNED : (tensor, tensor) -> tensor + stablehlo.return %8 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } do { + %8 = stablehlo.dynamic_slice %arg0, %iterArg_2, sizes = [1] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<5xf32>, tensor) -> tensor<1xf32> + %9 = stablehlo.multiply %8, %0 : tensor<1xf32> + %10 = stablehlo.reshape %9 : (tensor<1xf32>) -> tensor<1x1xf32> + %11 = stablehlo.pad %10, %cst, low = [0, 0], high = [4, 0], interior = [0, 0] : (tensor<1x1xf32>, tensor) -> tensor<5x1xf32> + %12:2 = stablehlo.while(%iterArg_3 = %11, %iterArg_4 = %c_0) : tensor<5x1xf32>, tensor attributes {operandSegmentSizes = dense<2> : tensor<1xi32>} + cond { + %16 = stablehlo.compare LT, %iterArg_4, %c, SIGNED : (tensor, tensor) -> tensor + stablehlo.return %16 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } do { + %16 = stablehlo.dynamic_slice %arg0, %iterArg_4, sizes = [1] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<5xf32>, tensor) -> tensor<1xf32> + %17 = stablehlo.multiply %8, %16 : tensor<1xf32> + %18 = stablehlo.reshape %17 : (tensor<1xf32>) -> tensor<1x1xf32> + %19 = stablehlo.dynamic_update_slice %iterArg_3, %18, %iterArg_4, %c_1 {operandSegmentSizes = dense<[1, 1, 2]> : tensor<3xi32>} : (tensor<5x1xf32>, tensor<1x1xf32>, tensor, tensor) -> tensor<5x1xf32> + %20 = stablehlo.add %iterArg_4, %c_0 : tensor + stablehlo.return %19, %20 {operandSegmentSizes = dense<2> : tensor<1xi32>} : tensor<5x1xf32>, tensor + } + %13 = stablehlo.reshape %12#0 : (tensor<5x1xf32>) -> tensor<1x5x1xf32> + %14 = stablehlo.dynamic_update_slice %iterArg, %13, %iterArg_2, %c_1, %c_1 {operandSegmentSizes = dense<[1, 1, 3]> : tensor<3xi32>} : (tensor<5x5x1xf32>, tensor<1x5x1xf32>, tensor, tensor, tensor) -> tensor<5x5x1xf32> + %15 = stablehlo.add %iterArg_2, %c_0 : tensor + stablehlo.return %14, %15 {operandSegmentSizes = dense<2> : tensor<1xi32>} : tensor<5x5x1xf32>, tensor + } + return %7#0 : tensor<5x5x1xf32> + } +} diff --git a/zml/test_data/snapshot/ops.test.simple while/fn (ops.test.simple while.CountInts, Tensor, Tensor) [2]Tensor_ba74471b89106421.mlir b/zml/test_data/snapshot/ops.test.simple while/fn (ops.test.simple while.CountInts, Tensor, Tensor) [2]Tensor_ba74471b89106421.mlir new file mode 100644 index 00000000..dc5c9151 --- /dev/null +++ b/zml/test_data/snapshot/ops.test.simple while/fn (ops.test.simple while.CountInts, Tensor, Tensor) [2]Tensor_ba74471b89106421.mlir @@ -0,0 +1,16 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<2> : tensor + %0 = stablehlo.multiply %arg2, %c : tensor + %1:2 = stablehlo.while(%iterArg = %0, %iterArg_0 = %arg3) : tensor, tensor attributes {operandSegmentSizes = dense<2> : tensor<1xi32>} + cond { + %2 = stablehlo.compare LT, %iterArg, %arg1, SIGNED : (tensor, tensor) -> tensor + stablehlo.return %2 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } do { + %2 = stablehlo.add %iterArg, %arg0 : tensor + %3 = stablehlo.add %iterArg_0, %iterArg : tensor + stablehlo.return %2, %3 {operandSegmentSizes = dense<2> : tensor<1xi32>} : tensor, tensor + } + return %1#0, %1#1 : tensor, tensor + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.Rng.decltest.gumbel/fn (Tensor.Rng, Tensor) struct { Tensor.Rng, Tensor.Rng.decltest.gumbel.Stats }_e3baa2046c4de947.mlir b/zml/test_data/snapshot/tensor.Tensor.Rng.decltest.gumbel/fn (Tensor.Rng, Tensor) struct { Tensor.Rng, Tensor.Rng.decltest.gumbel.Stats }_e3baa2046c4de947.mlir new file mode 100644 index 00000000..7ed668c5 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.Rng.decltest.gumbel/fn (Tensor.Rng, Tensor) struct { Tensor.Rng, Tensor.Rng.decltest.gumbel.Stats }_e3baa2046c4de947.mlir @@ -0,0 +1,88 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2xui64> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}", tf.aliasing_output = 0 : i32}, %arg1: tensor<4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2xui64> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<1xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<1xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<1.024000e+03> : tensor + %c = stablehlo.constant dense<0> : tensor + %c_0 = stablehlo.constant dense<0> : tensor + %cst_1 = stablehlo.constant dense<0xFF800000> : tensor + %c_2 = stablehlo.constant dense<[1, 65536, 4294967296, 281474976710656]> : tensor<4xui64> + %cst_3 = stablehlo.constant dense<2.000000e+00> : tensor + %cst_4 = stablehlo.constant dense<4.096000e+03> : tensor + %cst_5 = stablehlo.constant dense<0.000000e+00> : tensor + %cst_6 = stablehlo.constant dense<-1.000000e+00> : tensor + %cst_7 = stablehlo.constant dense<1.1920929E-7> : tensor + %cst_8 = stablehlo.constant dense<0.99999988> : tensor + %cst_9 = stablehlo.constant dense<1.000000e+00> : tensor + %c_10 = stablehlo.constant dense<9> : tensor + %output_state, %output = stablehlo.rng_bit_generator %arg0, algorithm = DEFAULT : (tensor<2xui64>) -> (tensor<2xui64>, tensor<1024x4xui32>) + %0 = stablehlo.broadcast_in_dim %c_10, dims = [] : (tensor) -> tensor<1024x4xui32> + %1 = stablehlo.shift_right_logical %output, %0 : tensor<1024x4xui32> + %2 = stablehlo.bitcast_convert %cst_9 : (tensor) -> tensor + %3 = stablehlo.broadcast_in_dim %2, dims = [] : (tensor) -> tensor<1024x4xui32> + %4 = stablehlo.or %1, %3 : tensor<1024x4xui32> + %5 = stablehlo.bitcast_convert %4 : (tensor<1024x4xui32>) -> tensor<1024x4xf32> + %6 = stablehlo.broadcast_in_dim %cst_9, dims = [] : (tensor) -> tensor<1024x4xf32> + %7 = stablehlo.subtract %5, %6 : tensor<1024x4xf32> + %8 = stablehlo.broadcast_in_dim %cst_8, dims = [] : (tensor) -> tensor<1024x4xf32> + %9 = stablehlo.multiply %7, %8 : tensor<1024x4xf32> + %10 = stablehlo.broadcast_in_dim %cst_7, dims = [] : (tensor) -> tensor<1024x4xf32> + %11 = stablehlo.add %9, %10 : tensor<1024x4xf32> + %12 = stablehlo.log %11 : tensor<1024x4xf32> + %13 = stablehlo.broadcast_in_dim %cst_6, dims = [] : (tensor) -> tensor<1024x4xf32> + %14 = stablehlo.multiply %12, %13 : tensor<1024x4xf32> + %15 = stablehlo.log %14 : tensor<1024x4xf32> + %16 = stablehlo.multiply %15, %13 : tensor<1024x4xf32> + %17 = stablehlo.reshape %16 : (tensor<1024x4xf32>) -> tensor<4096xf32> + %18 = stablehlo.reduce(%17 init: %cst_5) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<4096xf32>, tensor) -> tensor + reducer(%arg2: tensor, %arg3: tensor) { + %45 = stablehlo.add %arg3, %arg2 : tensor + stablehlo.return %45 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %19 = stablehlo.broadcast_in_dim %18, dims = [] : (tensor) -> tensor<1xf32> + %20 = stablehlo.broadcast_in_dim %cst_4, dims = [] : (tensor) -> tensor<1xf32> + %21 = stablehlo.divide %19, %20 : tensor<1xf32> + %22 = stablehlo.broadcast_in_dim %21, dims = [0] : (tensor<1xf32>) -> tensor<4096xf32> + %23 = stablehlo.subtract %17, %22 : tensor<4096xf32> + %24 = stablehlo.broadcast_in_dim %cst_3, dims = [] : (tensor) -> tensor<4096xf32> + %25 = stablehlo.power %23, %24 : tensor<4096xf32> + %26 = stablehlo.reduce(%25 init: %cst_5) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<4096xf32>, tensor) -> tensor + reducer(%arg2: tensor, %arg3: tensor) { + %45 = stablehlo.add %arg3, %arg2 : tensor + stablehlo.return %45 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %27 = stablehlo.broadcast_in_dim %26, dims = [] : (tensor) -> tensor<1xf32> + %28 = stablehlo.divide %27, %20 : tensor<1xf32> + %29 = stablehlo.log %arg1 : tensor<4xf32> + %30 = stablehlo.broadcast_in_dim %29, dims = [1] : (tensor<4xf32>) -> tensor<1024x4xf32> + %31 = stablehlo.add %30, %16 : tensor<1024x4xf32> + %32 = stablehlo.iota dim = 0 : tensor<4xi32> + %33 = stablehlo.broadcast_in_dim %32, dims = [1] : (tensor<4xi32>) -> tensor<1024x4xi32> + %34:2 = stablehlo.reduce(%31 init: %cst_1), (%33 init: %c_0) across dimensions = [1] {operandSegmentSizes = dense<2> : tensor<2xi32>} : (tensor<1024x4xf32>, tensor<1024x4xi32>, tensor, tensor) -> (tensor<1024xf32>, tensor<1024xi32>) + reducer(%arg2: tensor, %arg4: tensor) (%arg3: tensor, %arg5: tensor) { + %45 = stablehlo.compare GT, %arg2, %arg4, FLOAT : (tensor, tensor) -> tensor + %46 = stablehlo.compare NE, %arg2, %arg2, FLOAT : (tensor, tensor) -> tensor + %47 = stablehlo.or %45, %46 : tensor + %48 = stablehlo.select %47, %arg2, %arg4 : tensor, tensor + %49 = stablehlo.compare EQ, %arg2, %arg4, FLOAT : (tensor, tensor) -> tensor + %50 = stablehlo.compare LT, %arg3, %arg5, SIGNED : (tensor, tensor) -> tensor + %51 = stablehlo.and %49, %50 : tensor + %52 = stablehlo.or %47, %51 : tensor + %53 = stablehlo.select %52, %arg3, %arg5 : tensor, tensor + stablehlo.return %48, %53 {operandSegmentSizes = dense<2> : tensor<1xi32>} : tensor, tensor + } + %35 = stablehlo.broadcast_in_dim %34#1, dims = [0] : (tensor<1024xi32>) -> tensor<1024x1xi32> + %36 = stablehlo.reshape %35 : (tensor<1024x1xi32>) -> tensor<1024xi32> + %37 = "stablehlo.gather"(%c_2, %36) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = false, slice_sizes = array}> : (tensor<4xui64>, tensor<1024xi32>) -> tensor<1024xui64> + %38 = stablehlo.reduce(%37 init: %c) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1024xui64>, tensor) -> tensor + reducer(%arg2: tensor, %arg3: tensor) { + %45 = stablehlo.add %arg3, %arg2 : tensor + stablehlo.return %45 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %39 = stablehlo.broadcast_in_dim %38, dims = [] : (tensor) -> tensor<1xui64> + %40 = stablehlo.bitcast_convert %39 : (tensor<1xui64>) -> tensor<1x4xui16> + %41 = stablehlo.reshape %40 : (tensor<1x4xui16>) -> tensor<4xui16> + %42 = stablehlo.convert %41 : (tensor<4xui16>) -> tensor<4xf32> + %43 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<4xf32> + %44 = stablehlo.divide %42, %43 : tensor<4xf32> + return %output_state, %21, %28, %44 : tensor<2xui64>, tensor<1xf32>, tensor<1xf32>, tensor<4xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.Rng.decltest.uniform/fn (Tensor.Rng, Shape, Tensor.Rng.decltest.uniform.Stats.uniformStats__struct_199888) struct { Tensor.Rng, Tensor.Rng.decltest.uniform.Stats }_babf4bd850f5fbe7.mlir b/zml/test_data/snapshot/tensor.Tensor.Rng.decltest.uniform/fn (Tensor.Rng, Shape, Tensor.Rng.decltest.uniform.Stats.uniformStats__struct_199888) struct { Tensor.Rng, Tensor.Rng.decltest.uniform.Stats }_babf4bd850f5fbe7.mlir new file mode 100644 index 00000000..6335c448 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.Rng.decltest.uniform/fn (Tensor.Rng, Shape, Tensor.Rng.decltest.uniform.Stats.uniformStats__struct_199888) struct { Tensor.Rng, Tensor.Rng.decltest.uniform.Stats }_babf4bd850f5fbe7.mlir @@ -0,0 +1,58 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2xui64> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}", tf.aliasing_output = 0 : i32}) -> (tensor<2xui64> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<1xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<1xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<1xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<1xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<0xFF800000> : tensor + %cst_0 = stablehlo.constant dense<0x7F800000> : tensor + %cst_1 = stablehlo.constant dense<2.000000e+00> : tensor + %cst_2 = stablehlo.constant dense<1.024000e+03> : tensor + %cst_3 = stablehlo.constant dense<0.000000e+00> : tensor + %cst_4 = stablehlo.constant dense<-2.000000e+00> : tensor + %cst_5 = stablehlo.constant dense<1.200000e+01> : tensor + %cst_6 = stablehlo.constant dense<1.000000e+00> : tensor + %c = stablehlo.constant dense<9> : tensor + %output_state, %output = stablehlo.rng_bit_generator %arg0, algorithm = DEFAULT : (tensor<2xui64>) -> (tensor<2xui64>, tensor<1024xui32>) + %0 = stablehlo.broadcast_in_dim %c, dims = [] : (tensor) -> tensor<1024xui32> + %1 = stablehlo.shift_right_logical %output, %0 : tensor<1024xui32> + %2 = stablehlo.bitcast_convert %cst_6 : (tensor) -> tensor + %3 = stablehlo.broadcast_in_dim %2, dims = [] : (tensor) -> tensor<1024xui32> + %4 = stablehlo.or %1, %3 : tensor<1024xui32> + %5 = stablehlo.bitcast_convert %4 : (tensor<1024xui32>) -> tensor<1024xf32> + %6 = stablehlo.broadcast_in_dim %cst_6, dims = [] : (tensor) -> tensor<1024xf32> + %7 = stablehlo.subtract %5, %6 : tensor<1024xf32> + %8 = stablehlo.broadcast_in_dim %cst_5, dims = [] : (tensor) -> tensor<1024xf32> + %9 = stablehlo.multiply %7, %8 : tensor<1024xf32> + %10 = stablehlo.broadcast_in_dim %cst_4, dims = [] : (tensor) -> tensor<1024xf32> + %11 = stablehlo.add %9, %10 : tensor<1024xf32> + %12 = stablehlo.reduce(%11 init: %cst_3) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1024xf32>, tensor) -> tensor + reducer(%arg1: tensor, %arg2: tensor) { + %27 = stablehlo.add %arg2, %arg1 : tensor + stablehlo.return %27 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %13 = stablehlo.broadcast_in_dim %12, dims = [] : (tensor) -> tensor<1xf32> + %14 = stablehlo.broadcast_in_dim %cst_2, dims = [] : (tensor) -> tensor<1xf32> + %15 = stablehlo.divide %13, %14 : tensor<1xf32> + %16 = stablehlo.broadcast_in_dim %15, dims = [0] : (tensor<1xf32>) -> tensor<1024xf32> + %17 = stablehlo.subtract %11, %16 : tensor<1024xf32> + %18 = stablehlo.broadcast_in_dim %cst_1, dims = [] : (tensor) -> tensor<1024xf32> + %19 = stablehlo.power %17, %18 : tensor<1024xf32> + %20 = stablehlo.reduce(%19 init: %cst_3) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1024xf32>, tensor) -> tensor + reducer(%arg1: tensor, %arg2: tensor) { + %27 = stablehlo.add %arg2, %arg1 : tensor + stablehlo.return %27 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %21 = stablehlo.broadcast_in_dim %20, dims = [] : (tensor) -> tensor<1xf32> + %22 = stablehlo.divide %21, %14 : tensor<1xf32> + %23 = stablehlo.reduce(%11 init: %cst_0) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1024xf32>, tensor) -> tensor + reducer(%arg1: tensor, %arg2: tensor) { + %27 = stablehlo.minimum %arg2, %arg1 : tensor + stablehlo.return %27 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %24 = stablehlo.broadcast_in_dim %23, dims = [] : (tensor) -> tensor<1xf32> + %25 = stablehlo.reduce(%11 init: %cst) across dimensions = [0] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<1024xf32>, tensor) -> tensor + reducer(%arg1: tensor, %arg2: tensor) { + %27 = stablehlo.maximum %arg2, %arg1 : tensor + stablehlo.return %27 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + } + %26 = stablehlo.broadcast_in_dim %25, dims = [] : (tensor) -> tensor<1xf32> + return %output_state, %15, %22, %24, %26 : tensor<2xui64>, tensor<1xf32>, tensor<1xf32>, tensor<1xf32>, tensor<1xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.argMax/fn (Tensor) Tensor.ArgMaxRes_e51ff236eeeaadfa.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.argMax/fn (Tensor) Tensor.ArgMaxRes_e51ff236eeeaadfa.mlir new file mode 100644 index 00000000..d082b40b --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.argMax/fn (Tensor) Tensor.ArgMaxRes_e51ff236eeeaadfa.mlir @@ -0,0 +1,24 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x1xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<1x1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %cst = stablehlo.constant dense<0xFF800000> : tensor + %0 = stablehlo.iota dim = 0 : tensor<5xi32> + %1 = stablehlo.broadcast_in_dim %0, dims = [1] : (tensor<5xi32>) -> tensor<1x5xi32> + %2:2 = stablehlo.reduce(%arg0 init: %cst), (%1 init: %c) across dimensions = [1] {operandSegmentSizes = dense<2> : tensor<2xi32>} : (tensor<1x5xf32>, tensor<1x5xi32>, tensor, tensor) -> (tensor<1xf32>, tensor<1xi32>) + reducer(%arg1: tensor, %arg3: tensor) (%arg2: tensor, %arg4: tensor) { + %5 = stablehlo.compare GT, %arg1, %arg3, FLOAT : (tensor, tensor) -> tensor + %6 = stablehlo.compare NE, %arg1, %arg1, FLOAT : (tensor, tensor) -> tensor + %7 = stablehlo.or %5, %6 : tensor + %8 = stablehlo.select %7, %arg1, %arg3 : tensor, tensor + %9 = stablehlo.compare EQ, %arg1, %arg3, FLOAT : (tensor, tensor) -> tensor + %10 = stablehlo.compare LT, %arg2, %arg4, SIGNED : (tensor, tensor) -> tensor + %11 = stablehlo.and %9, %10 : tensor + %12 = stablehlo.or %7, %11 : tensor + %13 = stablehlo.select %12, %arg2, %arg4 : tensor, tensor + stablehlo.return %8, %13 {operandSegmentSizes = dense<2> : tensor<1xi32>} : tensor, tensor + } + %3 = stablehlo.broadcast_in_dim %2#0, dims = [0] : (tensor<1xf32>) -> tensor<1x1xf32> + %4 = stablehlo.broadcast_in_dim %2#1, dims = [0] : (tensor<1xi32>) -> tensor<1x1xi32> + return %3, %4 : tensor<1x1xf32>, tensor<1x1xi32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.argsort/fn (Tensor, u3, Tensor.ArgSortOpts) Tensor_b9d3aceaaa8fce1b.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.argsort/fn (Tensor, u3, Tensor.ArgSortOpts) Tensor_b9d3aceaaa8fce1b.mlir new file mode 100644 index 00000000..40bc06cb --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.argsort/fn (Tensor, u3, Tensor.ArgSortOpts) Tensor_b9d3aceaaa8fce1b.mlir @@ -0,0 +1,12 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<4x2x1x4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<4x2x1x4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.iota dim = 0 : tensor<4xi32> + %1 = stablehlo.broadcast_in_dim %0, dims = [3] : (tensor<4xi32>) -> tensor<4x2x1x4xi32> + %2:2 = "stablehlo.sort"(%arg0, %1) <{dimension = 3 : i64, is_stable = true}> ({ + ^bb0(%arg1: tensor, %arg2: tensor, %arg3: tensor, %arg4: tensor): + %3 = stablehlo.compare LT, %arg1, %arg2, SIGNED : (tensor, tensor) -> tensor + stablehlo.return %3 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + }) {operandSegmentSizes = dense<2> : tensor<1xi32>} : (tensor<4x2x1x4xi32>, tensor<4x2x1x4xi32>) -> (tensor<4x2x1x4xi32>, tensor<4x2x1x4xi32>) + return %2#1 : tensor<4x2x1x4xi32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.argsort/fn (Tensor, u3, Tensor.ArgSortOpts) Tensor_d5ba130ca24deacf.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.argsort/fn (Tensor, u3, Tensor.ArgSortOpts) Tensor_d5ba130ca24deacf.mlir new file mode 100644 index 00000000..da62c745 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.argsort/fn (Tensor, u3, Tensor.ArgSortOpts) Tensor_d5ba130ca24deacf.mlir @@ -0,0 +1,12 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x5xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.iota dim = 0 : tensor<5xi32> + %1 = stablehlo.broadcast_in_dim %0, dims = [1] : (tensor<5xi32>) -> tensor<2x5xi32> + %2:2 = "stablehlo.sort"(%arg0, %1) <{dimension = 1 : i64, is_stable = true}> ({ + ^bb0(%arg1: tensor, %arg2: tensor, %arg3: tensor, %arg4: tensor): + %3 = stablehlo.compare LT, %arg1, %arg2, FLOAT : (tensor, tensor) -> tensor + stablehlo.return %3 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + }) {operandSegmentSizes = dense<2> : tensor<1xi32>} : (tensor<2x5xf32>, tensor<2x5xi32>) -> (tensor<2x5xf32>, tensor<2x5xi32>) + return %2#1 : tensor<2x5xi32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.argsort/fn (Tensor, u3, Tensor.ArgSortOpts) Tensor_ec74630dd923db38.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.argsort/fn (Tensor, u3, Tensor.ArgSortOpts) Tensor_ec74630dd923db38.mlir new file mode 100644 index 00000000..abd60f92 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.argsort/fn (Tensor, u3, Tensor.ArgSortOpts) Tensor_ec74630dd923db38.mlir @@ -0,0 +1,12 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x5x10xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x5x10xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.iota dim = 0 : tensor<5xi32> + %1 = stablehlo.broadcast_in_dim %0, dims = [1] : (tensor<5xi32>) -> tensor<1x5x10xi32> + %2:2 = "stablehlo.sort"(%arg0, %1) <{dimension = 1 : i64, is_stable = true}> ({ + ^bb0(%arg1: tensor, %arg2: tensor, %arg3: tensor, %arg4: tensor): + %3 = stablehlo.compare GT, %arg1, %arg2, FLOAT : (tensor, tensor) -> tensor + stablehlo.return %3 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + }) {operandSegmentSizes = dense<2> : tensor<1xi32>} : (tensor<1x5x10xf16>, tensor<1x5x10xi32>) -> (tensor<1x5x10xf16>, tensor<1x5x10xi32>) + return %2#1 : tensor<1x5x10xi32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.cartesianProduct/fn (Tensor, Tensor) [2]Tensor_c363d77d6848ab99.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.cartesianProduct/fn (Tensor, Tensor) [2]Tensor_c363d77d6848ab99.mlir new file mode 100644 index 00000000..6929024b --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.cartesianProduct/fn (Tensor, Tensor) [2]Tensor_c363d77d6848ab99.mlir @@ -0,0 +1,7 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<6xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<6x4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<6x4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.broadcast_in_dim %arg0, dims = [0] : (tensor<6xi32>) -> tensor<6x4xi32> + %1 = stablehlo.broadcast_in_dim %arg1, dims = [1] : (tensor<4xi32>) -> tensor<6x4xi32> + return %0, %1 : tensor<6x4xi32>, tensor<6x4xi32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.cartesianProductStacked/fn (Tensor, Tensor) Tensor_c363d77d6848ab99.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.cartesianProductStacked/fn (Tensor, Tensor) Tensor_c363d77d6848ab99.mlir new file mode 100644 index 00000000..a2c92430 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.cartesianProductStacked/fn (Tensor, Tensor) Tensor_c363d77d6848ab99.mlir @@ -0,0 +1,10 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<6xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<6x4x2xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.broadcast_in_dim %arg0, dims = [0] : (tensor<6xi32>) -> tensor<6x4xi32> + %1 = stablehlo.reshape %0 : (tensor<6x4xi32>) -> tensor<6x4x1xi32> + %2 = stablehlo.broadcast_in_dim %arg1, dims = [1] : (tensor<4xi32>) -> tensor<6x4xi32> + %3 = stablehlo.reshape %2 : (tensor<6x4xi32>) -> tensor<6x4x1xi32> + %4 = stablehlo.concatenate %1, %3, dim = 2 : (tensor<6x4x1xi32>, tensor<6x4x1xi32>) -> tensor<6x4x2xi32> + return %4 : tensor<6x4x2xi32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.cumulativeSum/fn (Tensor) Tensor_779cc7a90f1d047d.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.cumulativeSum/fn (Tensor) Tensor_779cc7a90f1d047d.mlir new file mode 100644 index 00000000..b8784c97 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.cumulativeSum/fn (Tensor) Tensor_779cc7a90f1d047d.mlir @@ -0,0 +1,11 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %0 = "stablehlo.reduce_window"(%arg0, %cst) <{base_dilations = array, padding = dense<[[0, 0], [4, 0]]> : tensor<2x2xi64>, window_dilations = array, window_dimensions = array, window_strides = array}> ({ + ^bb0(%arg1: tensor, %arg2: tensor): + %1 = stablehlo.add %arg1, %arg2 : tensor + stablehlo.return %1 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + }) {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<2x5xf32>, tensor) -> tensor<2x5xf32> + return %0 : tensor<2x5xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicSlice/fn (Tensor, i8, Tensor.DynSlice) Tensor_813c9ac780d541e.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicSlice/fn (Tensor, i8, Tensor.DynSlice) Tensor_813c9ac780d541e.mlir new file mode 100644 index 00000000..e5c307f3 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicSlice/fn (Tensor, i8, Tensor.DynSlice) Tensor_813c9ac780d541e.mlir @@ -0,0 +1,7 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %0 = stablehlo.dynamic_slice %arg0, %c, %arg1, sizes = [2, 2] {operandSegmentSizes = dense<[1, 2]> : tensor<2xi32>} : (tensor<2x5xf32>, tensor, tensor) -> tensor<2x2xf32> + return %0 : tensor<2x2xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicSlice/fn (Tensor, i8, Tensor.DynSlice) Tensor_e2569044b377362b.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicSlice/fn (Tensor, i8, Tensor.DynSlice) Tensor_e2569044b377362b.mlir new file mode 100644 index 00000000..c305c75b --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicSlice/fn (Tensor, i8, Tensor.DynSlice) Tensor_e2569044b377362b.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.dynamic_slice %arg0, %arg1, sizes = [2] {operandSegmentSizes = dense<1> : tensor<2xi32>} : (tensor<10xf32>, tensor) -> tensor<2xf32> + return %0 : tensor<2xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor, Tensor) Tensor_a0a798addd49e74f.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor, Tensor) Tensor_a0a798addd49e74f.mlir new file mode 100644 index 00000000..ab49f07b --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor, Tensor) Tensor_a0a798addd49e74f.mlir @@ -0,0 +1,7 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<2x1xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %0 = stablehlo.dynamic_update_slice %arg0, %arg2, %c, %arg1 {operandSegmentSizes = dense<[1, 1, 2]> : tensor<3xi32>} : (tensor<2x5xf32>, tensor<2x1xf32>, tensor, tensor) -> tensor<2x5xf32> + return %0 : tensor<2x5xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor, Tensor) Tensor_ff069b5e746c5326.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor, Tensor) Tensor_ff069b5e746c5326.mlir new file mode 100644 index 00000000..71fb016d --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor, Tensor) Tensor_ff069b5e746c5326.mlir @@ -0,0 +1,8 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %0 = stablehlo.reshape %arg2 : (tensor<2xf32>) -> tensor<2x1xf32> + %1 = stablehlo.dynamic_update_slice %arg0, %0, %c, %arg1 {operandSegmentSizes = dense<[1, 1, 2]> : tensor<3xi32>} : (tensor<2x5xf32>, tensor<2x1xf32>, tensor, tensor) -> tensor<2x5xf32> + return %1 : tensor<2x5xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor.decltest.dynamicUpdateSlice__struct_136623._fwd__struct_136624, Tensor) Tensor_46e7a0832247bfa7.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor.decltest.dynamicUpdateSlice__struct_136623._fwd__struct_136624, Tensor) Tensor_46e7a0832247bfa7.mlir new file mode 100644 index 00000000..dcd657f8 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor.decltest.dynamicUpdateSlice__struct_136623._fwd__struct_136624, Tensor) Tensor_46e7a0832247bfa7.mlir @@ -0,0 +1,7 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<10xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.reshape %arg2 : (tensor<2xf32>) -> tensor<2xf32> + %1 = stablehlo.dynamic_update_slice %arg0, %0, %arg1 {operandSegmentSizes = dense<1> : tensor<3xi32>} : (tensor<10xf32>, tensor<2xf32>, tensor) -> tensor<10xf32> + return %1 : tensor<10xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor.decltest.dynamicUpdateSlice__struct_137078._fwd__struct_137079, Tensor) Tensor_d338b5d4d8f6f271.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor.decltest.dynamicUpdateSlice__struct_137078._fwd__struct_137079, Tensor) Tensor_d338b5d4d8f6f271.mlir new file mode 100644 index 00000000..6015cca2 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, Tensor.decltest.dynamicUpdateSlice__struct_137078._fwd__struct_137079, Tensor) Tensor_d338b5d4d8f6f271.mlir @@ -0,0 +1,7 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor<1xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.reshape %arg3 : (tensor<1xf32>) -> tensor<1x1xf32> + %1 = stablehlo.dynamic_update_slice %arg0, %0, %arg1, %arg2 {operandSegmentSizes = dense<[1, 1, 2]> : tensor<3xi32>} : (tensor<2x5xf32>, tensor<1x1xf32>, tensor, tensor) -> tensor<2x5xf32> + return %1 : tensor<2x5xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, [2]Tensor, Tensor) Tensor_d52db17c5ad49d8c.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, [2]Tensor, Tensor) Tensor_d52db17c5ad49d8c.mlir new file mode 100644 index 00000000..039e4dfc --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.dynamicUpdateSlice/fn (Tensor, [2]Tensor, Tensor) Tensor_d52db17c5ad49d8c.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg3: tensor<1x1xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.dynamic_update_slice %arg0, %arg3, %arg1, %arg2 {operandSegmentSizes = dense<[1, 1, 2]> : tensor<3xi32>} : (tensor<2x5xf32>, tensor<1x1xf32>, tensor, tensor) -> tensor<2x5xf32> + return %0 : tensor<2x5xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.fmod/fn (Tensor, f32) Tensor_5d1e6508b3dc3548.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.fmod/fn (Tensor, f32) Tensor_5d1e6508b3dc3548.mlir new file mode 100644 index 00000000..b5051652 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.fmod/fn (Tensor, f32) Tensor_5d1e6508b3dc3548.mlir @@ -0,0 +1,8 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<6xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<6xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<2.000000e+00> : tensor + %0 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<6xf32> + %1 = stablehlo.remainder %arg0, %0 : tensor<6xf32> + return %1 : tensor<6xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.fmod/fn (Tensor, f32) Tensor_d30d7323e1e93b70.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.fmod/fn (Tensor, f32) Tensor_d30d7323e1e93b70.mlir new file mode 100644 index 00000000..c5689eee --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.fmod/fn (Tensor, f32) Tensor_d30d7323e1e93b70.mlir @@ -0,0 +1,8 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<6xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<6xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<-1.500000e+00> : tensor + %0 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<6xf32> + %1 = stablehlo.remainder %arg0, %0 : tensor<6xf32> + return %1 : tensor<6xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_1cf22f2965934f5b.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_1cf22f2965934f5b.mlir new file mode 100644 index 00000000..03399925 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_1cf22f2965934f5b.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<1x8xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<8x7xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<10xf16>, tensor<1x8xi32>) -> tensor<8x7xf16> + return %0 : tensor<8x7xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_42b1906b87448f2a.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_42b1906b87448f2a.mlir new file mode 100644 index 00000000..f5d77d25 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_42b1906b87448f2a.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10x20xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<8x1x9xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<8x9x7x20xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<10x20xf16>, tensor<8x1x9xi32>) -> tensor<8x9x7x20xf16> + return %0 : tensor<8x9x7x20xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_4f75e8d518c3b3d1.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_4f75e8d518c3b3d1.mlir new file mode 100644 index 00000000..3733d132 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_4f75e8d518c3b3d1.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10x20xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<8x1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<8x7x20xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<10x20xf16>, tensor<8x1xi32>) -> tensor<8x7x20xf16> + return %0 : tensor<8x7x20xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_57a53a95ad472953.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_57a53a95ad472953.mlir new file mode 100644 index 00000000..4e853d25 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_57a53a95ad472953.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10x20xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<8x2xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<8x7x17xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<10x20xf16>, tensor<8x2xi32>) -> tensor<8x7x17xf16> + return %0 : tensor<8x7x17xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_5dec99541d53e940.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_5dec99541d53e940.mlir new file mode 100644 index 00000000..08486b0e --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_5dec99541d53e940.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<8x1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<8x7xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<10xf16>, tensor<8x1xi32>) -> tensor<8x7xf16> + return %0 : tensor<8x7xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_6def9230a7bcb902.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_6def9230a7bcb902.mlir new file mode 100644 index 00000000..d9b48859 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_6def9230a7bcb902.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<200x100x300xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<100x200x1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<100x200x300xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<200x100x300xf16>, tensor<100x200x1xi32>) -> tensor<100x200x300xf16> + return %0 : tensor<100x200x300xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_734d155694f71e37.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_734d155694f71e37.mlir new file mode 100644 index 00000000..ff8d9703 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_734d155694f71e37.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10x20xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<7x20xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<10x20xf16>, tensor<1xi32>) -> tensor<7x20xf16> + return %0 : tensor<7x20xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_77e9e196d9455f4c.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_77e9e196d9455f4c.mlir new file mode 100644 index 00000000..08486b0e --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_77e9e196d9455f4c.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<8x1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<8x7xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<10xf16>, tensor<8x1xi32>) -> tensor<8x7xf16> + return %0 : tensor<8x7xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_79da0dfda896d57e.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_79da0dfda896d57e.mlir new file mode 100644 index 00000000..ddffd244 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_79da0dfda896d57e.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<0xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<10xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<10xf16>, tensor<0xi32>) -> tensor<10xf16> + return %0 : tensor<10xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_7c379e03680deb5.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_7c379e03680deb5.mlir new file mode 100644 index 00000000..f7defcd5 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_7c379e03680deb5.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x4x6xui16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<2x2xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x2x2x3xui16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = false, slice_sizes = array}> : (tensor<2x4x6xui16>, tensor<2x2xi32>) -> tensor<2x2x2x3xui16> + return %0 : tensor<2x2x2x3xui16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_90254835651ba6f9.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_90254835651ba6f9.mlir new file mode 100644 index 00000000..3a691f1d --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_90254835651ba6f9.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<7xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<10xf16>, tensor<1xi32>) -> tensor<7xf16> + return %0 : tensor<7xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_b1b532a17c0c7821.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_b1b532a17c0c7821.mlir new file mode 100644 index 00000000..72c4a722 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_b1b532a17c0c7821.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10x20xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<8x1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<8x10x17xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<10x20xf16>, tensor<8x1xi32>) -> tensor<8x10x17xf16> + return %0 : tensor<8x10x17xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_b5aa3ebec7cf79f1.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_b5aa3ebec7cf79f1.mlir new file mode 100644 index 00000000..4e853d25 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_b5aa3ebec7cf79f1.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10x20xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<8x2xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<8x7x17xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<10x20xf16>, tensor<8x2xi32>) -> tensor<8x7x17xf16> + return %0 : tensor<8x7x17xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_ddbdd3f5dda057f8.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_ddbdd3f5dda057f8.mlir new file mode 100644 index 00000000..f6622672 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_ddbdd3f5dda057f8.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10x20x20xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<8x1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<8x10x17x20xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<10x20x20xf16>, tensor<8x1xi32>) -> tensor<8x10x17x20xf16> + return %0 : tensor<8x10x17x20xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_e28657b86fe33ba2.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_e28657b86fe33ba2.mlir new file mode 100644 index 00000000..6772223f --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.gatherSlices/fn (Tensor, Shape, Tensor, Tensor.GatherOpts) Tensor_e28657b86fe33ba2.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10x20xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<10x1xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<10x17xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = "stablehlo.gather"(%arg0, %arg1) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = true, slice_sizes = array}> : (tensor<10x20xf16>, tensor<10x1xi32>) -> tensor<10x17xf16> + return %0 : tensor<10x17xf16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.leakyReLU/fn (Tensor, f32) Tensor_381ab030e7ccb9d5.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.leakyReLU/fn (Tensor, f32) Tensor_381ab030e7ccb9d5.mlir new file mode 100644 index 00000000..59ba281f --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.leakyReLU/fn (Tensor, f32) Tensor_381ab030e7ccb9d5.mlir @@ -0,0 +1,13 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<1.000000e-01> : tensor + %cst_0 = stablehlo.constant dense<0.000000e+00> : tensor + %0 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<2xf32> + %1 = stablehlo.maximum %arg0, %0 : tensor<2xf32> + %2 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<2xf32> + %3 = stablehlo.multiply %arg0, %2 : tensor<2xf32> + %4 = stablehlo.minimum %3, %0 : tensor<2xf32> + %5 = stablehlo.add %1, %4 : tensor<2xf32> + return %5 : tensor<2xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.scalar/fn () [6]Tensor_409638ee2bde459.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.scalar/fn () [6]Tensor_409638ee2bde459.mlir new file mode 100644 index 00000000..54b236ae --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.scalar/fn () [6]Tensor_409638ee2bde459.mlir @@ -0,0 +1,11 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main() -> (tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense : tensor + %c_0 = stablehlo.constant dense<0> : tensor + %c_1 = stablehlo.constant dense<0> : tensor + %cst = stablehlo.constant dense<0.000000e+00> : tensor + %cst_2 = stablehlo.constant dense<0.000000e+00> : tensor + %c_3 = stablehlo.constant dense<0> : tensor + return %c, %c_0, %c_1, %cst, %cst_2, %c_3 : tensor, tensor, tensor, tensor, tensor, tensor + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.scatterSlices/fn (Tensor, Tensor, Tensor) Tensor_6ae2295e6097dde6.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.scatterSlices/fn (Tensor, Tensor, Tensor) Tensor_6ae2295e6097dde6.mlir new file mode 100644 index 00000000..96ed3e60 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.scatterSlices/fn (Tensor, Tensor, Tensor) Tensor_6ae2295e6097dde6.mlir @@ -0,0 +1,19 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x3x4x2xui16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<2x2x3x2xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<2x2x3x2x2xui16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x3x4x2xui16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.iota dim = 1 : tensor<2x2x3xi32> + %1 = stablehlo.reshape %0 : (tensor<2x2x3xi32>) -> tensor<2x2x3x1xi32> + %2 = stablehlo.slice %arg1 [0:2, 0:2, 0:3, 1:2] : (tensor<2x2x3x2xi32>) -> tensor<2x2x3x1xi32> + %3 = stablehlo.reshape %2 : (tensor<2x2x3x1xi32>) -> tensor<2x2x3xi32> + %4 = stablehlo.reshape %3 : (tensor<2x2x3xi32>) -> tensor<2x2x3x1xi32> + %5 = stablehlo.slice %arg1 [0:2, 0:2, 0:3, 0:1] : (tensor<2x2x3x2xi32>) -> tensor<2x2x3x1xi32> + %6 = stablehlo.reshape %5 : (tensor<2x2x3x1xi32>) -> tensor<2x2x3xi32> + %7 = stablehlo.reshape %6 : (tensor<2x2x3xi32>) -> tensor<2x2x3x1xi32> + %8 = stablehlo.concatenate %1, %4, %7, dim = 3 : (tensor<2x2x3x1xi32>, tensor<2x2x3x1xi32>, tensor<2x2x3x1xi32>) -> tensor<2x2x3x3xi32> + %9 = "stablehlo.scatter"(%arg0, %8, %arg2) <{indices_are_sorted = false, scatter_dimension_numbers = #stablehlo.scatter, unique_indices = false}> ({ + ^bb0(%arg3: tensor, %arg4: tensor): + %10 = stablehlo.add %arg3, %arg4 : tensor + stablehlo.return %10 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + }) {operandSegmentSizes = dense<1> : tensor<3xi32>} : (tensor<2x3x4x2xui16>, tensor<2x2x3x3xi32>, tensor<2x2x3x2x2xui16>) -> tensor<2x3x4x2xui16> + return %9 : tensor<2x3x4x2xui16> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.scatterSlices/fn (Tensor, []const Tensor, Tensor) Tensor_3f024338ab39284b.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.scatterSlices/fn (Tensor, []const Tensor, Tensor) Tensor_3f024338ab39284b.mlir new file mode 100644 index 00000000..44b19c21 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.scatterSlices/fn (Tensor, []const Tensor, Tensor) Tensor_3f024338ab39284b.mlir @@ -0,0 +1,11 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<3x3xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<2xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<2x3xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<3x3xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.reshape %arg1 : (tensor<2xi32>) -> tensor<2x1xi32> + %1 = "stablehlo.scatter"(%arg0, %0, %arg2) <{indices_are_sorted = false, scatter_dimension_numbers = #stablehlo.scatter, unique_indices = false}> ({ + ^bb0(%arg3: tensor, %arg4: tensor): + %2 = stablehlo.add %arg3, %arg4 : tensor + stablehlo.return %2 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + }) {operandSegmentSizes = dense<1> : tensor<3xi32>} : (tensor<3x3xi32>, tensor<2x1xi32>, tensor<2x3xi32>) -> tensor<3x3xi32> + return %1 : tensor<3x3xi32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.scatterSlices/fn (Tensor, []const Tensor, Tensor) Tensor_fb5a1da8ad9bf1fb.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.scatterSlices/fn (Tensor, []const Tensor, Tensor) Tensor_fb5a1da8ad9bf1fb.mlir new file mode 100644 index 00000000..df4bb58e --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.scatterSlices/fn (Tensor, []const Tensor, Tensor) Tensor_fb5a1da8ad9bf1fb.mlir @@ -0,0 +1,11 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<9xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<2xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg2: tensor<2xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<9xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.reshape %arg1 : (tensor<2xi32>) -> tensor<2x1xi32> + %1 = "stablehlo.scatter"(%arg0, %0, %arg2) <{indices_are_sorted = false, scatter_dimension_numbers = #stablehlo.scatter, unique_indices = false}> ({ + ^bb0(%arg3: tensor, %arg4: tensor): + %2 = stablehlo.add %arg3, %arg4 : tensor + stablehlo.return %2 {operandSegmentSizes = dense<1> : tensor<1xi32>} : tensor + }) {operandSegmentSizes = dense<1> : tensor<3xi32>} : (tensor<9xi32>, tensor<2x1xi32>, tensor<2xi32>) -> tensor<9xi32> + return %1 : tensor<9xi32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.slice/fn (Tensor, i8, Tensor.Slice) Tensor_1b9a60f4504a79f6.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.slice/fn (Tensor, i8, Tensor.Slice) Tensor_1b9a60f4504a79f6.mlir new file mode 100644 index 00000000..199da743 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.slice/fn (Tensor, i8, Tensor.Slice) Tensor_1b9a60f4504a79f6.mlir @@ -0,0 +1,7 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.slice %arg0 [0:2, 3:5] : (tensor<2x5xf32>) -> tensor<2x2xf32> + %1 = stablehlo.reshape %0 : (tensor<2x2xf32>) -> tensor<2x2xf32> + return %1 : tensor<2x2xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.slice/fn (Tensor, i8, Tensor.Slice) Tensor_6a8aa7237ca75292.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.slice/fn (Tensor, i8, Tensor.Slice) Tensor_6a8aa7237ca75292.mlir new file mode 100644 index 00000000..b3d803e8 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.slice/fn (Tensor, i8, Tensor.Slice) Tensor_6a8aa7237ca75292.mlir @@ -0,0 +1,7 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.slice %arg0 [0:2, 1:5:2] : (tensor<2x5xf32>) -> tensor<2x2xf32> + %1 = stablehlo.reshape %0 : (tensor<2x2xf32>) -> tensor<2x2xf32> + return %1 : tensor<2x2xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.slice/fn (Tensor, i8, Tensor.Slice) Tensor_ee2c6f0e350d8f21.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.slice/fn (Tensor, i8, Tensor.Slice) Tensor_ee2c6f0e350d8f21.mlir new file mode 100644 index 00000000..747ab5c8 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.slice/fn (Tensor, i8, Tensor.Slice) Tensor_ee2c6f0e350d8f21.mlir @@ -0,0 +1,7 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.slice %arg0 [0:1, 0:5] : (tensor<2x5xf32>) -> tensor<1x5xf32> + %1 = stablehlo.reshape %0 : (tensor<1x5xf32>) -> tensor<1x5xf32> + return %1 : tensor<1x5xf32> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.toDiagonal/fn (Tensor) Tensor_7c9528cf37407f7b.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.toDiagonal/fn (Tensor) Tensor_7c9528cf37407f7b.mlir new file mode 100644 index 00000000..62b4f397 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.toDiagonal/fn (Tensor) Tensor_7c9528cf37407f7b.mlir @@ -0,0 +1,13 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x2xui8> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x2x2xui8> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %0 = stablehlo.iota dim = 1 : tensor<2x2x2xi32> + %1 = stablehlo.iota dim = 2 : tensor<2x2x2xi32> + %2 = stablehlo.compare EQ, %0, %1, SIGNED : (tensor<2x2x2xi32>, tensor<2x2x2xi32>) -> tensor<2x2x2xi1> + %3 = stablehlo.reshape %arg0 : (tensor<2x2xui8>) -> tensor<2x2x1xui8> + %4 = stablehlo.broadcast_in_dim %3, dims = [0, 1, 2] : (tensor<2x2x1xui8>) -> tensor<2x2x2xui8> + %5 = stablehlo.broadcast_in_dim %c, dims = [] : (tensor) -> tensor<2x2x2xui8> + %6 = stablehlo.select %2, %4, %5 : tensor<2x2x2xi1>, tensor<2x2x2xui8> + return %6 : tensor<2x2x2xui8> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.triangular/fn (Tensor, i32) Tensor_3c1415d524fbdb98.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.triangular/fn (Tensor, i32) Tensor_3c1415d524fbdb98.mlir new file mode 100644 index 00000000..8fbf5b86 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.triangular/fn (Tensor, i32) Tensor_3c1415d524fbdb98.mlir @@ -0,0 +1,14 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<3x3xui8> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<3x3xui8> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %c_0 = stablehlo.constant dense<-1> : tensor + %0 = stablehlo.iota dim = 0 : tensor<3x3xi32> + %1 = stablehlo.broadcast_in_dim %c_0, dims = [] : (tensor) -> tensor<3x3xi32> + %2 = stablehlo.add %0, %1 : tensor<3x3xi32> + %3 = stablehlo.iota dim = 1 : tensor<3x3xi32> + %4 = stablehlo.compare GE, %2, %3, SIGNED : (tensor<3x3xi32>, tensor<3x3xi32>) -> tensor<3x3xi1> + %5 = stablehlo.broadcast_in_dim %c, dims = [] : (tensor) -> tensor<3x3xui8> + %6 = stablehlo.select %4, %arg0, %5 : tensor<3x3xi1>, tensor<3x3xui8> + return %6 : tensor<3x3xui8> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.triangular/fn (Tensor, i32) Tensor_9703ef96e083c0f8.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.triangular/fn (Tensor, i32) Tensor_9703ef96e083c0f8.mlir new file mode 100644 index 00000000..630146d5 --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.triangular/fn (Tensor, i32) Tensor_9703ef96e083c0f8.mlir @@ -0,0 +1,14 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<3x3xui8> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<3x3xui8> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %c_0 = stablehlo.constant dense<1> : tensor + %0 = stablehlo.iota dim = 0 : tensor<3x3xi32> + %1 = stablehlo.broadcast_in_dim %c_0, dims = [] : (tensor) -> tensor<3x3xi32> + %2 = stablehlo.add %0, %1 : tensor<3x3xi32> + %3 = stablehlo.iota dim = 1 : tensor<3x3xi32> + %4 = stablehlo.compare GE, %2, %3, SIGNED : (tensor<3x3xi32>, tensor<3x3xi32>) -> tensor<3x3xi1> + %5 = stablehlo.broadcast_in_dim %c, dims = [] : (tensor) -> tensor<3x3xui8> + %6 = stablehlo.select %4, %arg0, %5 : tensor<3x3xi1>, tensor<3x3xui8> + return %6 : tensor<3x3xui8> + } +} diff --git a/zml/test_data/snapshot/tensor.Tensor.decltest.triangular/fn (Tensor, i32) Tensor_ae9f56f8c7431633.mlir b/zml/test_data/snapshot/tensor.Tensor.decltest.triangular/fn (Tensor, i32) Tensor_ae9f56f8c7431633.mlir new file mode 100644 index 00000000..54aba19a --- /dev/null +++ b/zml/test_data/snapshot/tensor.Tensor.decltest.triangular/fn (Tensor, i32) Tensor_ae9f56f8c7431633.mlir @@ -0,0 +1,14 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<3x3xui8> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<3x3xui8> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %c_0 = stablehlo.constant dense<0> : tensor + %0 = stablehlo.iota dim = 0 : tensor<3x3xi32> + %1 = stablehlo.broadcast_in_dim %c_0, dims = [] : (tensor) -> tensor<3x3xi32> + %2 = stablehlo.add %0, %1 : tensor<3x3xi32> + %3 = stablehlo.iota dim = 1 : tensor<3x3xi32> + %4 = stablehlo.compare GE, %2, %3, SIGNED : (tensor<3x3xi32>, tensor<3x3xi32>) -> tensor<3x3xi1> + %5 = stablehlo.broadcast_in_dim %c, dims = [] : (tensor) -> tensor<3x3xui8> + %6 = stablehlo.select %4, %arg0, %5 : tensor<3x3xi1>, tensor<3x3xui8> + return %6 : tensor<3x3xui8> + } +} diff --git a/zml/test_data/snapshot/tensor.test.Tensor.maxPool1d/fn (Tensor) Tensor.ArgMaxRes_b92819e0050b1612.mlir b/zml/test_data/snapshot/tensor.test.Tensor.maxPool1d/fn (Tensor) Tensor.ArgMaxRes_b92819e0050b1612.mlir new file mode 100644 index 00000000..cdd3d51b --- /dev/null +++ b/zml/test_data/snapshot/tensor.test.Tensor.maxPool1d/fn (Tensor) Tensor.ArgMaxRes_b92819e0050b1612.mlir @@ -0,0 +1,21 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x2x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x2x2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<2x2x2xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %cst = stablehlo.constant dense<0xFF800000> : tensor + %0 = stablehlo.iota dim = 2 : tensor<2x2x5xi32> + %1:2 = "stablehlo.reduce_window"(%arg0, %0, %cst, %c) <{base_dilations = array, padding = dense<0> : tensor<3x2xi64>, window_dilations = array, window_dimensions = array, window_strides = array}> ({ + ^bb0(%arg1: tensor, %arg2: tensor, %arg3: tensor, %arg4: tensor): + %2 = stablehlo.compare GT, %arg1, %arg3, FLOAT : (tensor, tensor) -> tensor + %3 = stablehlo.compare NE, %arg1, %arg1, FLOAT : (tensor, tensor) -> tensor + %4 = stablehlo.or %2, %3 : tensor + %5 = stablehlo.select %4, %arg1, %arg3 : tensor, tensor + %6 = stablehlo.compare EQ, %arg1, %arg3, FLOAT : (tensor, tensor) -> tensor + %7 = stablehlo.compare LT, %arg2, %arg4, SIGNED : (tensor, tensor) -> tensor + %8 = stablehlo.and %6, %7 : tensor + %9 = stablehlo.or %4, %8 : tensor + %10 = stablehlo.select %9, %arg2, %arg4 : tensor, tensor + stablehlo.return %5, %10 {operandSegmentSizes = dense<2> : tensor<1xi32>} : tensor, tensor + }) {operandSegmentSizes = dense<2> : tensor<2xi32>} : (tensor<2x2x5xf32>, tensor<2x2x5xi32>, tensor, tensor) -> (tensor<2x2x2xf32>, tensor<2x2x2xi32>) + return %1#0, %1#1 : tensor<2x2x2xf32>, tensor<2x2x2xi32> + } +} diff --git a/zml/test_data/snapshot/tensor.test.Tensor.maxPool2d/fn (Tensor) Tensor.ArgMaxRes_c909c10268568544.mlir b/zml/test_data/snapshot/tensor.test.Tensor.maxPool2d/fn (Tensor) Tensor.ArgMaxRes_c909c10268568544.mlir new file mode 100644 index 00000000..c3d30de9 --- /dev/null +++ b/zml/test_data/snapshot/tensor.test.Tensor.maxPool2d/fn (Tensor) Tensor.ArgMaxRes_c909c10268568544.mlir @@ -0,0 +1,21 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<2x2x5x5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<2x2x2x4xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<2x2x2x4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %c = stablehlo.constant dense<0> : tensor + %cst = stablehlo.constant dense<0xFF800000> : tensor + %0 = stablehlo.iota dim = 3 : tensor<2x2x5x5xi32> + %1:2 = "stablehlo.reduce_window"(%arg0, %0, %cst, %c) <{base_dilations = array, padding = dense<0> : tensor<4x2xi64>, window_dilations = array, window_dimensions = array, window_strides = array}> ({ + ^bb0(%arg1: tensor, %arg2: tensor, %arg3: tensor, %arg4: tensor): + %2 = stablehlo.compare GT, %arg1, %arg3, FLOAT : (tensor, tensor) -> tensor + %3 = stablehlo.compare NE, %arg1, %arg1, FLOAT : (tensor, tensor) -> tensor + %4 = stablehlo.or %2, %3 : tensor + %5 = stablehlo.select %4, %arg1, %arg3 : tensor, tensor + %6 = stablehlo.compare EQ, %arg1, %arg3, FLOAT : (tensor, tensor) -> tensor + %7 = stablehlo.compare LT, %arg2, %arg4, SIGNED : (tensor, tensor) -> tensor + %8 = stablehlo.and %6, %7 : tensor + %9 = stablehlo.or %4, %8 : tensor + %10 = stablehlo.select %9, %arg2, %arg4 : tensor, tensor + stablehlo.return %5, %10 {operandSegmentSizes = dense<2> : tensor<1xi32>} : tensor, tensor + }) {operandSegmentSizes = dense<2> : tensor<2xi32>} : (tensor<2x2x5x5xf32>, tensor<2x2x5x5xi32>, tensor, tensor) -> (tensor<2x2x2x4xf32>, tensor<2x2x2x4xi32>) + return %1#0, %1#1 : tensor<2x2x2x4xf32>, tensor<2x2x2x4xi32> + } +} diff --git a/zml/test_data/snapshot/tensor.test.unused tensor/fn (Tensor) Tensor_8437cca72634e001.mlir b/zml/test_data/snapshot/tensor.test.unused tensor/fn (Tensor) Tensor_8437cca72634e001.mlir new file mode 100644 index 00000000..fdced322 --- /dev/null +++ b/zml/test_data/snapshot/tensor.test.unused tensor/fn (Tensor) Tensor_8437cca72634e001.mlir @@ -0,0 +1,5 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<10xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}", tf.aliasing_output = 0 : i32}) -> (tensor<10xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + return %arg0 : tensor<10xf32> + } +} diff --git a/zml/test_data/snapshot/testing.decltest.testLayer/nn.Linear.forward.mlir b/zml/test_data/snapshot/testing.decltest.testLayer/nn.Linear.forward.mlir new file mode 100644 index 00000000..8fc14351 --- /dev/null +++ b/zml/test_data/snapshot/testing.decltest.testLayer/nn.Linear.forward.mlir @@ -0,0 +1,6 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<5x2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<5xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.dot_general %arg1, %arg0, contracting_dims = [0] x [1], precision = [DEFAULT, DEFAULT] : (tensor<2xf32>, tensor<5x2xf32>) -> tensor<5xf32> + return %0 : tensor<5xf32> + } +} diff --git a/zml/test_data/snapshot/torch.decltest.meshgrid/fn (Tensor, Tensor, torch.MeshgridIndexing) [2]Tensor_af34bec8622b2348.mlir b/zml/test_data/snapshot/torch.decltest.meshgrid/fn (Tensor, Tensor, torch.MeshgridIndexing) [2]Tensor_af34bec8622b2348.mlir new file mode 100644 index 00000000..b7e583ff --- /dev/null +++ b/zml/test_data/snapshot/torch.decltest.meshgrid/fn (Tensor, Tensor, torch.MeshgridIndexing) [2]Tensor_af34bec8622b2348.mlir @@ -0,0 +1,7 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<6xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, %arg1: tensor<4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<4x6xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}, tensor<4x6xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.broadcast_in_dim %arg0, dims = [1] : (tensor<6xi32>) -> tensor<4x6xi32> + %1 = stablehlo.broadcast_in_dim %arg1, dims = [0] : (tensor<4xi32>) -> tensor<4x6xi32> + return %0, %1 : tensor<4x6xi32>, tensor<4x6xi32> + } +} diff --git a/zml/test_data/snapshot/torch.decltest.pixelShuffle/fn (Tensor, u32) Tensor_7db731f87a15127b.mlir b/zml/test_data/snapshot/torch.decltest.pixelShuffle/fn (Tensor, u32) Tensor_7db731f87a15127b.mlir new file mode 100644 index 00000000..075d54c7 --- /dev/null +++ b/zml/test_data/snapshot/torch.decltest.pixelShuffle/fn (Tensor, u32) Tensor_7db731f87a15127b.mlir @@ -0,0 +1,8 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<1x9x4x4xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x1x12x12xi32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.reshape %arg0 : (tensor<1x9x4x4xi32>) -> tensor<1x1x3x3x4x4xi32> + %1 = stablehlo.transpose %0, dims = [0, 1, 4, 2, 5, 3] : (tensor<1x1x3x3x4x4xi32>) -> tensor<1x1x4x3x4x3xi32> + %2 = stablehlo.reshape %1 : (tensor<1x1x4x3x4x3xi32>) -> tensor<1x1x12x12xi32> + return %2 : tensor<1x1x12x12xi32> + } +} diff --git a/zml/test_data/snapshot/torch.decltest.roll/fn (Tensor, []const i64, []const u8) Tensor_95471c6a0b9cc132.mlir b/zml/test_data/snapshot/torch.decltest.roll/fn (Tensor, []const i64, []const u8) Tensor_95471c6a0b9cc132.mlir new file mode 100644 index 00000000..4a64799a --- /dev/null +++ b/zml/test_data/snapshot/torch.decltest.roll/fn (Tensor, []const i64, []const u8) Tensor_95471c6a0b9cc132.mlir @@ -0,0 +1,22 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<4x2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<4x2xf32> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %cst = stablehlo.constant dense<1.000000e+00> : tensor + %cst_0 = stablehlo.constant dense<4.000000e+00> : tensor + %cst_1 = stablehlo.constant dense<2.000000e+00> : tensor + %0 = stablehlo.iota dim = 0 : tensor<4xf32> + %1 = stablehlo.broadcast_in_dim %cst_1, dims = [] : (tensor) -> tensor<4xf32> + %2 = stablehlo.add %0, %1 : tensor<4xf32> + %3 = stablehlo.broadcast_in_dim %cst_0, dims = [] : (tensor) -> tensor<4xf32> + %4 = stablehlo.remainder %2, %3 : tensor<4xf32> + %5 = stablehlo.convert %4 : (tensor<4xf32>) -> tensor<4xi32> + %6 = "stablehlo.gather"(%arg0, %5) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = false, slice_sizes = array}> : (tensor<4x2xf32>, tensor<4xi32>) -> tensor<4x2xf32> + %7 = stablehlo.iota dim = 0 : tensor<2xf32> + %8 = stablehlo.broadcast_in_dim %cst, dims = [] : (tensor) -> tensor<2xf32> + %9 = stablehlo.add %7, %8 : tensor<2xf32> + %10 = stablehlo.broadcast_in_dim %cst_1, dims = [] : (tensor) -> tensor<2xf32> + %11 = stablehlo.remainder %9, %10 : tensor<2xf32> + %12 = stablehlo.convert %11 : (tensor<2xf32>) -> tensor<2xi32> + %13 = "stablehlo.gather"(%6, %12) <{dimension_numbers = #stablehlo.gather, indices_are_sorted = false, slice_sizes = array}> : (tensor<4x2xf32>, tensor<2xi32>) -> tensor<4x2xf32> + return %13 : tensor<4x2xf32> + } +} diff --git a/zml/test_data/snapshot/torch.decltest.unsqueeze/fn (Tensor) Tensor_1e8d6fee27f95b51.mlir b/zml/test_data/snapshot/torch.decltest.unsqueeze/fn (Tensor) Tensor_1e8d6fee27f95b51.mlir new file mode 100644 index 00000000..a12b836b --- /dev/null +++ b/zml/test_data/snapshot/torch.decltest.unsqueeze/fn (Tensor) Tensor_1e8d6fee27f95b51.mlir @@ -0,0 +1,8 @@ +module @zml attributes {mhlo.num_partitions = 4 : i32, mhlo.num_replicas = 1 : i32} { + func.func @main(%arg0: tensor<8xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) -> (tensor<1x8x1x1xf16> {mhlo.layout_mode = "default", mhlo.sharding = "{replicated}"}) { + %0 = stablehlo.reshape %arg0 : (tensor<8xf16>) -> tensor<1x8xf16> + %1 = stablehlo.reshape %0 : (tensor<1x8xf16>) -> tensor<1x8x1xf16> + %2 = stablehlo.reshape %1 : (tensor<1x8x1xf16>) -> tensor<1x8x1x1xf16> + return %2 : tensor<1x8x1x1xf16> + } +}