MCPcopy Index your code
hub / github.com/lutzroeder/netron / addOrCheckAttribute

Method addOrCheckAttribute

source/python.js:10552–10563  ·  view source on GitHub ↗
(name, ty, is_parameter, is_buffer)

Source from the content-addressed store, hash-verified

10550 return slot;
10551 }
10552 addOrCheckAttribute(name, ty, is_parameter, is_buffer) {
10553 is_parameter = is_parameter || false;
10554 is_buffer = is_buffer || false;
10555 const slot_idx = this.findAttributeSlot(name);
10556 if (slot_idx === null) {
10557 return this.addAttribute(name, ty, is_parameter, is_buffer);
10558 }
10559 // TORCH_CHECK(is_parameter == this.is_parameter(*slot_idx), "Parameter field mismatch for the field '", name, "'");
10560 // const TypePtr& atype = getAttribute(*slot_idx);
10561 // TORCH_CHECK(ty.isSubtypeOf(*atype), ty.repr_str(), " is not compatible with the type ", atype.repr_str(), " for the field '", name, "'");
10562 return slot_idx;
10563 }
10564 findAttributeSlot(name) {
10565 for (let pos = 0; pos < this._attributes.length; pos++) {
10566 if (name === this._attributes[pos].name) {

Callers 4

register_moduleMethod · 0.80
register_bufferMethod · 0.80
register_parameterMethod · 0.80
register_attributeMethod · 0.80

Calls 2

findAttributeSlotMethod · 0.80
addAttributeMethod · 0.45

Tested by

no test coverage detected