MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / canOptimizeCast

Function canOptimizeCast

src/backend/common/cast.hpp:55–64  ·  view source on GitHub ↗

This function determines if consecutive cast operations should be removed from a JIT AST. This function returns true if consecutive cast operations in the JIT AST should be removed. Multiple cast operations are removed when going from a smaller type to a larger type and back again OR if the conversion is between two floating point types including complex types. Cast operations that will be remov

Source from the content-addressed store, hash-verified

53///
54/// \returns True if the inner cast operation should be removed
55constexpr bool canOptimizeCast(af::dtype outer, af::dtype inner) {
56 if (isFloating(outer)) {
57 if (isFloating(inner)) { return true; }
58 } else {
59 if (isFloating(inner)) { return true; }
60 if (dtypeSize(inner) >= dtypeSize(outer)) { return true; }
61 }
62
63 return false;
64}
65
66#ifdef AF_CPU
67template<typename To, typename Ti>

Callers 1

operator()Method · 0.85

Calls 2

isFloatingFunction · 0.85
dtypeSizeFunction · 0.85

Tested by

no test coverage detected