MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / normalize_cmp

Function normalize_cmp

ciphercore-base/src/ops/min_max.rs:56–67  ·  view source on GitHub ↗

If `cmp` is an array, add `1` to the shape by reshaping, otherwise, do nothing. This helper function is necessary for min/max, since we need to pad the shape of the result of the comparison in order to be able to call mux later.

(cmp: Node)

Source from the content-addressed store, hash-verified

54/// we need to pad the shape of the result of the comparison
55/// in order to be able to call mux later.
56fn normalize_cmp(cmp: Node) -> Result<Node> {
57 let cmp_type = cmp.get_type()?;
58 let normalized_cmp = if cmp_type.is_array() {
59 let mut new_shape = cmp_type.get_shape();
60 let st = cmp_type.get_scalar_type();
61 new_shape.push(1);
62 cmp.reshape(array_type(new_shape, st))?
63 } else {
64 cmp
65 };
66 Ok(normalized_cmp)
67}
68
69#[typetag::serde]
70impl CustomOperationBody for Min {

Callers 1

instantiateMethod · 0.85

Calls 7

is_arrayMethod · 0.80
get_shapeMethod · 0.80
array_typeFunction · 0.50
get_typeMethod · 0.45
get_scalar_typeMethod · 0.45
pushMethod · 0.45
reshapeMethod · 0.45

Tested by

no test coverage detected