Implement trait for tch::Tensor

I am building a framework to analyze generic flows in networks and I have the following (simplified) example:

use std::ops::Index;
use tch::Tensor;

pub trait Flows<F, Idx>: Index<Idx, Output = F> + Iterator<Item = F> {}

impl Flows<Tensor, Tensor> for Tensor {
    // TODO

fn main() {
    let t: Box<dyn Flows<Tensor, Tensor>> =
        Box::new(Tensor::of_slice(&[3, 1, 4, 1, 5]));

Sometimes, flows will be represented using tch::Tensors, which appear to implement some of the following traits already: - source. However, I can't seem to write the adapters correctly to dispatch standard rust calls to the underlying Tensor ones. Does anyone have any guidance? Thank you so much!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.