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

Method GetScalarFromTensor

tensorflow/core/framework/shape_inference.cc:963–979  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

961}
962
963Status InferenceContext::GetScalarFromTensor(const Tensor* t, int64* val) {
964 // Caller must ensure that <t> is not NULL.
965 const int rank = t->dims();
966 if (rank != 0) {
967 return errors::InvalidArgument("Input must be scalar but has rank ", rank);
968 }
969
970 if (t->dtype() == DT_INT32) {
971 *val = t->scalar<int32>()();
972 return Status::OK();
973 } else if (t->dtype() == DT_INT64) {
974 *val = t->scalar<int64>()();
975 return Status::OK();
976 } else {
977 return errors::InvalidArgument("Scalar input must be int32 or int64.");
978 }
979}
980
981// Returns a new dimension whose value is given by a scalar input tensor.
982Status InferenceContext::MakeDimForScalarInput(int idx, DimensionHandle* out) {

Callers 2

array_ops.ccFile · 0.80
math_ops.ccFile · 0.80

Calls 3

InvalidArgumentFunction · 0.85
dimsMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected