You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm now implementing a project related to tensor computation graph rewriting. I would like to attach custom data (e.g., output tensor shape) with each eclass. For example:
define_language!{pubenumMyLanguage{"tensor" = Tensor(Id),
"transpose" = Transpose(Id),
}}#[derive(Default,Debug,Clone)]pubstructMyAnalysis{}#[derive(Default,Debug,Clone)]pubstructTensorShape{pubshape:Vec<usize>,}implAnalysis<MyLanguage>forMyAnalysis{typeData = TensorShape;fnmake(egraph:&EGraph<MyLanguage,Self>,enode:&MyLanguage) -> Self::Data{let x = |i:&Id| egraph[*i].data;match enode {MyLanguage::Tensor(id) => {// how can I know the shape of this tensor?},MyLanguage::Transpose(id) => {// trasfer shapeunimplemented!()}}}fnmerge(&mutself,a:&mutSelf::Data,b:Self::Data) -> DidMerge{unimplemented!()}}fnmain(){let expr = "(transpose (tensor 0))";let tensorshapes = vec![TensorShape{ shape: vec![1, 2, 3]}];letmut runner = Runner::<MyLanguage,MyAnalysis>::default();
runner.run(..);}
However, I cannot find a good way to access the tensorshape of MyLanguage::Tensor(id) in the MyAnalysis::make. My solution for now is to change the MyLanguage to something like MyLanguage::Tensor(Id, Vec<Id>), and embeding the tensor shape into the Vec<Id>. But it seems not a good solution.
Is there a more elegant way to achieve this goal?
The text was updated successfully, but these errors were encountered:
Hi, I'm now implementing a project related to tensor computation graph rewriting. I would like to attach custom data (e.g., output tensor shape) with each eclass. For example:
However, I cannot find a good way to access the tensorshape of
MyLanguage::Tensor(id)
in theMyAnalysis::make
. My solution for now is to change the MyLanguage to something likeMyLanguage::Tensor(Id, Vec<Id>)
, and embeding the tensor shape into theVec<Id>
. But it seems not a good solution.Is there a more elegant way to achieve this goal?
The text was updated successfully, but these errors were encountered: