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

Function broadcast_pair

ciphercore-base/src/broadcast.rs:29–44  ·  view source on GitHub ↗
(t1: Type, t2: Type)

Source from the content-addressed store, hash-verified

27}
28
29fn broadcast_pair(t1: Type, t2: Type) -> Result<Type> {
30 if t1.get_scalar_type() != t2.get_scalar_type() {
31 return Err(runtime_error!("Scalar types mismatch: {t1:?} and {t2:?}"));
32 }
33 if t1.is_scalar() {
34 return Ok(t2);
35 }
36 if t2.is_scalar() {
37 return Ok(t1);
38 }
39 let scalar_type = t1.get_scalar_type();
40 Ok(array_type(
41 broadcast_shapes(t1.get_shape(), t2.get_shape())?,
42 scalar_type,
43 ))
44}
45
46pub(super) fn broadcast_arrays(element_types: Vec<Type>) -> Result<Type> {
47 if element_types.is_empty() {

Callers 1

broadcast_arraysFunction · 0.85

Calls 5

broadcast_shapesFunction · 0.85
is_scalarMethod · 0.80
get_shapeMethod · 0.80
array_typeFunction · 0.70
get_scalar_typeMethod · 0.45

Tested by

no test coverage detected