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

Method Compute

tensorflow/core/kernels/shape_ops.h:44–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 explicit ShapeOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}
43
44 void Compute(OpKernelContext* ctx) override {
45 TensorShape shape;
46 OP_REQUIRES_OK(ctx, shape_op_helpers::GetShape(ctx, 0, &shape));
47 const int rank = shape.dims();
48 Tensor* out = nullptr;
49 OP_REQUIRES_OK(ctx, ctx->allocate_output(0, TensorShape({rank}), &out));
50 auto vec = out->vec<OutType>();
51 for (int i = 0; i < rank; ++i) {
52 int64 dim_size = shape.dim_size(i);
53 if (out->dtype() == DT_INT32) {
54 OP_REQUIRES(
55 ctx, FastBoundsCheck(dim_size, std::numeric_limits<int32>::max()),
56 errors::InvalidArgument("Shape output type is 32-bit ", " but dim ",
57 i, " is ", dim_size));
58 }
59 vec(i) = static_cast<OutType>(dim_size);
60 }
61 }
62
63 bool IsExpensive() override { return false; }
64};

Callers

nothing calls this directly

Calls 9

FastBoundsCheckFunction · 0.85
InvalidArgumentFunction · 0.85
allocate_outputMethod · 0.80
GetShapeFunction · 0.70
TensorShapeClass · 0.50
maxFunction · 0.50
dimsMethod · 0.45
dim_sizeMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected