Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions jaxlib/gpu/rnn_kernels.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ DoRnnComputeWorkspaceReserveSpaceSizes(int input_size, int hidden_size,
JAX_RETURN_IF_ERROR(
JAX_AS_STATUS(gpudnnDestroyRNNDataDescriptor(input_data_desc)));
JAX_RETURN_IF_ERROR(JAX_AS_STATUS(gpudnnDestroyRNNDescriptor(rnn_desc)));
#ifdef JAX_GPU_HIP
JAX_RETURN_IF_ERROR(JAX_AS_STATUS(gpuFree(dropout_states_dev)));
#endif

// Round up to nearest multiples of 4 so we can return them as f32 arrays.
workSpaceSize += (workSpaceSize % 4);
Expand Down Expand Up @@ -351,6 +354,9 @@ static absl::Status DnnRNNForward_(gpuStream_t stream, void** buffers,
JAX_RETURN_IF_ERROR(
JAX_AS_STATUS(gpudnnDestroyDropoutDescriptor(dropout_desc)));
JAX_RETURN_IF_ERROR(JAX_AS_STATUS(gpudnnDestroyRNNDescriptor(rnn_desc)));
#ifdef JAX_GPU_HIP
JAX_RETURN_IF_ERROR(JAX_AS_STATUS(gpuFree(dropout_states_dev)));
#endif

return absl::OkStatus();
}
Expand Down Expand Up @@ -536,6 +542,9 @@ static absl::Status DnnRNNBackward_(gpuStream_t stream, void** buffers,
JAX_RETURN_IF_ERROR(
JAX_AS_STATUS(gpudnnDestroyDropoutDescriptor(dropout_desc)));
JAX_RETURN_IF_ERROR(JAX_AS_STATUS(gpudnnDestroyRNNDescriptor(rnn_desc)));
#ifdef JAX_GPU_HIP
JAX_RETURN_IF_ERROR(JAX_AS_STATUS(gpuFree(dropout_states_dev)));
#endif

return absl::OkStatus();
}
Expand Down
1 change: 1 addition & 0 deletions jaxlib/gpu/vendor.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ inline hipsparseStatus_t gpusparseCreate(gpusparseHandle_t* handle) {
#define GPU_STREAM_NON_BLOCKING hipStreamNonBlocking

#define gpuMalloc hipMalloc
#define gpuFree hipFree
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't believe it's not there yet...

Note, a corresponding entry is needed for CUDA too, and this needs to be upstreamed too

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, saw the upstream link in the descipriton, awesome. Then just an update for CUDA is needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep very funny to me aswell. looks like we have unlimited memory no need to free it. just keep using it :).
okay I'll update upstream aswell. thanks.

#define gpuGetLastError hipExtGetLastError
#define gpuGetErrorString hipGetErrorString
#define gpuMemcpyAsync hipMemcpyAsync
Expand Down