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

Method compute_shape

test/api/test_custom_op_gpu.cpp:231–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229 }
230
231 virtual migraphx::shape compute_shape(migraphx::shapes inputs) const override
232 {
233 if(inputs.size() != 1)
234 {
235 throw std::runtime_error("stride_two op must have only one input argument");
236 };
237 if(not inputs[0].standard())
238 {
239 throw std::runtime_error("stride_two op only works on the standard input shapes");
240 }
241 migraphx::shape input_s = inputs[0];
242 std::vector<size_t> dims = input_s.lengths();
243 std::vector<size_t> new_dims;
244 std::vector<size_t> strides = input_s.strides();
245 std::vector<size_t> new_strides;
246 std::for_each(dims.begin(), dims.end(), [&](auto i) { new_dims.push_back(i / 2); });
247 std::for_each(
248 strides.begin(), strides.end(), [&](auto i) { new_strides.push_back(i * 2); });
249 migraphx::shape output_shape{input_s.type(), new_dims, new_strides};
250 return output_shape;
251 }
252
253 virtual bool runs_on_offload_target() const override { return true; }
254 virtual std::vector<size_t> output_alias(migraphx::shapes) const override { return {0}; };

Callers

nothing calls this directly

Calls 7

for_eachFunction · 0.50
sizeMethod · 0.45
standardMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected