-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic working jax-cuda implementation for forwards.
- Loading branch information
1 parent
343c333
commit cfa089c
Showing
14 changed files
with
389 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
#ifndef _JAX_CUDA_H_ | ||
#define _JAX_CUDA_H_ | ||
|
||
#include <cuda_runtime.h> | ||
#include <cuda_runtime_api.h> | ||
|
||
struct SphDescriptor { | ||
std::int64_t n_samples; | ||
std::int64_t lmax; | ||
bool normalize; | ||
}; | ||
|
||
namespace sphericart_jax { | ||
|
||
namespace cuda { | ||
|
||
void apply_cuda_sph_f32(cudaStream_t stream, void **in, const char *opaque, | ||
std::size_t opaque_len); | ||
|
||
void apply_cuda_sph_f64(cudaStream_t stream, void **in, const char *opaque, | ||
std::size_t opaque_len); | ||
|
||
void apply_cuda_sph_with_gradients_f32(cudaStream_t stream, void **in, | ||
const char *opaque, | ||
std::size_t opaque_len); | ||
|
||
void apply_cuda_sph_with_gradients_f64(cudaStream_t stream, void **in, | ||
const char *opaque, | ||
std::size_t opaque_len); | ||
|
||
void apply_cuda_sph_with_hessians_f32(cudaStream_t stream, void **in, | ||
const char *opaque, | ||
std::size_t opaque_len); | ||
|
||
void apply_cuda_sph_with_hessians_f64(cudaStream_t stream, void **in, | ||
const char *opaque, | ||
std::size_t opaque_len); | ||
|
||
} // namespace cuda | ||
} // namespace sphericart_jax | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
import jax | ||
from .lib import sphericart_jax | ||
from .spherical_harmonics import spherical_harmonics | ||
|
||
|
||
# register the operations to xla | ||
for _name, _value in sphericart_jax.registrations().items(): | ||
if _name.startswith("cpu_"): | ||
jax.lib.xla_client.register_custom_call_target(_name, _value, platform="cpu") | ||
elif _name.startswith("cuda_"): | ||
jax.lib.xla_client.register_custom_call_target(_name, _value, platform="gpu") | ||
else: | ||
raise NotImplementedError(f"Unsupported target {_name}") | ||
raise NotImplementedError(f"Unsupported target in sphericart_jax_cpu {_name}") | ||
|
||
try: | ||
from .lib import sphericart_jax_gpu | ||
# register the operations to xla | ||
for _name, _value in sphericart_jax_gpu.registrations().items(): | ||
if _name.startswith("cuda_"): | ||
jax.lib.xla_client.register_custom_call_target(_name, _value, platform="gpu") | ||
else: | ||
raise NotImplementedError(f"Unsupported target in sphericart_jax_gpu {_name}") | ||
|
||
|
||
except: | ||
pass | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.