pub struct ApproxSigmoid {
pub precision: u64,
}
Expand description
A structure that defines the custom operation ApproxSigmoid that computes an approximate Sigmoid(x / (2 ** precision)) * (2 ** precision) using piecewise-linear approximation.
Sigmoid is a very commonly used function in ML: Sigmoid(x) = 1 / (1 + exp(-x)). So far this operation supports only INT64 scalar type.
§Custom operation arguments
- Node containing a signed 64-bit array or scalar to compute the sigmoid
§Custom operation returns
New ApproxSigmoid node
§Example
let c = create_context().unwrap();
let g = c.create_graph().unwrap();
let t = array_type(vec![3], INT64);
let x = g.input(t.clone()).unwrap();
let n = g.custom_op(CustomOperation::new(ApproxSigmoid {precision: 4}), vec![x]).unwrap();
Fields§
§precision: u64
Assume that we’re operating in fixed precision arithmetic with denominator 2 ** precision.
Trait Implementations§
Source§impl CustomOperationBody for ApproxSigmoid
impl CustomOperationBody for ApproxSigmoid
Source§impl Debug for ApproxSigmoid
impl Debug for ApproxSigmoid
Source§impl<'de> Deserialize<'de> for ApproxSigmoid
impl<'de> Deserialize<'de> for ApproxSigmoid
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Hash for ApproxSigmoid
impl Hash for ApproxSigmoid
Source§impl PartialEq for ApproxSigmoid
impl PartialEq for ApproxSigmoid
Source§impl Serialize for ApproxSigmoid
impl Serialize for ApproxSigmoid
impl Eq for ApproxSigmoid
impl StructuralPartialEq for ApproxSigmoid
Auto Trait Implementations§
impl Freeze for ApproxSigmoid
impl RefUnwindSafe for ApproxSigmoid
impl Send for ApproxSigmoid
impl Sync for ApproxSigmoid
impl Unpin for ApproxSigmoid
impl UnwindSafe for ApproxSigmoid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.