Source tensors, gradients और Linux native-exe
प्रकाशित compiler: v0.0.7-alpha.5.
Tensor types और shape checks
tensor<float, ...> में dimensions type का भाग हैं। Immutable, finite binary64 tensors में checked indexing, broadcasting, batched matmul, reshape, transpose, concat और reductions हैं। अधिकतम rank 8 और 65,536 cells; work तथा memory budgets लागू हैं।
Gradient और optimizer
tensor_value_grad selected parameter की value और gradient लौटाता है; tensor_sgd, Adam और AdamW bounded updates देते हैं। नीचे tagged upstream example और उसका exact output है, rounding को आदर्श decimal मान से न मिलाएँ।
pure funcra identity<T>(value: T) -> T {
return value;
}
bind features: tensor<float, 2, 2> = [[1.0, 2.0], [3.0, 4.0]];
bind weights: tensor<float, 2, 1> = [[0.5], [1.0]];
bind scores = identity(matmul(features, weights));
bind result = tensor_value_grad(weights, tensor_sum(tensor_square(matmul(features, weights))));
bind next_weights = tensor_sgd(weights, result[1], 0.01);
print(scores, result[0]);
print(result[1], next_weights);
bind x = 3.0;
bind offset = 2.0;
print(value_grad(x, scalar_square(x) + x * offset));
tensor<float, 2, 1> [2.5, 5.5] 36.5
tensor<float, 2, 1> [38.0, 54.0] tensor<float, 2, 1> [0.12, 0.45999999999999996]
(15.0, 8.0)
Run: scarp exec examples/tensor_learning.srp. Pinned source · Pinned stdout.
Signed और unsigned fixed-width integers
i8…i128, u8…u128 तथा 64-bit isize/usize अलग types हैं। to_i8…to_u128 explicit conversions representability check करते हैं; mixed widths अपने-आप convert नहीं होते। सामान्य arithmetic checked है; wrapping/saturating helpers को स्पष्ट चुनना पड़ता है।
सीमित Linux executable
scarp native-exe Linux x86-64 के लिए standalone ELF64 बनाता है। Source में बिना arguments pure funcra main() -> integer चाहिए। I/O, tensors, heap data और recursion supported नहीं हैं। Work तथा private stack limits बताने होते हैं। Exit 0–125 return value हैं, 126 range error, 129–135 native runtime errors। Output नया filename होना चाहिए।
pure funcra sum_to(count: integer) -> integer {
var total = 0;
repeat count as index {
total += index;
}
return total;
}
pure funcra main() -> integer {
return sum_to(10);
}
scarp native-exe linux-x86_64 1000 4096 examples/native_linux_exit.srp -o scarp-exit
./scarp-exit
echo $? # 45
BigInt file format और lifetime
Experimental file-backed scarp bigint के लिए checksummed SCBIGV01 conversion है। Interpreter BigInt से file-backed backend की budgets अलग हैं। Interpreter का Lifetime मृत bindings को अंतिम use के बाद release करता है; यह process RAM cap या cycle collector नहीं है।