Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephan Seitz
pystencils
Commits
9bb1e142
Commit
9bb1e142
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Add custom_backend to pystencils.show_code
parent
19f54169
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils/display_utils.py
+7
-5
7 additions, 5 deletions
pystencils/display_utils.py
with
7 additions
and
5 deletions
pystencils/display_utils.py
+
7
−
5
View file @
9bb1e142
import
sympy
as
sp
from
typing
import
Any
,
Dict
,
Optional
import
sympy
as
sp
from
pystencils.astnodes
import
KernelFunction
...
...
@@ -32,7 +34,7 @@ def highlight_cpp(code: str):
return
HTML
(
highlight
(
code
,
CppLexer
(),
HtmlFormatter
()))
def
show_code
(
ast
:
KernelFunction
):
def
show_code
(
ast
:
KernelFunction
,
custom_backend
=
None
):
"""
Returns an object to display generated code (C/C++ or CUDA)
Can either be displayed as HTML in Jupyter notebooks or printed as normal string.
...
...
@@ -45,11 +47,11 @@ def show_code(ast: KernelFunction):
self
.
ast
=
ast_input
def
_repr_html_
(
self
):
return
highlight_cpp
(
generate_c
(
self
.
ast
,
dialect
=
dialect
)).
__html__
()
return
highlight_cpp
(
generate_c
(
self
.
ast
,
dialect
=
dialect
,
custom_backend
=
custom_backend
)).
__html__
()
def
__str__
(
self
):
return
generate_c
(
self
.
ast
,
dialect
=
dialect
)
return
generate_c
(
self
.
ast
,
dialect
=
dialect
,
custom_backend
=
custom_backend
)
def
__repr__
(
self
):
return
generate_c
(
self
.
ast
,
dialect
=
dialect
)
return
generate_c
(
self
.
ast
,
dialect
=
dialect
,
custom_backend
=
custom_backend
)
return
CodeDisplay
(
ast
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment