-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Add some validation for const nodes #1222
Changes from all commits
9f203e1
3c0b2a1
e207dd1
800a6e7
0fee7e9
6b9427e
08df26a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../resources/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ use thiserror::Error; | |
|
||
use crate::extension::{ExtensionRegistry, SignatureError, TO_BE_INFERRED}; | ||
|
||
use crate::ops::constant::ConstTypeError; | ||
use crate::ops::custom::{resolve_opaque_op, CustomOp, CustomOpError}; | ||
use crate::ops::validate::{ChildrenEdgeData, ChildrenValidationError, EdgeValidationError}; | ||
use crate::ops::{FuncDefn, OpParent, OpTag, OpTrait, OpType, ValidateOp}; | ||
|
@@ -214,6 +215,12 @@ impl<'a, 'b> ValidationContext<'a, 'b> { | |
// Thirdly that the node has correct children | ||
self.validate_children(node, op_type)?; | ||
|
||
// OpType-specific checks. | ||
// TODO Maybe we should delegate these checks to the OpTypes themselves. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, but I can see why you don't.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this TODO can be removed now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should remain, it does feel like this should call into a trait. |
||
if let OpType::Const(c) = op_type { | ||
c.validate()?; | ||
}; | ||
|
||
Ok(()) | ||
} | ||
|
||
|
@@ -759,6 +766,9 @@ pub enum ValidationError { | |
/// [Opaque]: crate::ops::CustomOp::Opaque | ||
#[error(transparent)] | ||
CustomOpError(#[from] CustomOpError), | ||
/// TODO | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add docstring? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awkward, will post a PR to fixup this |
||
#[error(transparent)] | ||
ConstTypeError(#[from] ConstTypeError), | ||
} | ||
|
||
/// Errors related to the inter-graph edge validations. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"version": "v1", | ||
"nodes": | ||
[ | ||
{ | ||
"parent": 0, | ||
"input_extensions": null, | ||
"op": "Const", | ||
"v": | ||
{ | ||
"v": "Extension", | ||
"extensions": | ||
[ | ||
"arithmetic.float.types" | ||
], | ||
"typ": | ||
{ | ||
"t": "Opaque", | ||
"extension": "arithmetic.float.types", | ||
"id": "float64", | ||
"args": | ||
[], | ||
"bound": "C" | ||
}, | ||
"value": | ||
{ | ||
"c": "ConstF64", | ||
"v": 42 | ||
} | ||
} | ||
} | ||
], | ||
"edges": | ||
[], | ||
"encoder": null | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"version": "v1", | ||
"nodes": | ||
[ | ||
{ | ||
"parent": 0, | ||
"input_extensions": null, | ||
"op": "Const", | ||
"v": | ||
{ | ||
"v": "Extension", | ||
"extensions": | ||
[ | ||
"arithmetic.float.types" | ||
], | ||
"typ": | ||
{ | ||
"t": "Opaque", | ||
"extension": "arithmetic.float.types", | ||
"id": "float64", | ||
"args": | ||
[], | ||
"bound": "C" | ||
}, | ||
"value": | ||
{ | ||
"c": "ConstF64", | ||
"v": | ||
{ | ||
"value": 42.0 | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"edges": | ||
[], | ||
"encoder": null | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"version": "v1", | ||
"nodes": | ||
[ | ||
{ | ||
"parent": 0, | ||
"input_extensions": null, | ||
"op": "Const", | ||
"v": | ||
{ | ||
"v": "Sum", | ||
"tag": 1, | ||
"typ": | ||
{ | ||
"t": "Sum", | ||
"s": "Unit", | ||
"size": 2 | ||
}, | ||
"vs": | ||
[ | ||
{ | ||
"v": "Tuple", | ||
"vs": | ||
[] | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"edges": | ||
[], | ||
"encoder": null | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"version": "v1", | ||
"nodes": | ||
[ | ||
{ | ||
"parent": 0, | ||
"input_extensions": null, | ||
"op": "Const", | ||
"v": | ||
{ | ||
"v": "Sum", | ||
"tag": 1, | ||
"typ": | ||
{ | ||
"t": "Sum", | ||
"s": "Unit", | ||
"size": 2 | ||
}, | ||
"vs": | ||
[] | ||
} | ||
} | ||
], | ||
"edges": | ||
[], | ||
"encoder": null | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to include float extensions here and below I think?. Maybe it's fine because
CustomConst
don't work through extensions.