test: Add UI tests for testing type analysis autodiff
Signed-off-by: Karan Janthe <karanjanthe@gmail.com>
This commit is contained in:
parent
5773d38c7a
commit
80224c3e88
68 changed files with 1303 additions and 1 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit 0f65f31837a608db469ebde94adbc921be70bd8a
|
||||
Subproject commit b5098d515d5e1bd0f5470553bc0d18da9794ca8b
|
||||
13
tests/run-make/autodiff/type-trees/type-analysis/README.md
Normal file
13
tests/run-make/autodiff/type-trees/type-analysis/README.md
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Autodiff Type-Trees Type Analysis Tests
|
||||
|
||||
This directory contains run-make tests for the autodiff type-trees type analysis functionality. These tests verify that the autodiff compiler correctly analyzes and tracks type information for different Rust types during automatic differentiation.
|
||||
|
||||
## What These Tests Do
|
||||
|
||||
Each test compiles a simple Rust function with the `#[autodiff_reverse]` attribute and verifies that the compiler:
|
||||
|
||||
1. **Correctly identifies type information** in the generated LLVM IR
|
||||
2. **Tracks type annotations** for variables and operations
|
||||
3. **Preserves type context** through the autodiff transformation process
|
||||
|
||||
The tests capture the stdout from the autodiff compiler (which contains type analysis information) and verify it matches expected patterns using FileCheck.
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float, [-1,4]:Float@float, [-1,8]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = getelementptr inbounds nuw i8, ptr %{{[0-9]+}}, i64 4, !dbg !{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float, [-1,4]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fadd float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = getelementptr inbounds nuw i8, ptr %{{[0-9]+}}, i64 8, !dbg !{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fadd float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer, [-1,0]:Float@float, [-1,4]:Float@float, [-1,8]:Float@float}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float, [-1,4]:Float@float, [-1,8]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = getelementptr inbounds nuw i8, ptr %{{[0-9]+}}, i64 4, !dbg !{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float, [-1,4]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fadd float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = getelementptr inbounds nuw i8, ptr %{{[0-9]+}}, i64 8, !dbg !{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fadd float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &[f32; 3]) -> f32 {
|
||||
x[0] * x[0] + x[1] * x[1] + x[2] * x[2]
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = [1.0f32, 2.0, 3.0];
|
||||
let mut df_dx = [0.0f32; 3];
|
||||
let out = callee(&x);
|
||||
let out_ = d_square(&x, &mut df_dx, 1.0);
|
||||
assert_eq!(out, out_);
|
||||
assert_eq!(2.0, df_dx[0]);
|
||||
assert_eq!(4.0, df_dx[1]);
|
||||
assert_eq!(6.0, df_dx[2]);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("array.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("array.stdout", stdout);
|
||||
rfs::write("array.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("array.check").stdin_buf(rfs::read("array.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: br label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ %{{[0-9]+}}, %{{[0-9]+}} ], !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: br i1 %{{[0-9]+}}, label %{{[0-9]+}}, label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ %{{[0-9]+}}, %{{[0-9]+}} ], !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ 0.000000e+00, %{{[0-9]+}} ], [ %{{[0-9]+}}, %{{[0-9]+}} ]: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi i1 [ true, %{{[0-9]+}} ], [ false, %{{[0-9]+}} ]: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi i64 [ 0, %{{[0-9]+}} ], [ 1, %{{[0-9]+}} ]: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = getelementptr inbounds nuw [2 x [2 x float]], ptr %{{[0-9]+}}, i64 %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: br label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ %{{[0-9]+}}, %{{[0-9]+}} ], !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: br i1 %{{[0-9]+}}, label %{{[0-9]+}}, label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ %{{[0-9]+}}, %{{[0-9]+}} ], [ %{{[0-9]+}}, %{{[0-9]+}} ]: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi i1 [ true, %{{[0-9]+}} ], [ false, %{{[0-9]+}} ]: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi i64 [ 0, %{{[0-9]+}} ], [ 1, %{{[0-9]+}} ]: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = getelementptr inbounds nuw [2 x float], ptr %{{[0-9]+}}, i64 %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: br label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ %{{[0-9]+}}, %{{[0-9]+}} ], [ %{{[0-9]+}}, %{{[0-9]+}} ]: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi i1 [ true, %{{[0-9]+}} ], [ false, %{{[0-9]+}} ]: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi i64 [ 0, %{{[0-9]+}} ], [ 1, %{{[0-9]+}} ]: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = getelementptr inbounds nuw float, ptr %{{[0-9]+}}, i64 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fadd float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: br i1 %{{[0-9]+}}, label %{{[0-9]+}}, label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer, [-1,0]:Float@float}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: br label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ %{{[0-9]+}}, %{{[0-9]+}} ], !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: br i1 %{{[0-9]+}}, label %{{[0-9]+}}, label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ %{{[0-9]+}}, %{{[0-9]+}} ], !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ 0.000000e+00, %{{[0-9]+}} ], [ %{{[0-9]+}}, %{{[0-9]+}} ]: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi i1 [ true, %{{[0-9]+}} ], [ false, %{{[0-9]+}} ]: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi i64 [ 0, %{{[0-9]+}} ], [ 1, %{{[0-9]+}} ]: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = getelementptr inbounds nuw [2 x [2 x float]], ptr %{{[0-9]+}}, i64 %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: br label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ %{{[0-9]+}}, %{{[0-9]+}} ], !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: br i1 %{{[0-9]+}}, label %{{[0-9]+}}, label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ %{{[0-9]+}}, %{{[0-9]+}} ], [ %{{[0-9]+}}, %{{[0-9]+}} ]: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi i1 [ true, %{{[0-9]+}} ], [ false, %{{[0-9]+}} ]: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi i64 [ 0, %{{[0-9]+}} ], [ 1, %{{[0-9]+}} ]: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = getelementptr inbounds nuw [2 x float], ptr %{{[0-9]+}}, i64 %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: br label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ %{{[0-9]+}}, %{{[0-9]+}} ], [ %{{[0-9]+}}, %{{[0-9]+}} ]: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi i1 [ true, %{{[0-9]+}} ], [ false, %{{[0-9]+}} ]: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi i64 [ 0, %{{[0-9]+}} ], [ 1, %{{[0-9]+}} ]: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = getelementptr inbounds nuw float, ptr %{{[0-9]+}}, i64 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fadd float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: br i1 %{{[0-9]+}}, label %{{[0-9]+}}, label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &[[[f32; 2]; 2]; 2]) -> f32 {
|
||||
let mut sum = 0.0;
|
||||
for i in 0..2 {
|
||||
for j in 0..2 {
|
||||
for k in 0..2 {
|
||||
sum += x[i][j][k] * x[i][j][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
sum
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = [[[1.0f32, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]]];
|
||||
let mut df_dx = [[[0.0f32; 2]; 2]; 2];
|
||||
let out = callee(&x);
|
||||
let out_ = d_square(&x, &mut df_dx, 1.0);
|
||||
assert_eq!(out, out_);
|
||||
for i in 0..2 {
|
||||
for j in 0..2 {
|
||||
for k in 0..2 {
|
||||
assert_eq!(df_dx[i][j][k], 2.0 * x[i][j][k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("array3d.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("array3d.stdout", stdout);
|
||||
rfs::write("array3d.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("array3d.check").stdin_buf(rfs::read("array3d.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load ptr, ptr %{{[0-9]+}}, align 8, !dbg !{{[0-9]+}}, !nonnull !{{[0-9]+}}, !align !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer, [-1,0]:Pointer, [-1,0,0]:Float@float}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Pointer, [-1,0,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load ptr, ptr %{{[0-9]+}}, align 8, !dbg !{{[0-9]+}}, !nonnull !{{[0-9]+}}, !align !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
18
tests/run-make/autodiff/type-trees/type-analysis/box/box.rs
Normal file
18
tests/run-make/autodiff/type-trees/type-analysis/box/box.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &Box<f32>) -> f32 {
|
||||
**x * **x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = Box::new(7.0f32);
|
||||
let mut df_dx = Box::new(0.0f32);
|
||||
let out = callee(&x);
|
||||
let out_ = d_square(&x, &mut df_dx, 1.0);
|
||||
assert_eq!(out, out_);
|
||||
assert_eq!(14.0, *df_dx);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("box.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("box.stdout", stdout);
|
||||
rfs::write("box.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("box.check").stdin_buf(rfs::read("box.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer, [-1,0]:Float@float}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: *const f32) -> f32 {
|
||||
unsafe { *x * *x }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: f32 = 7.0;
|
||||
let out = callee(&x as *const f32);
|
||||
let mut df_dx: f32 = 0.0;
|
||||
let out_ = d_square(&x as *const f32, &mut df_dx, 1.0);
|
||||
assert_eq!(out, out_);
|
||||
assert_eq!(14.0, df_dx);
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("const_pointer.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("const_pointer.stdout", stdout);
|
||||
rfs::write("const_pointer.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck()
|
||||
.patterns("const_pointer.check")
|
||||
.stdin_buf(rfs::read("const_pointer.stdout"))
|
||||
.run();
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer, [-1,0]:Float@float}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
19
tests/run-make/autodiff/type-trees/type-analysis/f32/f32.rs
Normal file
19
tests/run-make/autodiff/type-trees/type-analysis/f32/f32.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &f32) -> f32 {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: f32 = 7.0;
|
||||
let mut df_dx: f32 = 0.0;
|
||||
let out = callee(&x);
|
||||
let out_ = d_square(&x, &mut df_dx, 1.0);
|
||||
|
||||
assert_eq!(out, out_);
|
||||
assert_eq!(14.0, df_dx);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("f32.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("f32.stdout", stdout);
|
||||
rfs::write("f32.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("f32.check").stdin_buf(rfs::read("f32.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Float@double} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@double}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load double, ptr %{{[0-9]+}}, align 8, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@double}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul double %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@double}
|
||||
// CHECK-DAG: ret double %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Float@double} |{[-1]:Pointer, [-1,0]:Float@double}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@double}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load double, ptr %{{[0-9]+}}, align 8, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@double}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul double %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@double}
|
||||
// CHECK-DAG: ret double %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
20
tests/run-make/autodiff/type-trees/type-analysis/f64/f64.rs
Normal file
20
tests/run-make/autodiff/type-trees/type-analysis/f64/f64.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#![feature(autodiff)]
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_callee, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &f64) -> f64 {
|
||||
x * x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = std::hint::black_box(3.0);
|
||||
|
||||
let output = callee(&x);
|
||||
assert_eq!(9.0, output);
|
||||
|
||||
let mut df_dx = 0.0;
|
||||
let output_ = d_callee(&x, &mut df_dx, 1.0);
|
||||
assert_eq!(output, output_);
|
||||
assert_eq!(6.0, df_dx);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("f64.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("f64.stdout", stdout);
|
||||
rfs::write("f64.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("f64.check").stdin_buf(rfs::read("f64.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i128, ptr %{{[0-9]+}}, align 16, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i128 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i128 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i128, ptr %{{[0-9]+}}, align 16, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i128 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i128 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &i128) -> i128 {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: i128 = 7;
|
||||
let _ = callee(&x);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("i128.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("i128.stdout", stdout);
|
||||
rfs::write("i128.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("i128.check").stdin_buf(rfs::read("i128.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i16, ptr %{{[0-9]+}}, align 2, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i16 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i16 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i16, ptr %{{[0-9]+}}, align 2, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i16 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i16 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
14
tests/run-make/autodiff/type-trees/type-analysis/i16/i16.rs
Normal file
14
tests/run-make/autodiff/type-trees/type-analysis/i16/i16.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &i16) -> i16 {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: i16 = 7;
|
||||
let _ = callee(&x);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("i16.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("i16.stdout", stdout);
|
||||
rfs::write("i16.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("i16.check").stdin_buf(rfs::read("i16.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i32, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i32 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i32 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i32, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i32 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i32 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
14
tests/run-make/autodiff/type-trees/type-analysis/i32/i32.rs
Normal file
14
tests/run-make/autodiff/type-trees/type-analysis/i32/i32.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &i32) -> i32 {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: i32 = 7;
|
||||
let _ = callee(&x);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("i32.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("i32.stdout", stdout);
|
||||
rfs::write("i32.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("i32.check").stdin_buf(rfs::read("i32.stdout")).run();
|
||||
}
|
||||
10
tests/run-make/autodiff/type-trees/type-analysis/i8/i8.check
Normal file
10
tests/run-make/autodiff/type-trees/type-analysis/i8/i8.check
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i8, ptr %{{[0-9]+}}, align 1, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i8 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i8 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer, [-1,0]:Integer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i8, ptr %{{[0-9]+}}, align 1, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i8 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i8 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
14
tests/run-make/autodiff/type-trees/type-analysis/i8/i8.rs
Normal file
14
tests/run-make/autodiff/type-trees/type-analysis/i8/i8.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &i8) -> i8 {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: i8 = 7;
|
||||
let _ = callee(&x);
|
||||
}
|
||||
28
tests/run-make/autodiff/type-trees/type-analysis/i8/rmake.rs
Normal file
28
tests/run-make/autodiff/type-trees/type-analysis/i8/rmake.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("i8.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("i8.stdout", stdout);
|
||||
rfs::write("i8.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("i8.check").stdin_buf(rfs::read("i8.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i64, ptr %{{[0-9]+}}, align 8, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i64 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i64 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i64, ptr %{{[0-9]+}}, align 8, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i64 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i64 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &isize) -> isize {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: isize = 7;
|
||||
let _ = callee(&x);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("isize.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("isize.stdout", stdout);
|
||||
rfs::write("isize.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("isize.check").stdin_buf(rfs::read("isize.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer, [-1,0]:Float@float}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: *mut f32) -> f32 {
|
||||
unsafe { *x * *x }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut x: f32 = 7.0;
|
||||
let out = callee(&mut x as *mut f32);
|
||||
let mut df_dx: f32 = 0.0;
|
||||
let out_ = d_square(&mut x as *mut f32, &mut df_dx, 1.0);
|
||||
assert_eq!(out, out_);
|
||||
assert_eq!(14.0, df_dx);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("mut_pointer.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("mut_pointer.stdout", stdout);
|
||||
rfs::write("mut_pointer.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("mut_pointer.check").stdin_buf(rfs::read("mut_pointer.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer, [-1,0]:Float@float}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &mut f32) -> f32 {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut x: f32 = 7.0;
|
||||
let mut df_dx: f32 = 0.0;
|
||||
let out = callee(&mut x);
|
||||
let out_ = d_square(&mut x, &mut df_dx, 1.0);
|
||||
assert_eq!(out, out_);
|
||||
assert_eq!(14.0, df_dx);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("mut_ref.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("mut_ref.stdout", stdout);
|
||||
rfs::write("mut_ref.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("mut_ref.check").stdin_buf(rfs::read("mut_ref.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer, [-1,0]:Float@float}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
18
tests/run-make/autodiff/type-trees/type-analysis/ref/ref.rs
Normal file
18
tests/run-make/autodiff/type-trees/type-analysis/ref/ref.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &f32) -> f32 {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: f32 = 7.0;
|
||||
let mut df_dx: f32 = 0.0;
|
||||
let out = callee(&x);
|
||||
let out_ = d_square(&x, &mut df_dx, 1.0);
|
||||
assert_eq!(out, out_);
|
||||
assert_eq!(14.0, df_dx);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("ref.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("ref.stdout", stdout);
|
||||
rfs::write("ref.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("ref.check").stdin_buf(rfs::read("ref.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("struct.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("struct.stdout", stdout);
|
||||
rfs::write("struct.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("struct.check").stdin_buf(rfs::read("struct.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer, [-1,0]:Float@float}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct MyStruct {
|
||||
f: f32,
|
||||
}
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &MyStruct) -> f32 {
|
||||
x.f * x.f
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = MyStruct { f: 7.0 };
|
||||
let mut df_dx = MyStruct { f: 0.0 };
|
||||
let out = callee(&x);
|
||||
let out_ = d_square(&x, &mut df_dx, 1.0);
|
||||
assert_eq!(out, out_);
|
||||
assert_eq!(14.0, df_dx.f);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("u128.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("u128.stdout", stdout);
|
||||
rfs::write("u128.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("u128.check").stdin_buf(rfs::read("u128.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i128, ptr %{{[0-9]+}}, align 16, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i128 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i128 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i128, ptr %{{[0-9]+}}, align 16, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i128 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i128 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &u128) -> u128 {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: u128 = 7;
|
||||
let _ = callee(&x);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("u16.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("u16.stdout", stdout);
|
||||
rfs::write("u16.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("u16.check").stdin_buf(rfs::read("u16.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i16, ptr %{{[0-9]+}}, align 2, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i16 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i16 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i16, ptr %{{[0-9]+}}, align 2, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i16 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i16 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
14
tests/run-make/autodiff/type-trees/type-analysis/u16/u16.rs
Normal file
14
tests/run-make/autodiff/type-trees/type-analysis/u16/u16.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &u16) -> u16 {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: u16 = 7;
|
||||
let _ = callee(&x);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("u32.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("u32.stdout", stdout);
|
||||
rfs::write("u32.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("u32.check").stdin_buf(rfs::read("u32.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i32, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i32 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i32 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i32, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i32 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i32 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
14
tests/run-make/autodiff/type-trees/type-analysis/u32/u32.rs
Normal file
14
tests/run-make/autodiff/type-trees/type-analysis/u32/u32.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &u32) -> u32 {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: u32 = 7;
|
||||
let _ = callee(&x);
|
||||
}
|
||||
28
tests/run-make/autodiff/type-trees/type-analysis/u8/rmake.rs
Normal file
28
tests/run-make/autodiff/type-trees/type-analysis/u8/rmake.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("u8.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("u8.stdout", stdout);
|
||||
rfs::write("u8.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("u8.check").stdin_buf(rfs::read("u8.stdout")).run();
|
||||
}
|
||||
10
tests/run-make/autodiff/type-trees/type-analysis/u8/u8.check
Normal file
10
tests/run-make/autodiff/type-trees/type-analysis/u8/u8.check
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i8, ptr %{{[0-9]+}}, align 1, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i8 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i8 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer, [-1,0]:Integer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i8, ptr %{{[0-9]+}}, align 1, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i8 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i8 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
14
tests/run-make/autodiff/type-trees/type-analysis/u8/u8.rs
Normal file
14
tests/run-make/autodiff/type-trees/type-analysis/u8/u8.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &u8) -> u8 {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: u8 = 7;
|
||||
let _ = callee(&x);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("union.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("union.stdout", stdout);
|
||||
rfs::write("union.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("union.check").stdin_buf(rfs::read("union.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer, [-1,0]:Float@float}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fmul float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[allow(dead_code)]
|
||||
union MyUnion {
|
||||
f: f32,
|
||||
i: i32,
|
||||
}
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &MyUnion) -> f32 {
|
||||
unsafe { x.f * x.f }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = MyUnion { f: 7.0 };
|
||||
let _ = callee(&x);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("usize.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("usize.stdout", stdout);
|
||||
rfs::write("usize.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("usize.check").stdin_buf(rfs::read("usize.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i64, ptr %{{[0-9]+}}, align 8, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i64 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i64 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK: callee - {[-1]:Integer} |{[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Integer, [-1,1]:Integer, [-1,2]:Integer, [-1,3]:Integer, [-1,4]:Integer, [-1,5]:Integer, [-1,6]:Integer, [-1,7]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i64, ptr %{{[0-9]+}}, align 8, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = mul i64 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: ret i64 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(x: &usize) -> usize {
|
||||
*x * *x
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: usize = 7;
|
||||
let _ = callee(&x);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//@ needs-enzyme
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{llvm_filecheck, rfs, rustc};
|
||||
|
||||
fn main() {
|
||||
// Compile the Rust file with the required flags, capturing both stdout and stderr
|
||||
let output = rustc()
|
||||
.input("vec.rs")
|
||||
.arg("-Zautodiff=Enable,PrintTAFn=callee")
|
||||
.arg("-Zautodiff=NoPostopt")
|
||||
.opt_level("3")
|
||||
.arg("-Clto=fat")
|
||||
.arg("-g")
|
||||
.run();
|
||||
|
||||
let stdout = output.stdout_utf8();
|
||||
let stderr = output.stderr_utf8();
|
||||
|
||||
// Write the outputs to files
|
||||
rfs::write("vec.stdout", stdout);
|
||||
rfs::write("vec.stderr", stderr);
|
||||
|
||||
// Run FileCheck on the stdout using the check file
|
||||
llvm_filecheck().patterns("vec.check").stdin_buf(rfs::read("vec.stdout")).run();
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
|
||||
// CHECK: ptr %{{[0-9]+}}: {[-1]:Pointer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = getelementptr inbounds nuw i8, ptr %{{[0-9]+}}, i64 8, !dbg !{{[0-9]+}}: {[-1]:Pointer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load ptr, ptr %{{[0-9]+}}, align 8, !dbg !{{[0-9]+}}, !nonnull !102, !noundef !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = getelementptr inbounds nuw i8, ptr %{{[0-9]+}}, i64 16, !dbg !{{[0-9]+}}: {[-1]:Pointer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load i64, ptr %{{[0-9]+}}, align 8, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = icmp eq i64 %{{[0-9]+}}, 0, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: br i1 %{{[0-9]+}}, label %{{[0-9]+}}, label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi i64 [ %{{[0-9]+}}, %{{[0-9]+}} ], [ 0, %{{[0-9]+}} ], !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ %{{[0-9]+}}, %{{[0-9]+}} ], [ -0.000000e+00, %{{[0-9]+}} ], !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = getelementptr inbounds nuw float, ptr %{{[0-9]+}}, i64 %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Pointer, [-1,0]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = load float, ptr %{{[0-9]+}}, align 4, !dbg !{{[0-9]+}}, !noundef !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = fadd float %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: %{{[0-9]+}} = add nuw i64 %{{[0-9]+}}, 1, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: %{{[0-9]+}} = icmp eq i64 %{{[0-9]+}}, %{{[0-9]+}}, !dbg !{{[0-9]+}}: {[-1]:Integer}
|
||||
// CHECK-DAG: br i1 %{{[0-9]+}}, label %{{[0-9]+}}, label %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
// CHECK-DAG: %{{[0-9]+}} = phi float [ -0.000000e+00, %{{[0-9]+}} ], [ %{{[0-9]+}}, %{{[0-9]+}} ], !dbg !{{[0-9]+}}: {[-1]:Float@float}
|
||||
// CHECK-DAG: ret float %{{[0-9]+}}, !dbg !{{[0-9]+}}: {}
|
||||
14
tests/run-make/autodiff/type-trees/type-analysis/vec/vec.rs
Normal file
14
tests/run-make/autodiff/type-trees/type-analysis/vec/vec.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(autodiff)]
|
||||
|
||||
use std::autodiff::autodiff_reverse;
|
||||
|
||||
#[autodiff_reverse(d_square, Duplicated, Active)]
|
||||
#[no_mangle]
|
||||
fn callee(arg: &std::vec::Vec<f32>) -> f32 {
|
||||
arg.iter().sum()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let v = vec![1.0f32, 2.0, 3.0];
|
||||
let _ = callee(&v);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue