Trait tract_pulse::internal::TypedOp
pub trait TypedOp: Op + Debug + DynClone + Send + Sync + 'static + Downcast + EvalOp {
Show 15 methods
// Required methods
fn as_op(&self) -> &(dyn Op + 'static);
fn as_op_mut(&mut self) -> &mut (dyn Op + 'static);
fn output_facts(
&self,
inputs: &[&TypedFact]
) -> Result<SmallVec<[TypedFact; 4]>, Error>;
// Provided methods
fn axes_mapping(
&self,
inputs: &[&TypedFact],
outputs: &[&TypedFact]
) -> Result<AxesMapping, Error> { ... }
fn fuse(
&self,
_model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
_node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>
) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>>, Error> { ... }
fn declutter_with_session(
&self,
session: &mut OptimizerSession<'_>,
model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>
) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>>, Error> { ... }
fn declutter(
&self,
model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>
) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>>, Error> { ... }
fn cost(
&self,
_inputs: &[&TypedFact]
) -> Result<SmallVec<[(Cost, TDim); 4]>, Error> { ... }
fn suggested_axis_changes(
&self
) -> Result<SmallVec<[(InOut, AxisOp); 4]>, Error> { ... }
fn change_axes(
&self,
model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>,
io: InOut,
change: &AxisOp
) -> Result<Option<AxisChangeConsequence>, Error> { ... }
fn slice(
&self,
patch: &mut ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>,
prefix: &str,
inputs: &[OutletId],
output_axis: usize,
start: usize,
end: usize
) -> Result<Option<SmallVec<[OutletId; 4]>>, Error> { ... }
fn quantize(
&self,
model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>,
dt: DatumType,
scale: f32,
zero_point: i32
) -> Result<Option<Box<dyn TypedOp + 'static, Global>>, Error> { ... }
fn concretize_dims(
&self,
source: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>,
target: &mut Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
mapping: &HashMap<OutletId, OutletId, RandomState>,
values: &SymbolValues
) -> Result<SmallVec<[OutletId; 4]>, Error> { ... }
fn codegen(
&self,
model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>
) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>>, Error> { ... }
fn nested_model_multipliers(
&self,
inputs: &[&TypedFact]
) -> Vec<(Cow<'_, str>, f64), Global> { ... }
}
Required Methods§
Provided Methods§
fn axes_mapping( &self, inputs: &[&TypedFact], outputs: &[&TypedFact] ) -> Result<AxesMapping, Error>
fn fuse(
&self,
_model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
_node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>
) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>>, Error>
fn fuse( &self, _model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>, _node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>> ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>>, Error>
Fuse op after codegen to deal with local optimisations.
fn declutter_with_session(
&self,
session: &mut OptimizerSession<'_>,
model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>
) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>>, Error>
fn declutter_with_session( &self, session: &mut OptimizerSession<'_>, model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>, node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>> ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>>, Error>
Declutter the op to the tract_core operator set as much as possible.
fn declutter(
&self,
model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>
) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>>, Error>
fn declutter( &self, model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>, node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>> ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>>, Error>
Declutter the op to the tract_core operator set as much as possible.
fn cost(
&self,
_inputs: &[&TypedFact]
) -> Result<SmallVec<[(Cost, TDim); 4]>, Error>
fn cost( &self, _inputs: &[&TypedFact] ) -> Result<SmallVec<[(Cost, TDim); 4]>, Error>
Computes a cost hint of the operation.
Each pair is a type of operation and a number per call on eval.
fn suggested_axis_changes( &self ) -> Result<SmallVec<[(InOut, AxisOp); 4]>, Error>
fn change_axes( &self, model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>, node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>, io: InOut, change: &AxisOp ) -> Result<Option<AxisChangeConsequence>, Error>
fn slice( &self, patch: &mut ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>, prefix: &str, inputs: &[OutletId], output_axis: usize, start: usize, end: usize ) -> Result<Option<SmallVec<[OutletId; 4]>>, Error>
fn quantize(
&self,
model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>,
dt: DatumType,
scale: f32,
zero_point: i32
) -> Result<Option<Box<dyn TypedOp + 'static, Global>>, Error>
fn quantize( &self, model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>, node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>, dt: DatumType, scale: f32, zero_point: i32 ) -> Result<Option<Box<dyn TypedOp + 'static, Global>>, Error>
Transforms the op in an equivalent one, operating on dt (i8 or u8).
Returns None if the op can not be translated.
fn concretize_dims(
&self,
source: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>,
target: &mut Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
mapping: &HashMap<OutletId, OutletId, RandomState>,
values: &SymbolValues
) -> Result<SmallVec<[OutletId; 4]>, Error>
fn concretize_dims( &self, source: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>, node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>, target: &mut Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>, mapping: &HashMap<OutletId, OutletId, RandomState>, values: &SymbolValues ) -> Result<SmallVec<[OutletId; 4]>, Error>
Transform the op into by providing a value to one or more symbols.
fn codegen(
&self,
model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>,
node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>>
) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>>, Error>
fn codegen( &self, model: &Graph<TypedFact, Box<dyn TypedOp + 'static, Global>>, node: &Node<TypedFact, Box<dyn TypedOp + 'static, Global>> ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static, Global>>>, Error>
Translate the op into the most efficient form possible for execution.
This transformation is supposed to be final, no more pass are expected to be run on the codegen networks.
Implementations§
§impl dyn TypedOp + 'static
impl dyn TypedOp + 'static
pub fn is<__T>(&self) -> boolwhere
__T: TypedOp,
pub fn is<__T>(&self) -> boolwhere __T: TypedOp,
Returns true if the trait object wraps an object of type __T
.
pub fn downcast<__T>(
self: Box<dyn TypedOp + 'static, Global>
) -> Result<Box<__T, Global>, Box<dyn TypedOp + 'static, Global>>where
__T: TypedOp,
pub fn downcast<__T>( self: Box<dyn TypedOp + 'static, Global> ) -> Result<Box<__T, Global>, Box<dyn TypedOp + 'static, Global>>where __T: TypedOp,
Returns a boxed object from a boxed trait object if the underlying object is of type
__T
. Returns the original boxed trait if it isn’t.
pub fn downcast_rc<__T>(
self: Rc<dyn TypedOp + 'static>
) -> Result<Rc<__T>, Rc<dyn TypedOp + 'static>>where
__T: TypedOp,
pub fn downcast_rc<__T>( self: Rc<dyn TypedOp + 'static> ) -> Result<Rc<__T>, Rc<dyn TypedOp + 'static>>where __T: TypedOp,
Returns an Rc
-ed object from an Rc
-ed trait object if the underlying object is of
type __T
. Returns the original Rc
-ed trait if it isn’t.
pub fn downcast_ref<__T>(&self) -> Option<&__T>where
__T: TypedOp,
pub fn downcast_ref<__T>(&self) -> Option<&__T>where __T: TypedOp,
Returns a reference to the object within the trait object if it is of type __T
, or
None
if it isn’t.
pub fn downcast_mut<__T>(&mut self) -> Option<&mut __T>where
__T: TypedOp,
pub fn downcast_mut<__T>(&mut self) -> Option<&mut __T>where __T: TypedOp,
Returns a mutable reference to the object within the trait object if it is of type
__T
, or None
if it isn’t.