-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing bug of lalrpop and adding new features; bumping version to 0.1.9
- Loading branch information
Showing
44 changed files
with
860 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "scallop-core" | ||
version = "0.1.8" | ||
version = "0.1.9" | ||
authors = ["Ziyang Li <[email protected]>"] | ||
edition = "2018" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
core/src/runtime/dynamic/dataflow/foreign_predicate/constraint.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use crate::common::input_tag::*; | ||
|
||
use super::*; | ||
|
||
impl StaticInputTag for bool { | ||
fn from_dynamic_input_tag(t: &DynamicInputTag) -> Option<Self> { | ||
match t { | ||
DynamicInputTag::Bool(b) => Some(b.clone()), | ||
_ => None, | ||
} | ||
} | ||
} | ||
|
||
impl ConvertFromInputTag<()> for bool { | ||
fn from_input_tag(_: ()) -> Option<Self> { None } | ||
} | ||
|
||
impl ConvertFromInputTag<bool> for bool { | ||
fn from_input_tag(t: bool) -> Option<Self> { Some(t) } | ||
} | ||
|
||
impl ConvertFromInputTag<usize> for bool { | ||
fn from_input_tag(t: usize) -> Option<Self> { Some(t > 0) } | ||
} | ||
|
||
impl ConvertFromInputTag<f32> for bool { | ||
fn from_input_tag(t: f32) -> Option<Self> { Some(t > 0.0) } | ||
} | ||
|
||
impl ConvertFromInputTag<f64> for bool { | ||
fn from_input_tag(t: f64) -> Option<Self> { Some(t > 0.0) } | ||
} | ||
|
||
impl<T: Clone + 'static> ConvertFromInputTag<InputDiffProb<T>> for bool { | ||
fn from_input_tag(t: InputDiffProb<T>) -> Option<Self> { Some(t.0 > 0.0) } | ||
} |
3 changes: 3 additions & 0 deletions
3
core/src/runtime/provenance/common/input_tags/convert_input_tag.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub trait ConvertFromInputTag<X: Sized>: Sized { | ||
fn from_input_tag(t: X) -> Option<Self>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use crate::common::input_tag::*; | ||
|
||
use super::*; | ||
|
||
impl StaticInputTag for f64 { | ||
fn from_dynamic_input_tag(t: &DynamicInputTag) -> Option<Self> { | ||
match t { | ||
DynamicInputTag::Float(f) => Some(f.clone()), | ||
DynamicInputTag::ExclusiveFloat(f, _) => Some(f.clone()), | ||
_ => None, | ||
} | ||
} | ||
} | ||
|
||
impl ConvertFromInputTag<()> for f64 { | ||
fn from_input_tag(_: ()) -> Option<Self> { None } | ||
} | ||
|
||
impl ConvertFromInputTag<bool> for f64 { | ||
fn from_input_tag(t: bool) -> Option<Self> { Some(if t { 1.0 } else { 0.0 }) } | ||
} | ||
|
||
impl ConvertFromInputTag<usize> for f64 { | ||
fn from_input_tag(t: usize) -> Option<Self> { Some(if t > 0 { 1.0 } else { 0.0 }) } | ||
} | ||
|
||
impl ConvertFromInputTag<Exclusion> for f64 { | ||
fn from_input_tag(_: Exclusion) -> Option<Self> { None } | ||
} | ||
|
||
impl ConvertFromInputTag<f64> for f64 { | ||
fn from_input_tag(t: f64) -> Option<Self> { Some(t) } | ||
} | ||
|
||
impl ConvertFromInputTag<InputExclusiveProb> for f64 { | ||
fn from_input_tag(t: InputExclusiveProb) -> Option<Self> { Some(t.prob) } | ||
} | ||
|
||
impl<T: Clone + 'static> ConvertFromInputTag<InputDiffProb<T>> for f64 { | ||
fn from_input_tag(t: InputDiffProb<T>) -> Option<Self> { Some(t.0) } | ||
} | ||
|
||
impl<T: Clone + 'static> ConvertFromInputTag<InputExclusiveDiffProb<T>> for f64 { | ||
fn from_input_tag(t: InputExclusiveDiffProb<T>) -> Option<Self> { Some(t.prob) } | ||
} |
93 changes: 93 additions & 0 deletions
93
core/src/runtime/provenance/common/input_tags/input_diff_prob.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
use crate::common::input_tag::*; | ||
|
||
use super::*; | ||
|
||
/// An input differentiable probability. | ||
/// | ||
/// It contains two elements. | ||
/// The first is an `f64` which represents the probability of the tag. | ||
/// The second is an `Option<T>` which is the original differentiable object. | ||
/// Note that if the second element is provided as `None` then it means we | ||
/// do not treat the object as differentiable and thus we do not need to | ||
/// back-propagate gradients into it. | ||
/// In such case the probability is treated as a constant. | ||
#[derive(Clone)] | ||
pub struct InputDiffProb<T: Clone + 'static>(pub f64, pub Option<T>); | ||
|
||
impl<T: Clone + 'static> std::fmt::Debug for InputDiffProb<T> { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
self.0.fmt(f) | ||
} | ||
} | ||
|
||
impl<T: Clone + 'static> From<(f64, Option<T>)> for InputDiffProb<T> { | ||
fn from((p, t): (f64, Option<T>)) -> Self { | ||
Self(p, t) | ||
} | ||
} | ||
|
||
impl<T: Clone + 'static> StaticInputTag for InputDiffProb<T> { | ||
fn from_dynamic_input_tag(t: &DynamicInputTag) -> Option<Self> { | ||
match t { | ||
DynamicInputTag::ExclusiveFloat(f, _) => Some(Self(f.clone(), None)), | ||
DynamicInputTag::Float(f) => Some(Self(f.clone(), None)), | ||
_ => None, | ||
} | ||
} | ||
} | ||
|
||
impl<T: Clone + 'static> ConvertFromInputTag<()> for InputDiffProb<T> { | ||
fn from_input_tag(_: ()) -> Option<Self> { | ||
None | ||
} | ||
} | ||
|
||
impl<T: Clone + 'static> ConvertFromInputTag<bool> for InputDiffProb<T> { | ||
fn from_input_tag(b: bool) -> Option<Self> { | ||
if b { | ||
None | ||
} else { | ||
Some(Self(0.0, None)) | ||
} | ||
} | ||
} | ||
|
||
impl<T: Clone + 'static> ConvertFromInputTag<usize> for InputDiffProb<T> { | ||
fn from_input_tag(u: usize) -> Option<Self> { | ||
if u > 0 { | ||
None | ||
} else { | ||
Some(Self(0.0, None)) | ||
} | ||
} | ||
} | ||
|
||
impl<T: Clone + 'static> ConvertFromInputTag<Exclusion> for InputDiffProb<T> { | ||
fn from_input_tag(_: Exclusion) -> Option<Self> { | ||
None | ||
} | ||
} | ||
|
||
impl<T: Clone + 'static> ConvertFromInputTag<f64> for InputDiffProb<T> { | ||
fn from_input_tag(t: f64) -> Option<Self> { | ||
Some(Self(t, None)) | ||
} | ||
} | ||
|
||
impl<T: Clone + 'static> ConvertFromInputTag<InputExclusiveProb> for InputDiffProb<T> { | ||
fn from_input_tag(t: InputExclusiveProb) -> Option<Self> { | ||
Some(Self(t.prob, None)) | ||
} | ||
} | ||
|
||
impl<T: Clone + 'static> ConvertFromInputTag<InputDiffProb<T>> for InputDiffProb<T> { | ||
fn from_input_tag(t: InputDiffProb<T>) -> Option<Self> { | ||
Some(t.clone()) | ||
} | ||
} | ||
|
||
impl<T: Clone + 'static> ConvertFromInputTag<InputExclusiveDiffProb<T>> for InputDiffProb<T> { | ||
fn from_input_tag(t: InputExclusiveDiffProb<T>) -> Option<Self> { | ||
Some(Self(t.prob, None)) | ||
} | ||
} |
Oops, something went wrong.