MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / NPyCast

Function NPyCast

tensorflow/compiler/xla/python/bfloat16.cc:719–728  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

717// Performs a NumPy array cast from type 'From' to 'To'.
718template <typename From, typename To>
719void NPyCast(void* from_void, void* to_void, npy_intp n, void* fromarr,
720 void* toarr) {
721 const auto* from =
722 reinterpret_cast<typename TypeDescriptor<From>::T*>(from_void);
723 auto* to = reinterpret_cast<typename TypeDescriptor<To>::T*>(to_void);
724 for (npy_intp i = 0; i < n; ++i) {
725 to[i] =
726 static_cast<typename TypeDescriptor<To>::T>(static_cast<To>(from[i]));
727 }
728}
729
730// Registers a cast between bfloat16 and type 'T'. 'numpy_type' is the NumPy
731// type corresponding to 'T'. If 'cast_is_safe', registers that bfloat16 can be

Callers 1

bfloat16.ccFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected