Use a literal instruction to replace the shape since output of shape operator are literals in migraphx
| 38 | // Use a literal instruction to replace the shape since output of |
| 39 | // shape operator are literals in migraphx |
| 40 | instruction_ref parse(const op_desc& /*opd*/, |
| 41 | const tf_parser& /*parser*/, |
| 42 | const tf_parser::node_info& info, |
| 43 | std::vector<instruction_ref> args) const |
| 44 | { |
| 45 | auto starts = args[1]->eval().get<int32_t>().to_vector(); |
| 46 | auto size = args[2]->eval().get<int32_t>().to_vector(); |
| 47 | auto axes = args[0]->get_shape().lens(); |
| 48 | size_t num_axes = axes.size(); |
| 49 | |
| 50 | std::vector<int64_t> axes_int64(axes.begin(), axes.end()); |
| 51 | std::vector<int64_t> starts_int64(starts.begin(), starts.end()); |
| 52 | std::vector<int64_t> ends(num_axes); |
| 53 | std::vector<int64_t> op_axes(num_axes); |
| 54 | std::iota(op_axes.begin(), op_axes.end(), 0); |
| 55 | for(size_t i = 0; i < num_axes; i++) |
| 56 | { |
| 57 | if(size[i] == -1) |
| 58 | ends[i] = axes_int64[i]; |
| 59 | else |
| 60 | ends[i] = starts_int64[i] + size[i]; |
| 61 | } |
| 62 | auto op = make_op("slice", {{"starts", starts_int64}, {"ends", ends}, {"axes", op_axes}}); |
| 63 | return info.add_instruction(op, info.make_contiguous(args[0])); |
| 64 | } |
| 65 | }; |
| 66 | |
| 67 | } // namespace tf |
nothing calls this directly
no test coverage detected