# ArrayFire inplace assignment

**URL:** <https://discourse.julialang.org/t/arrayfire-inplace-assignment/15930>\
**Category:** New to Julia\
**Tags:** gpu\
**Created:** [October 5, 2018, 2:27pm UTC](https://discourse.julialang.org/t/arrayfire-inplace-assignment/15930 "2018-10-05T14:27:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [October 5, 2018, 2:27pm UTC](https://discourse.julialang.org/t/arrayfire-inplace-assignment/15930/1 "2018-10-05T14:27:01Z")

</div>

Hi,

It seems ArrayFire change the inplace assignment like

```julia
function rhs!(x)
x .= x .+ 1
end

```

This is not permitted. Removing `.=` does not modify `x`…

How are we supposed to write inplace functions then?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [October 5, 2018, 2:37pm UTC](https://discourse.julialang.org/t/arrayfire-inplace-assignment/15930/2 "2018-10-05T14:37:51Z")

</div>

> [@rveltz](#):
>
> How are we supposed to write inplace functions then?

You shouldn’t with ArrayFire. It has a special allocator that should handle memory issues.

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [October 5, 2018, 4:47pm UTC](https://discourse.julialang.org/t/arrayfire-inplace-assignment/15930/3 "2018-10-05T16:47:17Z")

</div>

OK, I will try.

Thank you for the hint

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [October 5, 2018, 7:31pm UTC](https://discourse.julialang.org/t/arrayfire-inplace-assignment/15930/4 "2018-10-05T19:31:11Z")

</div>

Actually it is faster to remove `@afgc` and let the `gc` do the work. You can use `swap!` if needed
