tract_hir/ops/array/
slice.rs1use crate::infer::*;
2use crate::internal::*;
3
4pub use tract_core::ops::array::Slice;
5
6impl InferenceRulesOp for Slice {
7 fn rules<'r, 'p: 'r, 's: 'r>(
8 &'s self,
9 s: &mut Solver<'r>,
10 inputs: &'p [TensorProxy],
11 outputs: &'p [TensorProxy],
12 ) -> InferenceResult {
13 check_input_arity(inputs, 1)?;
14 check_output_arity(outputs, 1)?;
15 s.equals(&inputs[0].rank, &outputs[0].rank)?;
16 s.equals(&inputs[0].datum_type, &outputs[0].datum_type)?;
17 s.given(&inputs[0].rank, move |s, rank| {
18 (0..(rank as usize)).try_for_each(move |axis| {
19 if self.axis == axis {
20 s.equals(&outputs[0].shape[axis], (self.end.clone() - &self.start).to_dim())
21 } else {
22 s.equals(&outputs[0].shape[axis], &inputs[0].shape[axis])
23 }
24 })
25 })?;
26 Ok(())
27 }
28
29 as_op!();
30 to_typed!();
31}