cubecl_std/tensor/view/operations/
view.rs1use super::*;
2use crate::tensor::{View, ViewExpand};
3use crate::{CubeOptionExpand, tensor::layout::Coordinates};
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_as_tensor_map_method(&self, scope: &mut Scope) -> CubeOptionExpand<TensorMap<T>> {
57 ViewExpand::__expand_as_tensor_map_method(self.clone(), scope)
58 }
59
60 fn __expand_shape_method(&self, scope: &mut Scope) -> <C>::ExpandType {
61 ViewExpand::__expand_shape_method(self, scope)
62 }
63
64 fn __expand_is_in_bounds_method(
65 &self,
66 scope: &mut Scope,
67 pos: <C>::ExpandType,
68 ) -> ExpandElementTyped<bool> {
69 ViewExpand::__expand_is_in_bounds_method(self, scope, pos)
70 }
71
72 fn __expand_tensor_map_load_method(
73 &self,
74 scope: &mut Scope,
75 barrier: BarrierExpand,
76 shared_memory: SliceExpand<T, ReadWrite>,
77 pos: C::ExpandType,
78 ) {
79 ViewExpand::__expand_tensor_map_load_method(
80 self.clone(),
81 scope,
82 barrier,
83 shared_memory,
84 pos,
85 )
86 }
87}
88
89impl<T: CubePrimitive, C: Coordinates> ViewOperationsMut<T, C> for View<T, C, ReadWrite> {}
90impl<T: CubePrimitive, C: Coordinates> ViewOperationsMutExpand<T, C>
91 for ViewExpand<T, C, ReadWrite>
92{
93 fn __expand_write_method(
94 &self,
95 scope: &mut Scope,
96 pos: <C>::ExpandType,
97 value: <T>::ExpandType,
98 ) {
99 ViewExpand::__expand_write_method(self.clone(), scope, pos, value);
100 }
101
102 fn __expand_write_checked_method(
103 &self,
104 scope: &mut Scope,
105 pos: <C>::ExpandType,
106 value: <T>::ExpandType,
107 ) {
108 ViewExpand::__expand_write_checked_method(self.clone(), scope, pos, value);
109 }
110
111 fn __expand_to_linear_slice_mut_method(
112 &self,
113 scope: &mut Scope,
114 pos: <C>::ExpandType,
115 end: <C>::ExpandType,
116 ) -> SliceExpand<T, ReadWrite> {
117 ViewExpand::__expand_to_linear_slice_mut_inner_method(self.clone(), scope, pos, end)
118 }
119
120 fn __expand_tensor_map_store_method(
121 &self,
122 scope: &mut Scope,
123 shared_memory: SliceExpand<T, ReadOnly>,
124 pos: C::ExpandType,
125 ) {
126 ViewExpand::__expand_tensor_map_store_method(self.clone(), scope, shared_memory, pos)
127 }
128}