E3047
E3047 — Areshapecall the compiler cannot check: the new shape has a different number of elements than the tensor (withoutPadMode::PadorPadMode::Trim), a size is not known while compiling, or the arguments are not a shape such as[4, 4]and an optionalPadMode.
What the compiler reports
E3047{{.*}}reshape cannot change the number of elements: Tensor<f32, [128, 128]> has 16384, the new shape has 256
transpose permutation map must not contain duplicates
Type mismatch in argument 1 for function 'requires_specific_layout'.
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
//
fn requires_specific_layout(t : Tensor<f32, [ 128, 256 ]>) -> i32 {
return 0;
}
fn main() -> i32 {
// 1. Invalid tensor init
let t_host : Tensor<f32, [?, ?]> = true;
// 2. Generic missing
let a = Tensor([10]);
// 3. Generic not scalar
let b = Tensor<Tensor<f32, [?, ?]>>([10]);
// 4. Invalid reshape
let c : Tensor<f32, [ 128, 128 ]> = 1.0;
let d = c.reshape([256]);
// 5. Invalid transpose
let e = c.transpose([ 0, 0 ]);
// 6. Layout mismatch
requires_specific_layout(c);
return 0;
}
From tests/frontend/fail/tensor_errors.vx, which asserts this diagnostic on every commit.
Related
A tour of VxThe chapter covering the rule this code enforces.
All diagnosticsEvery code the compiler can emit, grouped by stage.
E3046A
for loop over a tensor that is not a variable or a flat array literal, such as one a function call returns, or a nested array literal. The loop reads the tensor by index, so it needs a name: bind the tensor with let first.
E3048An if with no else whose value is used, as in let u = if c { .. };. When the condition is false there is no branch to give a value. Add an else, or use the if as a statement.