E6031
E6031 — A tensor shape that folds to a negative extent, or whose size is more than 2^63 - 1 bytes, the most an allocation can ask for. The size is known, and it is not one the generated code can allocate: it would wrap.
What the compiler reports
Error[E6031] at [[@LINE+1]]:11: `Tensor<f32, [2, -3]>` cannot be allocated: one of its extents is negative
Error[E6031] at [[@LINE+1]]:14: `Tensor<f32, [2305843009213693952]>` cannot be allocated: its size is more than 2^63 - 1 bytes
The fragments the test suite holds the compiler to. An ellipsis marks text the test does not constrain; the emitted message also carries a source location.
A program that triggers it
//
// Part of the Vx Project, under the Apache License v2.0 with LLVM Exceptions.
// See LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//
// A tensor size written as a negative number is refused, and so is a tensor of 2^63 bytes:
// it fits in 64 bits, but an allocation can ask for at most 2^63 - 1 bytes. A tensor of
// 2^62 bytes is allowed.
fn main() -> i32 {
let b = Tensor<f32, [2, -3]>::new();
// 2^61 elements of 4 bytes each is 2^63 bytes.
let huge = Tensor<f32, [2305843009213693952]>::new();
// 2^61 elements of 2 bytes each is 2^62 bytes.
// FITS-NOT: Tensor<f16
let fits = Tensor<f16, [2147483648, 1073741824]>::new();
return 0;
}
From tests/frontend/fail/tensor_size_negative_or_too_large.vx, which asserts this diagnostic on every commit.
Related
Topologies and memoryThe chapter covering the rule this code enforces.
All diagnosticsEvery code the compiler can emit, grouped by stage.
E6030A
spawn region on a device hands out a tensor it makes, which the host could not free. The compiler makes such a tensor before the region instead, in the device's memory, when the region hands it out as a variable created with Tensor<..>(..), ::new() or unsafe { ..::uninit() }, with no type annotation, a size that uses nothing the region computes, and a name nothing outside the region already uses.