| 65 | ~GatherKernel() override = default; |
| 66 | |
| 67 | std::shared_ptr<user_op::OpKernelCache> InitOpKernelCache( |
| 68 | user_op::KernelCacheContext* ctx) const override { |
| 69 | if (ctx->parallel_ctx().parallel_num() > 1) { |
| 70 | const auto axis = ctx->Attr<int64_t>("axis"); |
| 71 | const NdSbp& in_nd_sbp = ctx->NdSbp4ArgNameAndIndex("in", 0); |
| 72 | const Shape& hierarchy = *ctx->parallel_desc().hierarchy(); |
| 73 | CheckNdSbp(hierarchy, axis, in_nd_sbp, ctx->NdSbp4ArgNameAndIndex("indices", 0), |
| 74 | ctx->NdSbp4ArgNameAndIndex("out", 0)); |
| 75 | const Shape in_logical_shape = |
| 76 | ExpandDimIf0D(ctx->LogicalTensorDesc4ArgNameAndIndex("in", 0)->shape()); |
| 77 | TensorSliceView view = GetTensorSliceView4ParallelId(hierarchy, in_nd_sbp, in_logical_shape, |
| 78 | ctx->parallel_ctx().parallel_id()); |
| 79 | return std::make_shared<GatherOpKernelCache>(view.At(axis).begin(), view.At(axis).end()); |
| 80 | } else { |
| 81 | return nullptr; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | private: |
| 86 | void Compute(user_op::KernelComputeContext* ctx, user_op::OpKernelState*, |
nothing calls this directly
no test coverage detected