Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MultilineChartContent not defined #119

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
52 changes: 33 additions & 19 deletions src/Loggers/LogCustomScalar.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using .tensorboard_plugin_custom_scalar
using .tensorboard_plugin_custom_scalar: var"MarginChartContent.Series" as MarginChartContent_Series

# possible chart types
@enum tb_chart_type tb_multiline=1 tb_margin=2

Expand Down Expand Up @@ -25,14 +28,12 @@ function chart(name::String, metadata::Tuple{tb_chart_type, AbstractArray})
chart_type, tags = metadata

if chart_type == tb_multiline
content = MultilineChartContent(tag = tags)
return Chart(title = name, multiline = content)
content = MultilineChartContent(tags)
return Chart(name, OneOf(:multiline, content))
elseif chart_type == tb_margin
@assert length(tags) == 3
args = Dict(k => v for (k, v) in zip([:value, :lower, :upper], tags))
content = MarginChartContent(
series = [MarginChartContent_Series(; args...)])
return Chart(title = name, margin = content)
@assert length(tags) == 3 # value, lower, upper
content = MarginChartContent([MarginChartContent_Series(tags...)])
return Chart(name, OneOf(:margin, content))
else
@error "The chart type must be `tb_multiline` or `tb_margin`"
end
Expand All @@ -44,16 +45,29 @@ end

function custom_scalar_summary(layout)
cat_spec = zip(keys(layout), values(layout))
categories = [Category(title = k, chart = charts(c)) for (k, c) in cat_spec]

layout = Layout(category = categories)
plugin_data = SummaryMetadata_PluginData(plugin_name = "custom_scalars")
smd = SummaryMetadata(plugin_data = plugin_data)
cs_tensor = TensorProto(dtype = _DataType.DT_STRING,
string_val = [serialize_proto(layout)],
tensor_shape = TensorShapeProto())

Summary_Value(tag = "custom_scalars__config__",
tensor = cs_tensor,
metadata = smd)
categories = [Category(title, charts(c), false) for (title, c) in cat_spec]

layout = Layout(zero(Int32), categories)
plugin_data = SummaryMetadata_PluginData("custom_scalars", UInt8[])
smd = SummaryMetadata(plugin_data, "", "", DataClass.DATA_CLASS_UNKNOWN)
cs_tensor = TensorProto(_DataType.DT_STRING,
nothing,
zero(Int32),
UInt8[],
Int32[],
Float32[],
Float64[],
Int32[],
[serialize_proto(layout)],
Float32[],
Int64[],
Bool[],
Float64[],
ResourceHandleProto[],
VariantTensorDataProto[],
UInt32[],
UInt64[],
UInt8[])

Summary_Value("", "custom_scalars__config__", smd, OneOf(:tensor, cs_tensor))
end
Loading