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

Method Compute

tensorflow/core/kernels/shape_ops.h:71–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69 explicit ShapeNOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}
70
71 void Compute(OpKernelContext* ctx) override {
72 for (int i = 0; i < ctx->num_inputs(); ++i) {
73 TensorShape shape;
74 OP_REQUIRES_OK(ctx, shape_op_helpers::GetShape(ctx, i, &shape));
75 const int dims = shape.dims();
76 Tensor* out = nullptr;
77 OP_REQUIRES_OK(ctx, ctx->allocate_output(i, {dims}, &out));
78 auto vec = out->vec<OutType>();
79
80 for (int j = 0; j < dims; ++j) {
81 int64 dim_size = shape.dim_size(j);
82 if (out->dtype() == DT_INT32) {
83 OP_REQUIRES(
84 ctx, FastBoundsCheck(dim_size, std::numeric_limits<int32>::max()),
85 errors::InvalidArgument("ShapeN output type is 32-bit but shape ",
86 i, " dim ", j, " is ", dim_size));
87 }
88 vec(j) = static_cast<OutType>(dim_size);
89 }
90 }
91 }
92
93 bool IsExpensive() override { return false; }
94};

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected