ruda_tensor/api/
exchange.rs1use super::{Tensor,Int};
2use crate::{Backend,primitive::TensorPrimitive,collective::{VariableTensorCollective,VariableTensorExchange}};
3
4impl<B:Backend,const D:usize> Tensor<B,D> {
5 pub fn all_to_all_v<C:VariableTensorCollective<B>>(self,communicator:C,send_counts:&[usize])
8 -> Result<VariableTensorExchange<Self>,C::Error> {
9 let result=communicator.all_to_all_v_float(self.into_primitive().tensor(),send_counts)?;
10 Ok(VariableTensorExchange {value:Tensor::from_primitive(TensorPrimitive::Float(result.value)),receive_counts:result.receive_counts})
11 }
12}
13impl<B:Backend,const D:usize> Tensor<B,D,Int> {
14 pub fn all_to_all_v_int<C:VariableTensorCollective<B>>(self,communicator:C,send_counts:&[usize])
16 -> Result<VariableTensorExchange<Self>,C::Error> {
17 let result=communicator.all_to_all_v_int(self.into_primitive(),send_counts)?;
18 Ok(VariableTensorExchange {value:Tensor::from_primitive(result.value),receive_counts:result.receive_counts})
19 }
20}