pub struct TaylorExponent {
pub taylor_terms: u64,
pub fixed_precision_points: u64,
}
Expand description
A structure that defines the custom operation TaylorExponent that computes an approximate exp(x / (2 ** fixed_precision)) * (2 ** fixed_precision) using Taylor expansion.
Note that Taylor expansion correcly approximates exp(x) only for positive x, so we have to do A2B to get the MSB. Since we’re doing A2B anyway, we can compute exp(integer_part(x)) and exp(fractional_part(x)) separately, computing the former directly from bits, and using Taylor expansion for the latter, getting better precision. See the Keller-Sun paper, Algorithm 2 for more details.
So far this operation supports only INT64 scalar type.
§Custom operation arguments
- Node containing a signed 64-bit array or scalar to compute the exponent
§Custom operation returns
New TaylorExponent node
§Example
let c = create_context().unwrap();
let g = c.create_graph().unwrap();
let t = array_type(vec![2, 3], INT64);
let x = g.input(t.clone()).unwrap();
let n2 = g.custom_op(CustomOperation::new(TaylorExponent {taylor_terms: 5, fixed_precision_points: 4}), vec![x]).unwrap();
Fields§
§taylor_terms: u64
Number of terms from the Taylor expansion to consider (5 is typically enough).
fixed_precision_points: u64
Assume that we’re operating in fixed precision arithmetic with denominator 2 ** fixed_precision_points.
Trait Implementations§
Source§impl CustomOperationBody for TaylorExponent
impl CustomOperationBody for TaylorExponent
Source§impl Debug for TaylorExponent
impl Debug for TaylorExponent
Source§impl<'de> Deserialize<'de> for TaylorExponent
impl<'de> Deserialize<'de> for TaylorExponent
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>,
Source§impl Hash for TaylorExponent
impl Hash for TaylorExponent
Source§impl PartialEq for TaylorExponent
impl PartialEq for TaylorExponent
Source§impl Serialize for TaylorExponent
impl Serialize for TaylorExponent
impl Eq for TaylorExponent
impl StructuralPartialEq for TaylorExponent
Auto Trait Implementations§
impl Freeze for TaylorExponent
impl RefUnwindSafe for TaylorExponent
impl Send for TaylorExponent
impl Sync for TaylorExponent
impl Unpin for TaylorExponent
impl UnwindSafe for TaylorExponent
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
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
key
and return true
if they are equal.