// Dtype2DataType converts a tensor.Dtype to a cudnnDataType.
772892
func Dtype2DataType(t tensor.Dtype) cudnn.DataType {
	switch t.Name() {
	case "float64":
		return cudnn.Double
	case "float32":
		return cudnn.Float
	case "float16":
		return cudnn.Half
	case "int8":
		return cudnn.Int8
	case "int32":
		return cudnn.Int32
	case "int128":
		return cudnn.Int8x4
	}
	panic("Unreachable")
}
144204
func (s *MessageAttributeValue) SetDataType(v string) *MessageAttributeValue {
	s.DataType = &v
	return s
}
854986
func DiffuseMapTyped(data map[string]interface{}, fieldJoiner string, typePrefixSeparator string) (map[string]interface{}, []error) {
    errs   := make([]error, 0)
    output := make(map[string]interface{})

//  get the list of keys and sort them because order in a map is undefined
    dataKeys := StringKeys(data)
    sort.Strings(dataKeys)

//  for each data item
    for _, key := range dataKeys {
        var keyParts []string

        value, _ := data[key]

    //  handle "typed" maps in which the type information is embedded
        if typePrefixSeparator != "" {
            typeKeyPair := strings.SplitN(key, typePrefixSeparator, 2)

            if len(typeKeyPair) == 2 {
                key = typeKeyPair[1]

                if v, err := coerceIntoType(value, typeKeyPair[0]); err == nil {
                    value = v
                }else{
                    errs = append(errs, err)
                }
            }else{
                if v, err := coerceIntoType(value, `str`); err == nil {
                    value = v
                }else{
                    errs = append(errs, err)
                }
            }

        }

        keyParts = strings.Split(key, fieldJoiner)

        output = DeepSet(output, keyParts, value).(map[string]interface{})
    }

    return output, errs
}
1158262
func InDepTypes(x DependencyType, set []DependencyType) bool {
	for _, v := range set {
		if v == x {
			return true
		}
	}
	return false
}
543776
func (typedData *TypedData) EncodeType(primaryType string) hexutil.Bytes {
	// Get dependencies primary first, then alphabetical
	deps := typedData.Dependencies(primaryType, []string{})
	slicedDeps := deps[1:]
	sort.Strings(slicedDeps)
	deps = append([]string{primaryType}, slicedDeps...)

	// Format as a string with fields
	var buffer bytes.Buffer
	for _, dep := range deps {
		buffer.WriteString(dep)
		buffer.WriteString("(")
		for _, obj := range typedData.Types[dep] {
			buffer.WriteString(obj.Type)
			buffer.WriteString(" ")
			buffer.WriteString(obj.Name)
			buffer.WriteString(",")
		}
		buffer.Truncate(buffer.Len() - 1)
		buffer.WriteString(")")
	}
	return buffer.Bytes()
}
1221601
func (b ShapeValueBuilder) GoType(ref *ShapeRef, elem bool) string {
	if ref.Shape.Type != "structure" && ref.Shape.Type != "list" && ref.Shape.Type != "map" {
		// Scalars are always pointers.
		return ref.GoTypeWithPkgName()
	}

	prefix := ""
	if ref.Shape.Type == "list" {
		ref = &ref.Shape.MemberRef
		prefix = "[]"
	}

	if elem {
		return prefix + ref.Shape.GoTypeWithPkgNameElem()
	}
	return prefix + ref.GoTypeWithPkgName()
}
447578
func (m *DbMap) TableForType(t reflect.Type) *TableMap {
	for _, table := range m.tables {
		if table.gotype == t {
			return table
		}
	}
	return nil
}
72440
func (s *PutTemplateService) OpType(opType string) *PutTemplateService {
	s.opType = opType
	return s
}
450159
func getAllDepTypes() []string {
	depTypes := make([]string, 0, len(cmds))
	for depType := range cmds {
		depTypes = append(depTypes, depType)
	}
	sort.Strings(depTypes)
	return depTypes
}
152740
func (co *Context) SpatialTfSamplerForward(stDesc *SpatialTransformer, alpha float64, xDesc *TensorDescriptor, x Memory, grid Memory, beta float64, yDesc *TensorDescriptor, y Memory) error {
	// DOUBLECHECK: "cudnnSpatialTfSamplerForward" returns Memory type in Parameter 8
	var alphaC, betaC unsafe.Pointer
	switch xDesc.dataType {
	case Float, Half:
		var alphaF, betaF C.float
		alphaF = C.float(float32(alpha))
		betaF = C.float(float32(beta))
		alphaC = unsafe.Pointer(&alphaF)
		betaC = unsafe.Pointer(&betaF)
	case Double:
		var alphaF, betaF C.double
		alphaF = C.double(alpha)
		betaF = C.double(beta)
		alphaC = unsafe.Pointer(&alphaF)
		betaC = unsafe.Pointer(&betaF)
	default:
		return errors.Errorf("Unsupported data type: %v", xDesc.dataType)
	}
	// call cudnnSpatialTfSamplerForward
	return result(C.cudnnSpatialTfSamplerForward(co.internal, stDesc.internal, alphaC, xDesc.internal, x.Pointer(), grid.Pointer(), betaC, yDesc.internal, y.Pointer()))
}
473209
func HeadersForType(obj interface{}) []string {
	t := reflect.TypeOf(obj)
	if t.Kind() != reflect.Struct {
		panic(errNotStruct)
	}
	headers := make([]string, t.NumField())
	for i := 0; i < t.NumField(); i++ {
		headers[i] = strings.ToUpper(t.Field(i).Name)
	}
	return headers
}
292925
func (s *GetScalingPlanResourceForecastDataInput) SetForecastDataType(v string) *GetScalingPlanResourceForecastDataInput {
	s.ForecastDataType = &v
	return s
}
553212
func SupportsDType(path string) (bool, error) {
	// locate dummy so that we have at least one dirent
	dummy, err := locateDummyIfEmpty(path)
	if err != nil {
		return false, err
	}
	if dummy != "" {
		defer os.Remove(dummy)
	}

	visited := 0
	supportsDType := true
	fn := func(ent *syscall.Dirent) bool {
		visited++
		if ent.Type == syscall.DT_UNKNOWN {
			supportsDType = false
			// stop iteration
			return true
		}
		// continue iteration
		return false
	}
	if err = iterateReadDir(path, fn); err != nil {
		return false, err
	}
	if visited == 0 {
		return false, fmt.Errorf("did not hit any dirent during iteration %s", path)
	}
	return supportsDType, nil
}
1188229
func IsTypeSupported(t ImageType) bool {
	_, ok := ImageTypes[t]
	return ok && IsImageTypeSupportedByVips(t).Load
}
809883
func (s Slice) IsType(t ValueType) bool {
	return typeMap[s.head()] == t
}
1299001
func (c Cid) Type() uint64 {
	if c.Version() == 0 {
		return DagProtobuf
	}
	_, n := uvarint(c.str)
	codec, _ := uvarint(c.str[n:])
	return codec
}
311687
func (p *Packet) GetUDPType() byte {
	// Every UDP control packet has a 20 byte packet signature. The
	// first 2 bytes represent the following control information.
	// Byte 0 : Bits 0,1 are reserved fields.
	//          Bits 2,3,4 represent version information.
	//          Bits 5,6 represent udp packet type,
	//          Bit 7 represents encryption. (currently unused).
	// Byte 1: reserved for future use.
	// Bytes [2:20]: Packet signature.
	return GetUDPTypeFromBuffer(p.ipHdr.Buffer[p.ipHdr.ipHeaderLen:])
}