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

Function IsTypeSpecHelper

tensorflow/python/util/util.cc:506–514  ·  view source on GitHub ↗

Returns 1 if `o` is an instance of TypeSpec, but is not TensorSpec. Returns 0 otherwise. Returns -1 if an error occurred.

Source from the content-addressed store, hash-verified

504// Returns 0 otherwise.
505// Returns -1 if an error occurred.
506bool IsTypeSpecHelper(PyObject* o) {
507 static auto* const check_cache = new CachedTypeCheck([](PyObject* to_check) {
508 int is_type_spec = IsInstanceOfRegisteredType(to_check, "TypeSpec");
509 int is_tensor_spec = IsInstanceOfRegisteredType(to_check, "TensorSpec");
510 if ((is_type_spec == -1) || (is_tensor_spec == -1)) return -1;
511 return static_cast<int>(is_type_spec && !is_tensor_spec);
512 });
513 return check_cache->CachedLookup(o);
514}
515
516// Returns 1 if `o` is a (non-string) sequence or CompositeTensor or
517// (non-TensorSpec) TypeSpec.

Callers 2

IsTypeSpecFunction · 0.85

Calls 2

CachedLookupMethod · 0.80

Tested by

no test coverage detected