MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / parse

Method parse

src/tf/parse_slice.cpp:40–64  ·  view source on GitHub ↗

Use a literal instruction to replace the shape since output of shape operator are literals in migraphx

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

iotaFunction · 0.85
lensMethod · 0.80
make_opFunction · 0.50
to_vectorMethod · 0.45
evalMethod · 0.45
get_shapeMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
add_instructionMethod · 0.45
make_contiguousMethod · 0.45

Tested by

no test coverage detected