Skip to main content

adopt_untracked_eager_value

Function adopt_untracked_eager_value 

Source
pub fn adopt_untracked_eager_value(
    ctx: Arc<EagerRuntime>,
    value: TensorValue,
) -> EagerTensor
Expand description

Adopt an untracked eager tensor value produced by this runtime’s backend.

This is a low-level extension contract for eager composite operations that execute through EagerRuntime::with_backend_mut and receive a lazy TensorValue from the backend. The value must have been produced for the same eager runtime; this helper intentionally does not register gradient metadata and must not be used for tracked outputs.

§Examples

use tenferro_ad::extension::adopt_untracked_eager_value;
use tenferro_ad::EagerRuntime;
use tenferro_cpu::CpuBackend;
use tenferro_tensor::{Tensor, TensorValue};

let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new());
let value = TensorValue::from_tensor(
    Tensor::from_vec_col_major(vec![1], vec![1.0_f64]).unwrap(),
);
let eager = adopt_untracked_eager_value(ctx, value);
assert_eq!(eager.shape(), &[1]);
assert!(!eager.tracks_grad());