cubecl_std/tensor/view/operations/
view.rs

1use super::*;
2use crate::tensor::layout::Coordinates;
3use crate::tensor::{View, ViewExpand};
4use cubecl::prelude::*;
5use cubecl_core::{self as cubecl, prelude::barrier::BarrierExpand};
6
7impl<T: CubePrimitive, C: Coordinates, IO: Clone> Lined for View<T, C, IO> {}
8impl<T: CubePrimitive, C: Coordinates, IO: Clone> LinedExpand for ViewExpand<T, C, IO> {
9    fn line_size(&self) -> u32 {
10        ViewExpand::line_size(self)
11    }
12}
13
14impl<T: CubePrimitive, C: Coordinates, IO: Clone> ViewOperations<T, C> for View<T, C, IO> {}
15impl<T: CubePrimitive, C: Coordinates, IO: Clone> ViewOperationsExpand<T, C>
16    for ViewExpand<T, C, IO>
17{
18    fn __expand_read_method(&self, scope: &mut Scope, pos: <C>::ExpandType) -> <T>::ExpandType {
19        ViewExpand::__expand_read_method(self.clone(), scope, pos)
20    }
21
22    fn __expand_read_checked_method(
23        &self,
24        scope: &mut Scope,
25        pos: <C>::ExpandType,
26    ) -> <T>::ExpandType {
27        ViewExpand::__expand_read_checked_method(self.clone(), scope, pos)
28    }
29
30    fn __expand_read_masked_method(
31        &self,
32        scope: &mut Scope,
33        pos: <C>::ExpandType,
34        mask_value: <T>::ExpandType,
35    ) -> <T>::ExpandType {
36        ViewExpand::__expand_read_masked_method(self.clone(), scope, pos, mask_value)
37    }
38
39    fn __expand_read_unchecked_method(
40        &self,
41        scope: &mut Scope,
42        pos: <C>::ExpandType,
43    ) -> <T>::ExpandType {
44        ViewExpand::__expand_read_unchecked_method(self.clone(), scope, pos)
45    }
46
47    fn __expand_to_linear_slice_method(
48        &self,
49        scope: &mut Scope,
50        pos: <C>::ExpandType,
51        end: <C>::ExpandType,
52    ) -> SliceExpand<T, ReadOnly> {
53        ViewExpand::__expand_to_linear_slice_inner_method(self.clone(), scope, pos, end)
54    }
55
56    fn __expand_shape_method(&self, scope: &mut Scope) -> <C>::ExpandType {
57        ViewExpand::__expand_shape_method(self, scope)
58    }
59
60    fn __expand_is_in_bounds_method(
61        &self,
62        scope: &mut Scope,
63        pos: <C>::ExpandType,
64    ) -> ExpandElementTyped<bool> {
65        ViewExpand::__expand_is_in_bounds_method(self, scope, pos)
66    }
67
68    fn __expand_tensor_map_load_method(
69        &self,
70        scope: &mut Scope,
71        barrier: BarrierExpand,
72        shared_memory: SliceExpand<T, ReadWrite>,
73        pos: C::ExpandType,
74    ) {
75        ViewExpand::__expand_tensor_map_load_method(
76            self.clone(),
77            scope,
78            barrier,
79            shared_memory,
80            pos,
81        )
82    }
83}
84
85impl<T: CubePrimitive, C: Coordinates> ViewOperationsMut<T, C> for View<T, C, ReadWrite> {}
86impl<T: CubePrimitive, C: Coordinates> ViewOperationsMutExpand<T, C>
87    for ViewExpand<T, C, ReadWrite>
88{
89    fn __expand_write_method(
90        &self,
91        scope: &mut Scope,
92        pos: <C>::ExpandType,
93        value: <T>::ExpandType,
94    ) {
95        ViewExpand::__expand_write_method(self.clone(), scope, pos, value);
96    }
97
98    fn __expand_write_checked_method(
99        &self,
100        scope: &mut Scope,
101        pos: <C>::ExpandType,
102        value: <T>::ExpandType,
103    ) {
104        ViewExpand::__expand_write_checked_method(self.clone(), scope, pos, value);
105    }
106
107    fn __expand_to_linear_slice_mut_method(
108        &self,
109        scope: &mut Scope,
110        pos: <C>::ExpandType,
111        end: <C>::ExpandType,
112    ) -> SliceExpand<T, ReadWrite> {
113        ViewExpand::__expand_to_linear_slice_mut_inner_method(self.clone(), scope, pos, end)
114    }
115
116    fn __expand_tensor_map_store_method(
117        &self,
118        scope: &mut Scope,
119        shared_memory: SliceExpand<T, ReadOnly>,
120        pos: C::ExpandType,
121    ) {
122        ViewExpand::__expand_tensor_map_store_method(self.clone(), scope, shared_memory, pos)
123    }
124}