tiny.accy.choir.tensor
Defined in choir.
API (9)
Actions
Public operations.
TensorJob.contextTensorJob.deinitTensorJob.fingerprintTensorJob.initTensorJob.passContextTensorJob.verify
Types and contracts
Public types and contracts.
Values and defaults
Public values and defaults.
Source
Source: lib/accy/src/choir/root.zig:10
zig
pub const tensor = @import("tensor.zig");Source: lib/accy/src/choir/tensor.zig
zig
const std = @import("std");const choir = @import("choir");const contract = @import("contract.zig");const semantic = @import("semantic.zig");const ir = choir.ir;const passes = choir.passes;pub const product_name = "accy.tensor_opt";pub const TensorModule = @import("root.zig").publication.Module(.tensor);pub const TensorJob = struct { allocator: std.mem.Allocator, contract_module: *contract.ContractJob, choir_module: *ir.Operation, analysis_cache: passes.AnalysisCache, observed_fingerprint: u64, pub fn init( allocator: std.mem.Allocator, contract_module: *contract.ContractJob, analysis_cache: passes.AnalysisCache, ) !*TensorJob { const module = try allocator.create(TensorJob); errdefer allocator.destroy(module); module.* = .{ .allocator = allocator, .contract_module = contract_module, .choir_module = contract_module.choir_module, .analysis_cache = analysis_cache, .observed_fingerprint = 0, }; try module.verify(); module.observed_fingerprint = try choir.operationFingerprint(allocator, module.choir_module); return module; } pub fn context(self: *TensorJob) *ir.Context { return self.contract_module.context(); } pub fn deinit(self: *TensorJob) void { self.analysis_cache.deinit(); self.contract_module.deinit(); const allocator = self.allocator; allocator.destroy(self); } pub fn verify(self: *TensorJob) !void { try self.contract_module.verify(); try contract.verifyAllowedDialects(self.choir_module); } pub fn fingerprint(self: *const TensorJob) u64 { return self.observed_fingerprint; } pub fn passContext(self: *TensorJob) passes.PassContext { return passes.PassContext.init(self.choir_module, self.context(), self.allocator, &self.analysis_cache); }};test "tensor module owns contract product and analysis cache" { const allocator = std.testing.allocator; var builder = try semantic.Builder.init(allocator, semantic.Builder.ContextLimits.standard); defer builder.deinit(); const ty = try builder.tensor(.f32, &.{4}); var function = try builder.beginFunction("tensor_add", &.{ ty, ty }, &.{ty}); const sum = try function.add(function.parameter(0), function.parameter(1)); try function.return_(&.{sum}); try function.finish(); const semantic_module = try builder.finish(); var contract_module = try contract.ContractJob.init(allocator, semantic_module); var contract_owned = true; errdefer if (contract_owned) contract_module.deinit(); var analysis_cache = passes.AnalysisCache.init(allocator, null); var cache_owned = true; errdefer if (cache_owned) analysis_cache.deinit(); var tensor_module = try TensorJob.init(allocator, contract_module, analysis_cache); contract_owned = false; cache_owned = false; defer tensor_module.deinit(); try std.testing.expectEqualStrings(product_name, "accy.tensor_opt"); try tensor_module.verify(); try std.testing.expectEqual(try choir.operationFingerprint(allocator, tensor_module.choir_module), tensor_module.fingerprint());}Complete caller list for choir.TensorJob.deinit
7 direct callers.
tiny.accy.choir.DispatchJob.deinit[method] atlib/accy/src/choir/dispatch.zig:41lib.accy.src.choir.dispatch.test_dispatch_module_owns_tensor_product[function] — test source atlib/accy/src/choir/dispatch.zig:60in nearest public ownertiny.accy.choir.dispatchlib.accy.src.choir.gpu.test_kernel_module_owns_memory_product[function] — test source atlib/accy/src/choir/gpu.zig:62in nearest public ownertiny.accy.choir.gpulib.accy.src.choir.memory.test_memory_module_owns_dispatch_product[function] — test source atlib/accy/src/choir/memory.zig:61in nearest public ownertiny.accy.choir.memorylib.accy.src.choir.tensor.test_tensor_module_owns_contract_product_and_analysis_cache[function] — test source atlib/accy/src/choir/tensor.zig:64in nearest public ownertiny.accy.choir.tensortiny.accy.preparation.TensorPreparationResult.deinit[method] atlib/accy/src/preparation/execution.zig:83lib.accy.src.target.module.test_target_module_owns_kernel_product[function] — test source atlib/accy/src/target/module.zig:79in nearest public ownertiny.accy.target.module
Audit
| Definitions | 10 |
|---|---|
| Public names | 19 |
| Members | 5 |
| Version | 26.7.0 |
| Revision | daab053ee433 |