Skip to content
Open
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
2 changes: 2 additions & 0 deletions include/GafferML/Tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class GAFFERML_API Tensor : public IECore::Object
IECore::DataPtr asData();
IECore::ConstDataPtr asData() const;

static const char *elementDataTypeToString( ONNXTensorElementDataType elementDataType );

private :

struct State : public IECore::RefCounted
Expand Down
2 changes: 1 addition & 1 deletion src/Gaffer/TweakPlug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ T applyNumericTweak(
)
);
default:
throw IECore::Exception( fmt::format( "Not a valid tweak mode: {}.", mode ) );
throw IECore::Exception( fmt::format( "Not a valid tweak mode: {}.", TweakPlug::modeToString( mode ) ) );
}
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/GafferArnold/ParameterHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ Gaffer::Plug *ParameterHandler::setupPlug( const AtNodeEntry *node, const AtPara
"GafferArnold::ParameterHandler::setupPlug",
fmt::format(
"Unsupported plug type \"{}\" for parameter \"{}\"",
plugTypeOverride,
plugTypeOverride.c_str(),
name.c_str()
)
);
Expand Down Expand Up @@ -581,7 +581,7 @@ Gaffer::Plug *ParameterHandler::setupPlug( const AtNodeEntry *node, const AtPara
"GafferArnold::ParameterHandler::setupPlug",
fmt::format(
"Unsupported parameter \"{}\" of type \"{}\" on node \"{}\" of type \"{}\"",
AiParamGetName( parameter ),
AiParamGetName( parameter ).c_str(),
AiParamGetTypeName( AiParamGetType( parameter ) ),
nodeName( plugParent ),
AiNodeEntryGetName( node )
Expand Down
2 changes: 1 addition & 1 deletion src/GafferCycles/IECoreCyclesPreview/IECoreCycles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ bool init()
auto kernelFile = std::filesystem::path( cyclesRootValue ) / "source" / "kernel" / "types.h";
if( !std::filesystem::is_regular_file( kernelFile ) )
{
IECore::msg( IECore::Msg::Error, "IECoreCycles::init", fmt::format( "File \"{}\" not found", kernelFile ) );
IECore::msg( IECore::Msg::Error, "IECoreCycles::init", fmt::format( "File \"{}\" not found", kernelFile.string() ) );
Copy link
Member

Choose a reason for hiding this comment

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

I think we can #include "fmt/std.h" to get automatically formatting of paths.

return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/GafferCycles/IECoreCyclesPreview/OIIOOutputDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void OIIOOutputDriver::write_render_tile( const Tile &tile )
for( int i = 0; i < layer.numChannels; ++i )
{
spec.channelnames.push_back(
fmt::format( "{}{}{}", layerName, layerName.size() ? "." : "", g_channels[i] )
fmt::format( "{}{}{}", layerName, layerName.size() ? "." : "", g_channels[i].string() )
Copy link
Member

Choose a reason for hiding this comment

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

I think we should have Cortex provide a formatter for InternedString, so we don't need to do this at all call sites.

);
}
}
Expand Down
38 changes: 37 additions & 1 deletion src/GafferImage/Merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,42 @@ struct OpMax
static const SingleInputMode onlyB = Operate;
};

const char *mergeOpToString( Merge::Operation op )
{
switch( op )
{
case Merge::Add:
return "Add";
case Merge::Atop:
return "Atop";
case Merge::Divide:
return "Divide";
case Merge::In:
return "In";
case Merge::Out:
return "Out";
case Merge::Mask:
return "Mask";
case Merge::Matte:
return "Matte";
case Merge::Multiply:
return "Multiply";
case Merge::Over:
return "Over";
case Merge::Subtract:
return "Subtract";
case Merge::Difference:
return "Difference";
case Merge::Under:
return "Under";
case Merge::Min:
return "Min";
case Merge::Max:
return "Max";
}
return "Invalid";
}

template< class Functor, typename... Args >
typename Functor::ReturnType dispatchOperation( Merge::Operation op, Functor &&functor, Args&&... args )
{
Expand All @@ -201,7 +237,7 @@ typename Functor::ReturnType dispatchOperation( Merge::Operation op, Functor &&f
case Merge::Min : return functor.template operator()<OpMin>( std::forward<Args>( args )... );
case Merge::Max : return functor.template operator()<OpMax>( std::forward<Args>( args )... );
default:
throw InvalidArgumentException( fmt::format( "Invalid Merge Operation : {}", op ) );
throw InvalidArgumentException( fmt::format( "Invalid Merge Operation : {}", mergeOpToString( op ) ) );
}
}

Expand Down
56 changes: 55 additions & 1 deletion src/GafferML/Tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void dispatchTensorData( const Ort::Value &value, F &&functor )
// > implies that we shouldn't know that, let alone depend on it.
[[fallthrough]];
default :
throw IECore::Exception( fmt::format( "Unsupported element type {}", elementType ) );
throw IECore::Exception( fmt::format( "Unsupported element type {}", Tensor::elementDataTypeToString( elementType ) ) );
}
}

Expand Down Expand Up @@ -478,3 +478,57 @@ IECore::ConstDataPtr Tensor::asData() const
}
return dataFromValue( m_state->value );
}

const char *Tensor::elementDataTypeToString( ONNXTensorElementDataType elementDataType )
{
switch( elementDataType )
{
case ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED :
return "Undefined";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT :
return "Float";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8 :
return "Uint8";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8 :
return "Int8";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16 :
return "Uint16";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16 :
return "Int16";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32 :
return "Int32";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64 :
return "int64";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING :
return "String";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL :
return "Bool";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16 :
return "Float16";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE :
return "Double";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32 :
return "Uint32";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64 :
return "Uint64";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64 :
return "Complex64";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128 :
return "Complex128";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16 :
return "BFloat16";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E4M3FN :
return "Float8E4M3FN";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E4M3FNUZ :
return "Float8E4M3FNUZ";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E5M2 :
return "Float8E5M2";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E5M2FNUZ :
return "Float8E5M2FNUZ";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT4 :
return "Uint4";
case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT4 :
return "Int4";
}
return "Invalid";
}
2 changes: 1 addition & 1 deletion src/GafferML/TensorToImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ IECore::ConstFloatVectorDataPtr TensorToImage::computeChannelData( const std::st
if( elementType != ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT )
{
/// \todo Support other types by converting to float.
throw IECore::Exception( fmt::format( "Unsupported tensor data type \"{}\"", elementType ) );
throw IECore::Exception( fmt::format( "Unsupported tensor data type \"{}\"", Tensor::elementDataTypeToString( elementType ) ) );
}

FloatVectorDataPtr outData = new FloatVectorData;
Expand Down
4 changes: 2 additions & 2 deletions src/GafferMLModule/GafferMLModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ std::string tensorRepr( const Tensor &tensor )
{
// We don't have a good `repr()` for this - just return a default one
// and the ValuePlugSerialiser will attempt a base 64 encoding instead.
return fmt::format( "<GafferML._GafferML.Tensor object at {}>", (void *)&tensor );
return fmt::format( "<GafferML._GafferML.Tensor object at {}>", reinterpret_cast<uintptr_t>( (void *)&tensor ) );
}
}

Expand Down Expand Up @@ -152,7 +152,7 @@ object tensorGetItem( const Tensor &tensor, const std::vector<int64_t> &location
case ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING :
return object( tensor.value().GetStringTensorElement( toLinearIndex( tensor.shape(), location ) ) );
default :
throw IECore::Exception( fmt::format( "Unsupported element type {}", elementType ) );
throw IECore::Exception( fmt::format( "Unsupported element type {}", Tensor::elementDataTypeToString( elementType ) ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/GafferScene/IECoreScenePreview/PrimitiveAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ IECoreScene::PrimitivePtr PrimitiveAlgo::mergePrimitives(
else
{
throw IECore::Exception( fmt::format(
"Unsupported Primitive type for merging: {}", primitives[0].first->typeId()
"Unsupported Primitive type for merging: {}", IECore::RunTimeTyped::typeNameFromTypeId( primitives[0].first->typeId() )
) );
}
}
2 changes: 1 addition & 1 deletion src/GafferScene/RenderController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,7 @@ void RenderController::updateInternal( const ProgressCallback &callback, const I
IECore::Msg::Warning, "RenderController",
fmt::format(
"{} attribute edit{} required geometry to be regenerated",
m_failedAttributeEdits, m_failedAttributeEdits > 1 ? "s" : ""
m_failedAttributeEdits.load(), m_failedAttributeEdits > 1 ? "s" : ""
Copy link
Member

Choose a reason for hiding this comment

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

I think this is another one that would be dealt with by #include "fmt/std.h"

)
);
m_failedAttributeEdits = 0;
Expand Down
12 changes: 6 additions & 6 deletions src/IECoreArnold/ParameterAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ void setParameterInternal( AtNode *node, AtString name, int parameterType, bool
AtArray *a = ParameterAlgo::dataToArray( value, parameterType );
if( !a )
{
msg( Msg::Warning, messageContext, fmt::format( "Unable to create array from data of type \"{}\" for parameter \"{}\"", value->typeName(), name ) );
msg( Msg::Warning, messageContext, fmt::format( "Unable to create array from data of type \"{}\" for parameter \"{}\"", value->typeName(), name.c_str() ) );
Copy link
Member

Choose a reason for hiding this comment

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

There are enough of these that perhaps it would be better to register a formatter for AtString? I think format_as allows us to do that quite simply?

return;
}
if( AiArrayGetType( a ) != parameterType )
{
msg( Msg::Warning, messageContext, fmt::format( "Unable to create array of type {} from data of type \"{}\" for parameter \"{}\"", AiParamGetTypeName( parameterType ), value->typeName(), name ) );
msg( Msg::Warning, messageContext, fmt::format( "Unable to create array of type {} from data of type \"{}\" for parameter \"{}\"", AiParamGetTypeName( parameterType ), value->typeName(), name.c_str() ) );
return;
}
AiNodeSetArray( node, name, a );
Expand All @@ -99,7 +99,7 @@ void setParameterInternal( AtNode *node, AtString name, int parameterType, bool
}
else
{
msg( Msg::Warning, "setParameter", fmt::format( "Int64Data value {} is out of range for parameter \"{}\"", data->readable(), name ) );
msg( Msg::Warning, "setParameter", fmt::format( "Int64Data value {} is out of range for parameter \"{}\"", data->readable(), name.c_str() ) );
}
}
else if( const IntData *data = dataCast<IntData>( name, value, messageContext ) )
Expand All @@ -117,7 +117,7 @@ void setParameterInternal( AtNode *node, AtString name, int parameterType, bool
}
else
{
msg( Msg::Warning, "setParameter", fmt::format( "UInt64Data value {} is out of range for parameter \"{}\"", data->readable(), name ) );
msg( Msg::Warning, "setParameter", fmt::format( "UInt64Data value {} is out of range for parameter \"{}\"", data->readable(), name.c_str() ) );
}
}
else if( const IntData *data = runTimeCast<const IntData>( value ) )
Expand Down Expand Up @@ -251,7 +251,7 @@ void setParameterInternal( AtNode *node, AtString name, int parameterType, bool
nodeStr = AiNodeEntryGetName( AiNodeGetNodeEntry( node ) );
}

msg( Msg::Warning, messageContext, fmt::format( "Arnold parameter \"{}\" on node \"{}\" has unsupported type \"{}\".", name, nodeStr, AiParamGetTypeName( parameterType ) ) );
msg( Msg::Warning, messageContext, fmt::format( "Arnold parameter \"{}\" on node \"{}\" has unsupported type \"{}\".", name.c_str(), nodeStr, AiParamGetTypeName( parameterType ) ) );
}
}
}
Expand Down Expand Up @@ -396,7 +396,7 @@ void setParameter( AtNode *node, AtString name, const IECore::Data *value, const
msg(
Msg::Warning,
messageContext,
fmt::format( "Unsupported data type \"{}\" for name \"{}\"", value->typeName(), name )
fmt::format( "Unsupported data type \"{}\" for name \"{}\"", value->typeName(), name.c_str() )
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/IECoreArnold/ShaderNetworkAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void NodeParameter::updateParameter() const
AiNodeResetParameter( m_node, m_parameterName );
msg(
Msg::Warning, "NodeParameter",
fmt::format( "{}.{} : Node \"{}\" not found", AiNodeGetName( m_node ), m_parameterName, m_parameterValue )
fmt::format( "{}.{} : Node \"{}\" not found", AiNodeGetName( m_node ), m_parameterName.c_str(), m_parameterValue.c_str() )
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/IECoreArnold/ShapeAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void convertPrimitiveVariable( const IECoreScene::Primitive *primitive, const Pr
msg(
Msg::Warning,
messageContext,
fmt::format( "Unable to create user parameter \"{}\" because primitive variable has unsupported interpolation", name )
fmt::format( "Unable to create user parameter \"{}\" because primitive variable has unsupported interpolation", name.c_str() )
);
return;
}
Expand Down Expand Up @@ -314,7 +314,7 @@ void convertPrimitiveVariable( const IECoreScene::Primitive *primitive, const Pr
msg(
Msg::Warning,
messageContext,
fmt::format( "Unable to create user parameter \"{}\" for primitive variable of type \"{}\"", name, primitiveVariable.data->typeName() )
fmt::format( "Unable to create user parameter \"{}\" for primitive variable of type \"{}\"", name.c_str(), primitiveVariable.data->typeName() )
);
return;
}
Expand Down Expand Up @@ -371,7 +371,7 @@ void convertPrimitiveVariable( const IECoreScene::Primitive *primitive, const Pr
msg(
Msg::Warning,
messageContext,
fmt::format( "Failed to create array for parameter \"{}\" from data of type \"{}\"", name, primitiveVariable.data->typeName() )
fmt::format( "Failed to create array for parameter \"{}\" from data of type \"{}\"", name.c_str(), primitiveVariable.data->typeName() )
);
}

Expand Down