https://github.com/kurama622/tensorflow-custom-op
tensorflow custom op
https://github.com/kurama622/tensorflow-custom-op
Last synced: 7 months ago
JSON representation
tensorflow custom op
- Host: GitHub
- URL: https://github.com/kurama622/tensorflow-custom-op
- Owner: Kurama622
- License: apache-2.0
- Created: 2022-08-13T08:48:35.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-13T15:37:57.000Z (about 3 years ago)
- Last Synced: 2025-01-11T18:47:07.489Z (9 months ago)
- Language: C++
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TensorFlow Custom Op
This is a matrix multiplication operation.
You can find detailed principles and instructions [here](https://svegeta.gitee.io/tensorflow/tensorflow-custom-op-cpp/)
## USAGE
### No Gradients InvolvedExample: `op_mymatmul_test.py`
```python
import tensorflow as tf
m = tf.load_op_library('./op_mymatmul.so')a = tf.constant(
[[1., 2],
[3, 4],
[1, 1]])b = tf.constant(
[[1., 2, 1],
[3, 4, 1]])with tf.Session('') as s:
print(s.run(m.mymatmul(a, b)))
print(s.run(tf.matmul(a, b)))
```### Need Gradients
```python
# ...import op_mymatmul_grad
# ...
# In addition to replacing matrix multiplication with mymatmul, just write your neural network model normally
m = tf.load_op_library('./op_mymatmul.so')
m.mymatmul(...)
```