| 126 | virtual bool runs_on_offload_target() const override { return true; } |
| 127 | |
| 128 | virtual migraphx::argument |
| 129 | compute(migraphx::context ctx, migraphx::shape, migraphx::arguments inputs) const override |
| 130 | { |
| 131 | // This custom op simply sets first half size_bytes of the input 0, and rest of the half |
| 132 | // bytes are copied. for this custom_op, it does its computation on the "device". Therefore, |
| 133 | // `runs_on_offload_target()` is set to "true" |
| 134 | auto* buffer_ptr = inputs[0].data(); |
| 135 | auto input_bytes = inputs[0].get_shape().bytes(); |
| 136 | auto copy_bytes = input_bytes / 2; |
| 137 | MIGRAPHX_HIP_ASSERT(hipSetDevice(0)); |
| 138 | MIGRAPHX_HIP_ASSERT( |
| 139 | hipMemsetAsync(buffer_ptr, 0, copy_bytes, ctx.get_queue<hipStream_t>())); |
| 140 | MIGRAPHX_HIP_ASSERT(hipDeviceSynchronize()); |
| 141 | return inputs[0]; |
| 142 | } |
| 143 | |
| 144 | virtual migraphx::shape compute_shape(migraphx::shapes inputs) const override |
| 145 | { |