pub struct OpSchema { /* private fields */ }
Expand description

| ———– | @brief | | A class to record the schema of an op. | | OpSchema records the common interface | of an op specified by its name. This is | optional for each operator implemented | in Caffe2 but is strongly recommended. | | To register an OpSchema, one can use | the macro | | OPERATOR_SCHEMA(name) and then append | the various functions in the class. | For example, for an op that takes in two | inputs, one output, and the first input | and output could be in-place, can be | written as | | OPERATOR_SCHEMA(name) | .NumInputs(2) | .NumOutputs(1) | .AllowInplace({{0, 0}}); |

Implementations§

source§

impl OpSchema

source

pub fn has_cost_inference_function(&self) -> bool

source

pub fn infer_cost( &self, def: &OperatorDef, input_tensor_shape: &Vec<TensorShape> ) -> OpSchemaCost

source

pub fn input_desc(&self) -> &Vec<(*const u8, *const u8)>

source

pub fn output_desc(&self) -> &Vec<(*const u8, *const u8)>

source

pub fn num_inputs_with_function( &mut self, func: fn(_u0: i32) -> bool ) -> &mut OpSchema

| Functions to set the property of the | operator schemas. | | Sets the number of inputs, either a fixed | number or a min and a max.

| ———– | @brief | | Input is checked with a specified function. |

source

pub fn num_outputs_from_function( &mut self, func: fn(_u0: i32) -> bool ) -> &mut OpSchema

| ———– | @brief | | Output is checked with a specified function. |

source

pub fn num_inputs_outputs( &mut self, func: fn(_u0: i32, _u1: i32) -> bool ) -> &mut OpSchema

| ———– | @brief | | Relationship between inputs and outputs | is checked with a specified function. |

source

pub fn output_calculator(&mut self, calc: fn(_u0: i32) -> i32) -> &mut OpSchema

| ———– | @brief | | Set the output calculator to a user-defined | function. | | Set the function that can calculate | the number of output based on the number | of input. Use only one function in the | set below. |

source

pub fn allow_inplace_with_functor( &mut self, inplace: fn(_u0: i32, _u1: i32) -> bool ) -> &mut OpSchema

| Sets the rule to allow optional in-place | operation. |

source

pub fn allow_inplace(&mut self, inplace: HashSet<(i32, i32)>) -> &mut OpSchema

source

pub fn allow_one_to_one_inplace(&mut self) -> &mut OpSchema

source

pub fn enforce_inplace_with_function( &mut self, inplace: fn(_u0: i32, _u1: i32) -> bool ) -> &mut OpSchema


Sets the rule to enforce in-place operation.

source

pub fn enforce_inplace(&mut self, inplace: HashSet<(i32, i32)>) -> &mut OpSchema

source

pub fn enforce_one_to_one_inplace(&mut self) -> &mut OpSchema

source

pub fn fill_using( &mut self, populator: fn(_u0: &mut OpSchema) -> c_void ) -> &mut OpSchema

| Calls the passed function with this as | an argument. Useful for adding docs for | templated/macro ops.

source

pub fn num_inputs_from_set( &mut self, allowed_input_nums: HashSet<i32> ) -> &mut OpSchema

| ———– | @brief | | Input could be one of the values specified | in allowed_input_nums. |

source

pub fn num_outputs_bounded(&mut self, min: i32, max: i32) -> &mut OpSchema

| ———– | @brief | | Output could be in range [min, max], | inclusive. |

source

pub fn num_outputs_fixed(&mut self, n: i32) -> &mut OpSchema

| ———– | @brief | | A single output. | | Sets the number of outputs, either a | fixed number, a min and a max, or a function | that takes in the input number and produces | an output number. | | Use only one function in the set below. |

source

pub fn num_outputs_from_set( &mut self, allowed_output_nums: HashSet<i32> ) -> &mut OpSchema

| ———– | @brief | | Output could be one of the values specified | in allowed_output_nums. |

source

pub fn same_number_of_output(&mut self) -> &mut OpSchema

| ———– | @brief | | Set the number of outputs to be the same | as the number of inputs. |

source

pub fn input( &mut self, n: i32, name: *const u8, description: *const u8 ) -> &mut OpSchema

source

pub fn output( &mut self, n: i32, name: *const u8, description: *const u8 ) -> &mut OpSchema

source

pub fn calculate_output(&self, num_input: i32) -> i32

| ———– | @brief | | A function to allow one to get the number | of outputs based on the number of inputs, | if this schema supports it. |

source

pub fn sparse_lengths_filler_helper( &mut self, shapes: &Vec<Vec<i64>>, value_index: usize, length_index: usize, fillers: *mut Vec<TensorFiller> )

source

pub fn sparse_weights_filler_helper( &mut self, shapes: &Vec<Vec<i64>>, weight_index: usize, fillers: *mut Vec<TensorFiller> )

source

pub fn sparse_segments_filler_helper( &mut self, shapes: &Vec<Vec<i64>>, value_index: usize, segment_index: usize, fillers: *mut Vec<TensorFiller> )

source

pub fn value_key_length_input_fillers( &mut self, value_index: usize, key_index: usize, length_index: usize ) -> &mut OpSchema

| The helper is build sparse input with | values, keys, weights and lengths; | | e.g.: | values = [1, 2, 3, 2, 4, 6, 7, 3, 6] | keys = [0, 1, 4, 0, 1, 2, 5, 1, 2] | _/ ___/ _/ | lengths = [3, 4, 2]

source

pub fn weighted_value_key_length_input_fillers( &mut self, value_index: usize, key_index: usize, length_index: usize, weight_index: usize ) -> &mut OpSchema

| The helper is build sparse input with | values, keys, weights and lengths; | | e.g.: | values = [1, 2, 3, 2, 4, 6, 7, 3, 6] | keys = [0, 1, 4, 0, 1, 2, 5, 1, 2] | weights = [1, 1, 1, 0, 2, 2, 2, 1, 2] | _/ ___/ _/ | lengths = [3, 4, 2]

source

pub fn value_length_input_fillers( &mut self, value_index: usize, length_index: usize ) -> &mut OpSchema

| The helper is build sparse input with | values and lengths; e.g.: | | values = [1, 2, 3, 2, 4, 6, 7, 3, 6] | _/ ___/ _/ | lengths = [3, 4, 2]

source

pub fn disallow_input_fillers(&mut self) -> &mut OpSchema

source

pub fn input_fillers(&self, shapes: &Vec<Vec<i64>>) -> Vec<TensorFiller>

source

pub fn supply_dense_fillers( &mut self, shapes: &Vec<Vec<i64>> ) -> Vec<TensorFiller>

source

pub fn new(ty: &String, file: &String, line: i32) -> Self

source

pub fn file(&self) -> &String

| ———– | @brief | | Returns the file that the op schema is | registered from. |

source

pub fn line(&self) -> i32

| ———– | @brief | | Returns the line in file that the op schema | is registered from. |

source

pub fn doc(&self) -> *const u8

| ———– | @brief | | Returns the docstring of the op schema. |

source

pub fn inherit_onnx_schema_default(&mut self) -> &mut OpSchema

| ———– | @brief | | Shortcut to InheritOnnxSchema(type_) |

source

pub fn infer_tensor( &self, def: &OperatorDef, input_type_shape: &Vec<TensorShape> ) -> Vec<TensorShape>

| ———– | @brief | | A function to allow one to infer the type | and shape from the op schema. |

source

pub fn verify(&self, def: &OperatorDef) -> bool

| ———– | @brief | | Verifies if an operator definition | protobuf matches the pattern specified | in the schema. |

source

pub fn num_inputs_bounded(&mut self, min: i32, max: i32) -> &mut OpSchema

| ———– | @brief | | Input could be in range [min, max], inclusive. |

source

pub fn num_inputs_fixed(&mut self, n: i32) -> &mut OpSchema

| ———– | @brief | | A single input. |

source

pub fn onnx_schema(&self) -> &String

source

pub fn min_input(&self) -> i32

source

pub fn max_input(&self) -> i32

source

pub fn min_output(&self) -> i32

source

pub fn max_output(&self) -> i32

source

pub fn num_inputs_allowed(&self, x: i32) -> bool

source

pub fn num_outputs_allowed(&self, x: i32) -> bool

source

pub fn num_inputs_outputs_allowed(&self, x: i32, y: i32) -> bool

source

pub fn inf(&self) -> i32

source

pub fn inplace_enforced(&self, x: i32, y: i32) -> bool

source

pub fn args(&self) -> &Vec<SchemaArgument>

source

pub fn private_op(&mut self) -> bool

source

pub fn can_inputs_cross_devices(&self) -> bool

source

pub fn infer_device( &self, def: &OperatorDef ) -> (Vec<DeviceOption>, Vec<DeviceOption>)

| ———– | @brief | | Infer required device location of an | op’s inputs and outputs |

source

pub fn private(&mut self) -> &mut OpSchema

Remove from documentation

source

pub fn inputs_can_cross_devices(&mut self) -> &mut OpSchema

This op can pass data across devices

source

pub fn tensor_inference_function( &mut self, function: TensorInferenceFunctionType ) -> &mut OpSchema

| Functions to deal with type and shape | inference. Basically, this registers | a function that takes in an OperatorDef | and a series of input type and shape specified | by | | TensorProto objects (whose data fields | are empty), and produces a series of | output type and shape. |

| ———– | @brief | | Sets the tensor inference function, | which is a std::function object defined | in operator_schema.h. |

source

pub fn needs_all_input_shapes( f: TensorInferenceFunctionType ) -> TensorInferenceFunctionType

| A wrapper that makes an infer tensor | function to return unknown shape for | all outputs if any one of the inputs has | unknown shape |

source

pub fn inherit_onnx_schema( &mut self, onnx_schema_name: &String ) -> &mut OpSchema

| ———– | @brief | | Sets the corresponding onnx schema | name |

source

pub fn identical_type_and_shape(&mut self) -> &mut OpSchema

| ———– | @brief | | Sets the tensor inference function | to produce the same output as the input. |

source

pub fn identical_type_and_shape_of_input(&mut self, idx: i32) -> &mut OpSchema

source

pub fn identical_type_and_shape_of_multiple_inputs( &mut self, indices: &Vec<i32> ) -> &mut OpSchema

source

pub fn identical_type_and_shape_of_input_dim( &mut self, idx: i32, dim: i32 ) -> &mut OpSchema

source

pub fn scalar_type(&mut self, dt: TensorProto_DataType) -> &mut OpSchema

source

pub fn cost_inference_function( &mut self, function: CostInferenceFunctionType ) -> &mut OpSchema

| ———– | @brief | | Register the Cost inference function. |

source

pub fn device_inference_function( &mut self, function: DeviceInferenceFunctionType ) -> &mut OpSchema

| ———– | @brief | | Returns the required device location | of inputs and outputs. |

source

pub fn set_doc(&mut self, doc: &String) -> &mut OpSchema

| Functions to do documentation for the | operator schema. |

source

pub fn arg( &mut self, name: *const u8, description: *const u8, required: Option<bool> ) -> &mut OpSchema

Trait Implementations§

source§

impl Default for OpSchema

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for OpSchema

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V