tiny.accy.preparation.schedule
Defined in preparation.
API (16)
Actions
Public operations.
SchedulePlanAnalysis.deinitSchedulePlanAnalysis.getWorkForRootSchedulePlanAnalysis.initSchedulePlanAnalysis.workItemCountScheduleWorkItem.opCountgetSchedulePlanAnalysiskernelInputValueForOperandschedulePlanningPass
Types and contracts
Public types and contracts.
Values and defaults
Public values and defaults.
schedule_plan_analysis_descriptorschedule_plan_analysis_nameschedule_planning_pass_descriptionschedule_planning_pass_name
Source
Source: lib/accy/src/preparation/schedule/pass.zig:46
zig
pub const SchedulePlanAnalysis = struct { allocator: std.mem.Allocator, work_items: std.ArrayListUnmanaged(ScheduleWorkItem), root_to_item: std.AutoHashMap(*ir.Operation, usize), single_work_count: usize = 0, fusion_work_count: usize = 0, kernel_call_work_count: usize = 0, scheduled_op_count: usize = 0, total_static_elements: u64 = 0, pub fn init(allocator: std.mem.Allocator) SchedulePlanAnalysis { return .{ .allocator = allocator, .work_items = .empty, .root_to_item = std.AutoHashMap(*ir.Operation, usize).init(allocator), }; } pub fn deinit(self: *SchedulePlanAnalysis) void { for (self.work_items.items) |*item| { item.deinit(self.allocator); } self.work_items.deinit(self.allocator); self.root_to_item.deinit(); self.* = undefined; } pub fn workItemCount(self: SchedulePlanAnalysis) usize { return self.work_items.items.len; } pub fn getWorkForRoot( self: *const SchedulePlanAnalysis, root: *ir.Operation, ) ?*const ScheduleWorkItem { const index = self.root_to_item.get(root) orelse return null; return &self.work_items.items[index]; } fn addWorkItem( self: *SchedulePlanAnalysis, kind: ScheduleWorkKind, root: *ir.Operation, ops: []const *ir.Operation, output_value: *ir.Value, info: shape_analysis.TensorInfo, shapes: *const shape_analysis.ShapeLayoutAnalysis, ) !void { if (ops.len == 0) return; if (self.root_to_item.contains(root)) return; const element_count = info.element_count orelse return; const total_elements = try accounting.add(self.total_static_elements, element_count); const owned_ops = try self.allocator.alloc(*ir.Operation, ops.len); errdefer self.allocator.free(owned_ops); @memcpy(owned_ops, ops); const id = self.work_items.items.len; const resources = try resourceEstimateForWork( self.allocator, ops, info, shapes, ); try self.root_to_item.put(root, id); errdefer _ = self.root_to_item.remove(root); try self.work_items.append(self.allocator, .{ .id = id, .kind = kind, .root = root, .ops = owned_ops, .output_value = output_value, .dtype = info.dtype, .rank = info.rank(), .element_count = element_count, .resources = resources, }); switch (kind) { .elementwise_single => self.single_work_count += 1, .elementwise_fusion => self.fusion_work_count += 1, .shape => self.single_work_count += 1, .dot_general => self.single_work_count += 1, .reduction => self.single_work_count += 1, .kernel_call => self.kernel_call_work_count += 1, .row_pipeline => self.fusion_work_count += 1, .iterate => self.single_work_count += 1, .flash_attention => self.fusion_work_count += 1, .scan => self.single_work_count += 1, } self.scheduled_op_count += ops.len; self.total_static_elements = total_elements; }};Source: lib/accy/src/preparation/schedule/pass.zig:25
zig
pub const ScheduleWorkItem = struct { id: usize, kind: ScheduleWorkKind, root: *ir.Operation, ops: []*ir.Operation, output_value: *ir.Value, dtype: choir_abi.DType, rank: usize, element_count: u64, resources: ScheduleResourceEstimate, pub fn opCount(self: ScheduleWorkItem) usize { return self.ops.len; } fn deinit(self: *ScheduleWorkItem, allocator: std.mem.Allocator) void { allocator.free(self.ops); self.* = undefined; }};Source: lib/accy/src/preparation/schedule/pass.zig:262
zig
pub fn getSchedulePlanAnalysis( pass_ctx: *passes.PassContext, op: *ir.Operation,) !*SchedulePlanAnalysis { const ptr = try pass_ctx.getAnalysis( op, &schedule_plan_analysis_descriptor, computeSchedulePlanAnalysis, cleanupSchedulePlanAnalysis, ); return @ptrCast(@alignCast(ptr));}Source: lib/accy/src/preparation/schedule/pass.zig:881
zig
pub fn kernelInputValueForOperand( work: ScheduleWorkItem, operand: *ir.Value,) *ir.Value { switch (work.kind) { .elementwise_single, .elementwise_fusion, .dot_general, .reduction, .row_pipeline, .iterate, .flash_attention, => { const def_any = operand.getDefiningOp() orelse return operand; const def_op: *ir.Operation = @ptrCast(@alignCast(def_any)); const broadcast_name = dialect_mod.AccyDialect.BroadcastInDimOp.operation_name; if (!std.mem.eql(u8, def_op.name.name, broadcast_name)) { return operand; } const operands = def_op.getOperandValues(); if (operands.len != 1) return operand; return operands[0]; }, else => return operand, }}Source: lib/accy/src/preparation/schedule/pass.zig:275
zig
pub fn schedulePlanningPass() passes.Pass { return .{ .name = schedule_planning_pass_name, .description = schedule_planning_pass_description, .run_fn = runSchedulePlanningPass, .work_contract = .{ .identity = .{ .name = schedule_planning_pass_name, .version = 1 }, .estimate = schedulePassWork, }, };}Source: lib/accy/src/preparation/schedule/pass.zig:253
zig
pub const schedule_plan_analysis_descriptor = passes.AnalysisDescriptor{ .id = passes.analysisId(schedule_plan_analysis_name), .name = schedule_plan_analysis_name, .work_contract = .{ .identity = .{ .name = schedule_plan_analysis_name, .version = 1 }, .estimate = scheduleAnalysisWork, },};Source: lib/accy/src/preparation/schedule/pass.zig:16
zig
pub const schedule_plan_analysis_name = "accy-choir-schedule-plan";Source: lib/accy/src/preparation/schedule/pass.zig:18
zig
pub const schedule_planning_pass_description = "Plan static Accy Choir tensor work items before kernel outlining";Source: lib/accy/src/preparation/schedule/pass.zig:23
zig
pub const ScheduleResourceEstimate = accy_choir.record.dispatch.ScheduleResourceEstimate;Source: lib/accy/src/preparation/schedule/pass.zig:21
zig
pub const ScheduleWorkKind = accy_choir.record.dispatch.ScheduleWorkKind;Source: lib/accy/src/preparation/root.zig:21
zig
pub const schedule = @import("schedule/root.zig");Source: lib/accy/src/preparation/schedule/root.zig
zig
const pass = @import("pass.zig");pub const schedule_plan_analysis_name = pass.schedule_plan_analysis_name;pub const schedule_planning_pass_name = pass.schedule_planning_pass_name;pub const schedule_planning_pass_description = pass.schedule_planning_pass_description;pub const ScheduleWorkKind = pass.ScheduleWorkKind;pub const ScheduleResourceEstimate = pass.ScheduleResourceEstimate;pub const ScheduleWorkItem = pass.ScheduleWorkItem;pub const SchedulePlanAnalysis = pass.SchedulePlanAnalysis;pub const schedule_plan_analysis_descriptor = pass.schedule_plan_analysis_descriptor;pub const getSchedulePlanAnalysis = pass.getSchedulePlanAnalysis;pub const schedulePlanningPass = pass.schedulePlanningPass;pub const kernelInputValueForOperand = pass.kernelInputValueForOperand;Complete caller list for preparation.schedule.getSchedulePlanAnalysis
16 direct callers.
lib.accy.src.preparation.schedule.pass.checkScheduleChain[function] — private source atlib/accy/src/preparation/schedule/pass.zig:1746in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.runSchedulePlanningPass[function] — private source atlib/accy/src/preparation/schedule/pass.zig:287in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_emits_dot_general_work_for_static_rank-2_matmul[function] — test source atlib/accy/src/preparation/schedule/pass.zig:1075in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_emits_kernel_call_work_with_operand_effects[function] — test source atlib/accy/src/preparation/schedule/pass.zig:1198in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_emits_one_work_item_for_an_elementwise_fusion_cluster[function] — test source atlib/accy/src/preparation/schedule/pass.zig:963in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_emits_reduction_work_for_static_rank-1_reduce[function] — test source atlib/accy/src/preparation/schedule/pass.zig:1139in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_emits_shape_work_for_static_concatenate[function] — test source atlib/accy/src/preparation/schedule/pass.zig:1506in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_emits_shape_work_for_static_iota[function] — test source atlib/accy/src/preparation/schedule/pass.zig:1460in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_emits_shape_work_for_static_pad[function] — test source atlib/accy/src/preparation/schedule/pass.zig:1410in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_emits_shape_work_for_static_slice[function] — test source atlib/accy/src/preparation/schedule/pass.zig:1364in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_emits_shape_work_for_static_transpose[function] — test source atlib/accy/src/preparation/schedule/pass.zig:1318in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_emits_standalone_work_when_fusion_is_rejected[function] — test source atlib/accy/src/preparation/schedule/pass.zig:1022in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_estimates_catalog_kernel_call_reductions[function] — test source atlib/accy/src/preparation/schedule/pass.zig:1262in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_orders_fusion_after_broadcast_source_producers[function] — test source atlib/accy/src/preparation/schedule/pass.zig:1608in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_orders_fusion_after_external_producers[function] — test source atlib/accy/src/preparation/schedule/pass.zig:1554in nearest public ownerlib.accy.src.preparation.schedule.passlib.accy.src.preparation.schedule.pass.test_schedule_planning_reports_aggregate_element_overflow_without_caching_a_plan[function] — test source atlib/accy/src/preparation/schedule/pass.zig:1830in nearest public ownerlib.accy.src.preparation.schedule.pass
Audit
| Definitions | 16 |
|---|---|
| Public names | 16 |
| Members | 17 |
| Version | 26.7.0 |
| Revision | daab053ee433 |