|
| 1 | +// Copyright 2020 TensorFlow Authors |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#include "tensorflow/compiler/tf2xla/xla_tensor/ops/replica_id.h" |
| 16 | + |
| 17 | +#include "tensorflow/compiler/tf2xla/xla_tensor/lowering_context.h" |
| 18 | + |
| 19 | +namespace swift_xla { |
| 20 | +namespace ir { |
| 21 | +namespace ops { |
| 22 | + |
| 23 | +ReplicaId::ReplicaId() : Node( |
| 24 | + ir::OpKind(at::aten::xla_replica_id), |
| 25 | + {}, |
| 26 | + xla::ShapeUtil::MakeShape(xla::S32, {}), |
| 27 | + 1, 0x18923728) {} |
| 28 | + |
| 29 | +NodePtr ReplicaId::Clone(OpList operands) const { |
| 30 | + return MakeNode<ReplicaId>(); |
| 31 | +} |
| 32 | + |
| 33 | +XlaOpVector ReplicaId::Lower(LoweringContext* loctx) const { |
| 34 | + return ReturnOp(xla::ConvertElementType( |
| 35 | + xla::ReplicaId(loctx->builder()), xla::S32), loctx); |
| 36 | +} |
| 37 | + |
| 38 | +std::string ReplicaId::ToString() const { |
| 39 | + std::stringstream ss; |
| 40 | + ss << Node::ToString(); |
| 41 | + return ss.str(); |
| 42 | +} |
| 43 | + |
| 44 | +} // namespace ops |
| 45 | +} // namespace ir |
| 46 | +} // namespace swift_xla |
0 commit comments