| 27 | |
| 28 | private: |
| 29 | void Compute(user_op::KernelComputeContext* ctx) const override { |
| 30 | const user_op::Tensor* in = ctx->Tensor4ArgNameAndIndex("in", 0); |
| 31 | user_op::Tensor* out = ctx->Tensor4ArgNameAndIndex("out", 0); |
| 32 | const ShapeView& in_shape = in->shape_view(); |
| 33 | CHECK_EQ(out->shape_view(), in_shape); |
| 34 | const DataType in_data_type = in->data_type(); |
| 35 | CHECK_EQ(out->data_type(), in_data_type); |
| 36 | if (in_shape.elem_cnt() == 0) { |
| 37 | // 0 shape tensor do not need copy |
| 38 | return; |
| 39 | } else { |
| 40 | AutoMemcpy(ctx->stream(), out->mut_raw_dptr(), in->raw_dptr(), |
| 41 | in_shape.elem_cnt() * GetSizeOfDataType(in_data_type), out->mem_case(), |
| 42 | in->mem_case()); |
| 43 | } |
| 44 | } |
| 45 | bool AlwaysComputeWhenAllOutputsEmpty() const override { return false; } |
| 46 | }; |
| 47 |
nothing calls this directly
no test coverage detected